OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   XML Schemas: ref'ing versus in-lining

[ Lists Home | Date Index | Thread Index ]
  • From: "Roger L. Costello" <costello@mitre.org>
  • To: xml-dev@lists.xml.org
  • Date: Wed, 13 Sep 2000 09:00:32 -0400

Hi Folks,

I am digging deep into the semantics of "ref".  Consider these examples:

Is the following:

    <element name="foo"> 
       <complexType>
          <element ref="a:bar"/>
       </complexType>
    </element>

    <element name="bar" type="string"/>

equivalent to this:

    <element name="foo"> 
       <complexType>
          <element name="bar" type="string"/>
       </complexType>
    </element>

Note in the first case I ref the bar element, whereas in the second case
I in-line the bar declaration.  Does a ref substitute the reference with
the element declaration, kind of like a macro substitution?

If the above are equivalent, then is this:

    <element name="foo"> 
       <complexType>
          <element ref="a:bar"/>
          <element ref="a:bar"/>
       </complexType>
    </element>

    <element name="bar" type="string"/>

equivalent to this:

    <element name="foo"> 
       <complexType>
          <element name="bar" type="string"/>
          <element name="bar" type="string"/>
       </complexType>
    </element>

Note that I have two references to bar in the first case, and in the
second case I in-line the two declarations.  When I ran this example
through XSV it accepted the first form but gave a warning message on the
second form (but still accepted it).  

In general, I know that it is not legal to have two element declarations
with different content.  For example, this:

    <element name="foo"> 
       <complexType>
          <element name="bar" type="string"/>
          <element name="bar" type="integer"/>
       </complexType>
    </element>

is not legal, and XSV flags it as an error.  May I conclude that it is
legal to multiply declare an element provided they all have the same
type?  

Are there other subtle differences between ref'ing an element versus
in-line declaring the element?  /Roger





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS