[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSchema: Element references and namespaces

  • From: rbourret@d... (Ron Bourret)
  • To: xml-dev@i...
  • Date: Mon, 21 Sep 1998 11:18:00 +0200

xschema element ref
I was writing section 4 (conversions) yesterday and realized we have a problem 
referring to elements by name from Ref, AttDef, and AttGroup elements.  For 
example:

   <ElementDecl Name="foo" ns="http://myfoo.org" prefix="myfoo">
      ...
   </ElementDecl>

   <ElementDecl Name="foo" ns="http://yourfoo.org" prefix="yourfoo">
      ...
   </ElementDecl>

   <ElementDecl Name="refersToFoo">
      <Model>
         <Ref Element="foo"/>
      </Model>
   </ElementDecl>

Which foo does the Element attribute in the content model of refersToFoo refer 
to?  I see two solutions to this:

1) Refer to elements by ID.  I don't like this from a usability standpoint -- it 
is far more natural to refer to elements by name.

2) Add nsElement and (possibly) prefixElement attributes to Ref, AttDef, and 
AttGroup.  This matches our namespace implementation, which uses a two-part 
naming system (Name + ns).

Note 1: We cannot name these attributes ns and prefix, as those already exist on 
AttDef and AttGroup and apply to the value of the Name attribute.

Note 2: prefixElement is not strictly necessary -- you could get the prefix from 
the ElementDecl, AttGroup, or AttDef.  Although it makes it possible for the 
user to introduce conflicting prefixes, it also makes conversion to a DTD much 
easier.  Because references can occur before declarations, you can't guarantee a 
successful prefix lookup when you need it.  Thus, you must either make two 
passes over the XSchema or build an in-memory tree before outputting anything.  
I would rather add prefixElement and have the checker check that it matches the 
relevant prefix.

Note 3: Can nsElement inherit from ns and prefixElement inherit from prefix?  In 
many (most?) cases, the content model of elements will refer to elements in the 
same namespace as the element being defined and attributes will belong to the 
same namespace as the element to which they apply.  Thus, it would be nice to 
omit nsElement and just apply ns from the enclosing ElementDecl, AttGroup, or 
AttDef.  However, inheriting from one attribute to another is definitely not in 
the spirit of XML and makes me a bit queasy.

-- Ron Bourret

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.