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

Re: XML Schemas: Best Practices

  • From: "Roger L. Costello" <costello@m...>
  • To: xml-dev@l...
  • Date: Thu, 14 Dec 2000 14:41:25 -0500

xml element substitution
Hi Folks,

[1] I would like to put on hold the topic of "Capturing Semantics of XML
Schema Components".  I realize now that that is a huge topic and it is
probably best to hold off on it till after the holidays.

[2] I gave a talk last week at XML 2000 on the results of our Best
Practices discussions.  An on-line version of the talk may be found at: 

       http://www.xfront.com/xml2000/

[3] The issue that I would like to start on now is: "Use Cases for
element substitution".  I would like for us to collectively come up with
a set of use cases for where it is appropriate to use element
substitution.

First, let's recall what element substitution is all about.  Element
substitution allows you to create an element that can substitute for
another element in an instance document.

Example.

In the below example I declare an element, metro, which can substitute
for subway in instance documents:

    <element name="subway" type="string"/>
    <element name="metro" substitutionGroup="a:subway"/>
    <element name="transportation">
        <complexType>
            <sequence>
                 <element ref="a:subway"/>
            </sequence>
        </complexType>
    </element>

Here's an instance document which uses <subway>:

    <transportation>
        <subway>Red Line</subway>
    </transportation>

Since metro can substitute for subway, here is another instance document
where <transportation> contains <metro>:

    <transportation>
        <metro>Red Line</metro>
    </transportation>

Thus, this example shows how the subway element may be substituted by
the metro element.

Is this subway/metro example a good use case for element substitution?

It occurred to me that one use case for element substitution is for
allowing instance document tags to be expressed in different languages.

For the above example I could use element substitution to enable
instance document authors to express <transportation> or <subway> in
either English or German:

   <element name="subway" type="string"/>
   <element name="Fußgängerunterführung" substitutionGroup="a:subway"/>
   <complexType name="transport">
        <sequence>
             <element ref="a:subway"/>
        </sequence>
   </complexType>
   <element name="transportation" type="a:transport"/>
   <element name="Beförderung" substitutionGroup="a:transportation"/>

Now someone could create an instance document and use either English or
German tags.  For example, here an instance document is expressed in
German:

    <Beförderung>
        <Fußgängerunterführung>Rot zeile</Fußgängerunterführung>
    </Beförderung>

Is this a good use case for element substitution?

What are other good use cases for element substitution?  I would like
for us to compile a list of use cases.  /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.