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

Quiz: what's the value space of the <Publisher> element?

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "'xml-dev@lists.xml.org'" <xml-dev@lists.xml.org>
  • Date: Mon, 22 Jun 2009 11:47:43 -0400

Quiz: what's the value space of the <Publisher> element?

Hi Folks,

Consider this element declaration:

    <xs:element name="Publisher" type="xs:string"/>

What is Publisher's value space? That is, what values can the <Publisher> element have in an XML instance document:


    <Publisher>_________</Publisher>


The Publisher element is being used by Book:


    <xs:element name="Book">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Title" type="xs:string"/>
                <xs:element name="Author" type="xs:string"/>
                <xs:element name="Date" type="xs:gYear"/>
                <xs:element name="ISBN" type="xs:string"/>
                <xs:element ref="Publisher" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>


Okay, what is Publisher's value space?

Scroll down for the answer ...























































VALUE SPACE

Did you answer:

   The value space of Publisher 
   is an unbounded string.


If you're using XML Schema 1.1 then your answer may be wrong.

XML Schema 1.1 has a new element, the <assert> element. It can impose additional constraints on the Publisher element. For example, the <Book> element is nested within a <BarnesAndNoble> element, which has an <assert> element that constrains the Publisher element to a maximum string length of 140 characters:


    <xs:element name="BarnesAndNoble">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Book" maxOccurs="unbounded" />
            </xs:sequence>
            <xs:assert test="not(Book[string-length(Publisher) gt 140])" />
        </xs:complexType>
    </xs:element>


The <Book> element is also nested within a <Borders> element, which has an <assert> element that constrains the Publisher element to either 'McMillin Publishing', 'Dell Publishing Co.', 'Harper &amp; Row', or 'Wrox Press':


    <xs:element name="Borders">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Book" maxOccurs="unbounded" />
            </xs:sequence>
            <xs:assert test="not(Book[not(Publisher = ('McMillin Publishing',
                                 'Dell Publishing Co.','Harper &amp; Row',
                                 'Wrox Press'))])" />
        </xs:complexType>
    </xs:element>


What's the value space of Publisher?

  - It could be an unbounded string, or

  - It could be a string of max length 140, or

  - It could be an enumeration list, 'McMillin Publishing', 
    'Dell Publishing Co.', 'Harper &amp; Row', or 'Wrox Press'

  - Or, it could be something else.


That's interesting, but so what?

Scroll down to see the "so what" ...


















































SO WHAT?

What this means is that an element declaration cannot be understood on its own, in isolation. 

To understand an element you must understand all possible ancestors of the element. 

Want to create a tool that automatically generates sample instance values for each element declared in the schema? That's relatively straightforward in XML Schema 1.0 because you can understand each element declaration in isolation. In XML Schema 1.1, as the above example illustrates, an element's value cannot be determined in isolation. So, instance-document-generator tools become impossible. (If not impossible, it will certainly be extraordinarily difficult) 

Want to create a tool that does automated analysis of element declarations? That's intractable.  (If not intractable, it will certainly be extraordinarily difficult)


Comments?

/Roger

 


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.