RE: [Update #2] XML Schema 1.1 Tutorial

>From slide 24:

"Example: in XSD 1.0 the below instance document is invalid because the 
<Title> element matches both the explicit element declaration and the 
<any/> wildcard.  In XSD 1.1, the instance is valid."

Not quite right.  In XSD 1.0, the >>schema<< is not legal, because there 
exist document(s) such as the one you show that have elements that would 
be attributed ambiguously.  So, it would be better to say something like:

"Example: in XSD 1.0 the complexType declaration shown below is not legal, 
because there are documents with elements like <Title> that could match 
either the explicit element declaration or the wildcard.  In XSD 1.1, this 
schema is valid, and the <Title> element is validated against the element 
declaration (not the wildcard)."

Also:  I think it might be useful to explain why this related to 
extensibility.  The reason this was added was because users were 
struggling to write extensible schemas with wildcards.   In XSD 1.1, the 
new rules for <any> allow you to put wildcards exactly where you want 
them, and <openContent> helps you get the effect of wildcards being added 
automatically.  I wonder whether a more useful slide title for novices 
might be "More flexible rules for wildcards" instead of "Non-Deterministic 
Content Models".  So, something like (I changed the example to use an 
integer and to add some optional content, as that makes clearer the 
significance of validating against the explicit declaration vs. wildcard). 
 Feel free to use the following or adapt to your taste.

------------------

Title: More Flexible Rules for Wildcards

Wildcards (<xs:any>) are important tools for describing extensible 
languages , but in XSD 1.0, it could be difficult or impossible to use 
wildcards near optional content.  XSD 1.1 is much more flexible.

"Example: in XSD 1.0 the complexType declaration shown below is not legal, 
because there are documents with elements like <Pages> that could match 
either the explicit element declaration or the wildcard.  In XSD 1.1, this 
schema is valid, and the <Pages> element is validated as an integer by the 
element declaration;  The <Reviews> and <Binding> elements are validated 
against the wildcard ."

<xs:element name="Book">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Title" type="xs:string" minOccurs="0"/>
                   <xs:element name="Pages" type="xs:integer" 
minOccurs="0"/> 
            <xs:any minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
----------
<Book>
        <Title>The Origin of Wealth</Title>
           <Pages>321</Pages>
           <Reviews>Excellent</Reviews>
           <Binding>Hardcover</Binding>
</Book> 


-------------

Noah

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------








"Costello, Roger L." <costello@mitre.org>
Sent by: xmlschema-dev-request@w3.org
08/12/2009 03:11 PM
 
        To:     "'noah_mendelsohn@us.ibm.com'" 
<noah_mendelsohn@us.ibm.com>
        cc:     "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
        Subject:        RE: [Update #2]  XML Schema 1.1 Tutorial



Thanks again Noah. Great suggestion! See slide 24:

 http://www.xfront.com/xml-schema-1-1/xml-schema-1-1.ppt

/Roger



> -----Original Message-----
> From: noah_mendelsohn@us.ibm.com [mailto:noah_mendelsohn@us.ibm.com] 
> Sent: Wednesday, August 12, 2009 2:41 PM
> To: Costello, Roger L.
> Cc: xmlschema-dev@w3.org
> Subject: Re: [Update #2] XML Schema 1.1 Tutorial
> 
> Suggestion:
> 
> I think the changes to support non-deterministic content 
> models involving 
> <any> is a big deal, and it would be good to highlight that in the 5 
> minute intro along with the syntax changes to <any>
> 
> Use case is:
> 
> You have a content model like:
> 
>         <sequence>
>                 <element ref="a" />
>                 <element ref="optionalelement" minOccurs="0" />
>                 <!-- want to allow extensions here -->
> 
>         </sequence>
> 
> You want an optional wildcard at the end, and for whatever 
> reason prefer 
> not to use openContent (you like the explicit <any>, you want 
> to control 
> exactly where the extenion points are and some may not be at the end, 
> etc.)  So, you want:
> 
>         <sequence>
>                 <element ref="a" />
>                 <element ref="optionalelement" minOccurs="0" />
>                 <!-- want to allow extensions here -->
>                 <any minOccurs="0" maxOccurs="unbounded" />
>         </sequence>
> 
> In XSD 1.0 you could not do this, because an <optionalelement 
> /> in the 
> instance matched both the explicit particle and the wildcard. 
>  In XSD 1.1, 
> this does what you want.  I think that's worth pointing out.  Also, 
> <openContent> works in the presence of optional elements, so 
> there's no 
> ambiguity problem with that in XSD 1.1 either.  Content will 
> match the 
> explicit element particle in preference to either an <any> or 
> openContent. 
>  I'm fairly sure that if there is an ambiguity between an <any> and 
> <openContent> the tie goes to the explicit <any>.  In 
> general, openContent 
> only gets checked if you were otherwise about to fail validation.  I 
> think.
> 
> Noah
> 
> --------------------------------------
> Noah Mendelsohn 
> IBM Corporation
> One Rogers Street
> Cambridge, MA 02142
> 1-617-693-4036
> --------------------------------------
> 
> 
> 
> 
> 
> 
> 
> 
> "Costello, Roger L." <costello@mitre.org>
> Sent by: xmlschema-dev-request@w3.org
> 08/08/2009 01:27 PM
> 
>         To:     "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
>         cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
>         Subject:        [Update #2]  XML Schema 1.1 Tutorial
> 
> 
> 
> Hi Folks,
> 
> Here are the updates I made to the XML Schema 1.1 Tutorial:
> 
>     1. I received many excellent comments and 
>        incorporated them.
> 
>     2. I created 20 lab exercises. I recommend 
>        working the exercises as you read through 
>        the tutorial.
> 
> 
> Here is the updated tutorial:
> 
> http://www.xfront.com/xml-schema-1-1/xml-schema-1-1.ppt
> 
> 
> Here is the updated tutorial + labs + examples:
> 
> http://www.xfront.com/xml-schema-1-1/xml-schema-1-1.zip
> 
> 
> As always, please let me know if there is anything in the 
> tutorial that is 
> unclear or if you find a typo. 
> 
> /Roger
> 
> 
> 

Received on Wednesday, 12 August 2009 20:31:43 UTC