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

XML Schemas: ref'ing versus in-lining

  • From: "Roger L. Costello" <costello@m...>
  • To: xml-dev@l...
  • Date: Wed, 13 Sep 2000 09:00:32 -0400

ref in xml
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


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.