1 2007-08-29w3c sml f2f xml schema 1.1 sandy gao, ibm
TRANSCRIPT
![Page 1: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/1.jpg)
2007-08-29 W3C SML F2F 1
XML Schema 1.1
Sandy Gao, IBM
![Page 2: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/2.jpg)
W3C SML F2F2007-08-29 2
Agenda
Overview Key improvements over Schema 1.0
DatatypesStructures
References
![Page 3: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/3.jpg)
W3C SML F2F2007-08-29 3
Overview
Schema 1.1 is to address most common issues and requests for schema “users”
Currently at Last Call for datatypes; “almost” at Last Call for structures
Compatibility is a major goalAll 1.0 valid documents are 1.1 validWith exceptions
![Page 4: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/4.jpg)
W3C SML F2F2007-08-29 4
Datatypes Improvements
Alignment with XPath, XSLT, XQuery, etc. specificationsAnyAtomicType, YearMonthDuration,
DayTimeDuration, date/time normalization, … precisionDecimal
To support the anticipated new IEEE-754r type that carries precision
Bug fixes and clarifications
![Page 5: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/5.jpg)
W3C SML F2F2007-08-29 5
Structures Improvements
Co-constraints Assertion Conditional Type Assignment
Versioning Open content , <xs:all>, weakened wildcard, negative
wildcard, conditional inclusion
Complex type restriction Other improvements
![Page 6: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/6.jpg)
W3C SML F2F2007-08-29 6
Assertion
<xs:complexType name="arrayType"> <xs:sequence> <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="length" type="xs:int"/>
</xs:complexType>
Similar to Schematron Use XPath 2.0 to specify boolean expressions
that have to be satisfied Part of complex types
Restriction relation is maintained
<xs:assert test="@length eq fn:count(./entry)"/>
![Page 7: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/7.jpg)
W3C SML F2F2007-08-29 7
Assertion (Cont’)
Most frequently requested schema feature Only the sub-tree rooted at the element
being validated is accessible by XPath evaluationAxis like “..” always returns the empty
sequence Does not completely replace Schematron
![Page 8: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/8.jpg)
W3C SML F2F2007-08-29 8
Conditional Type Assignment
Instance:<message kind="string"> This is a text message.</message><message kind="XML"> <some> <xml>content</xml> </some></message>
Schema:<xs:element name="message" type="messageType"> <xs:alternative test="@kind='string'" type="messageTypeString"/> <xs:alternative test="@kind='base64'" type="messageTypeBase64"/> <xs:alternative test="@kind='binary'" type="messageTypeBase64"/> <xs:alternative test="@kind='xml'" type="messageTypeXML"/> <xs:alternative test="@kind='XML'" type="messageTypeXML"/></xs:element>
![Page 9: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/9.jpg)
W3C SML F2F2007-08-29 9
CTA (Cont’)
Type used for validation is selected based on XPath 2.0 boolean expressions
Only attributes on the current element are accessible by XPath evaluation
![Page 10: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/10.jpg)
W3C SML F2F2007-08-29 10
Versioning
Allow earlier/general versions of schemas to leave extension points
Allow later/specific versions of schemas to customize/extend
![Page 11: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/11.jpg)
W3C SML F2F2007-08-29 11
Open Content
<xs:complexType name="name">
<xs:sequence> <xs:element name="given" type="xs:string"/> <xs:element name="middle" type="xs:string" minOccurs="0"/> <xs:element name="family" type="xs:string"/> </xs:sequence></xs:complexType>
Allow any number of any elements to appear Anywhere in the children list (“interleave”) At the end of the children list (“suffix”)
Leaves extension points in the content model
<xs:openContent> <xs:any mode="interleave"/> </xs:openContent>
![Page 12: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/12.jpg)
W3C SML F2F2007-08-29 12
Open Content (Cont’)
<xs:complexType>
<xs:sequence> <xs:element ref="sml:uri"/> </xs:sequence> <xs:anyAttribute processContents="skip"/></xs:complexType>
“An element with sml:ref=true is an instance of the URI scheme if and only if there is one and only one <sml:uri> element in its [chidren].”
<xs:openContent> <xs:any processContents="skip" notQName="sml:uri"/></xs:openContent>
![Page 13: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/13.jpg)
W3C SML F2F2007-08-29 13
<xs:all> Improvements
Allow maxOccurs to be > 1 Allow wildcards Allow extensions to add new members
![Page 14: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/14.jpg)
W3C SML F2F2007-08-29 14
<xs:all> Improvements (Cont’)<xs:complexType name="computer"><xs:all> <xs:element name="CPU"/> <!-- other computer parts --> <xs:element name="speaker" minOccurs="0" maxOccurs="7"/> <xs:any minOccurs="0" maxOccurs="unbounded"/></xs:all></xs:complexType>
Extension: <xs:extension base="computer"><xs:all> <xs:element name="Joystick"/> </xs:all></xs:extension>
Restriction: <xs:restriction base="computer"><xs:all> <xs:element name="CPU"/><!-- other computer parts --> <xs:any notQName="speaker" minOccurs="0“ maxOccurs="unbounded"/> </xs:all></xs:restriction>
![Page 15: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/15.jpg)
W3C SML F2F2007-08-29 15
Weakened Wildcard<xs:complexType> <xs:sequence> <xs:element name="child" minOccurs="0"/> <xs:any maxOccurs="unbounded"/> </xs:sequence></xs:complexType>
Violates “Unique Particle Attribution” (UPA) in schema 1.0
Becomes valid in schema 1.1 Elements take precedence over wildcards Element Declaration -> Wildcard -> Open
Content
![Page 16: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/16.jpg)
W3C SML F2F2007-08-29 16
Negative Wildcard
<xs:sequence> <xs:any notNamespace="##targetNamespace"/> <xs:any namespace="MyNS" notQName="my:e1 my:e2"/> <xs:any notQName="##defined"/></xs:sequence>
Any elements/attributes thatAre not in the listed namespacesDo not match the listed QNamesAre not defined in this schema
![Page 17: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/17.jpg)
W3C SML F2F2007-08-29 17
Conditional Inclusion<xsd:element name="e" vc:minVersion="3.2"> <!--* declaration suitable for 3.2 * and later processors *--></xsd:element><xsd:element name="e" vc:minVersion="1.1" vc:maxVersion="3.1"> <!--* declaration suitable for processors * supporting versions 1.1 through 3.1 *--></xsd:element>
A mechanism to version schema documents An element is not “included” if its
min/maxVersion attributes don’t match the schema language version of the processor
![Page 18: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/18.jpg)
W3C SML F2F2007-08-29 18
Complex Type Restriction
Base #1:(a, (b, c))Restriction #1:((a, b), c)
Base #2:(a | b | c)Derived #2:(b | c | a)
Extensional restriction (as opposed to schema 1.0’s intentional restriction) for content models and attributes
Identity Constraints can be named and reused
<xs:complexType name="base"> ... <xs:element name="e"> ... <xs:key name="myKey"> ...
<xs:complexType name="restriction"> ... <xs:element name="e"> ... <xs:key ref="myKey"> ...
![Page 19: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/19.jpg)
W3C SML F2F2007-08-29 19
Complex Type Restriction (Cont’)
<xs:schema targetNamespace="base"> ... <xs:complexType name="base"> ... <xs:element name="e" form="qualified"> ...
<xs:schema targetNamespace="restriction"> ... <xs:complexType name="restriction"> <xs:complexContent><xs:restriction base="base:base"> ...
“targetNamespace” on local declarations
<xs:element name="e" targetNamespace="base"> ...
![Page 20: 1 2007-08-29W3C SML F2F XML Schema 1.1 Sandy Gao, IBM](https://reader036.vdocuments.us/reader036/viewer/2022082512/5514f27d55034693478b5f3f/html5/thumbnails/20.jpg)
W3C SML F2F2007-08-29 20
References
Schema 1.1 Last Call working drafts: Structures: http://www.w3.org/TR/xmlschema11-1/ Datatypes: http://www.w3.org/TR/xmlschema11-2/ Drafts that show differences from schema 1.0 are also
available.
Guide to versioning using schema 1.1 features:
http://www.w3.org/TR/2007/WD-xmlschema-guide2versioning-20070720