XSchema: Element references and namespaces

Ron Bourret rbourret at dvs1.informatik.tu-darmstadt.de
Mon Sep 21 11:20:24 BST 1998


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 at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list