xml schema patterns for databinding
DESCRIPTION
http://2006.xmlconference.org/programme/presentations/43.htmlTRANSCRIPT
W3C XML Schema
Patterns for Databinding
Paul Downey, BT
Chair, XML Schema Patterns for Databinding Working Group
XML 2006, December 5th 2006
XML Schema
?
Validation
Schema
Processor
XML
Instance
XML
Schema
Post
Schema
Validation
Infoset
Description
SenderXML
Instance
XML
Schema
Receiver
Types
XML
xs:string
xs:int
foo:PurchaseOrder
tns:Address
Databinding
?
Databinding ≡ Abstraction
Model XML
Model
• Java
• Database
• Annotated DOM
• JSON
• PHP serialisation
• XML
• Whatever
Why Describe
?
Duck Typing XML
?
Force Array
<opt> <name>value</name></opt>
<opt> <name>value1</name> <name>value2</name></opt>
{ name => ‘value’}
{ name => [ ‘value1’, ‘value2’ ]}
Static Typing
{ int accountNo; long ammount; string name;}
What’s wrong with Databinding
?
“State of the Art”
• reject valid XML Schema documents
• reject valid XML instance documents
• content of valid XML instance documents often unavailable in model
Impedance Mismatch
><OO
Circles, Triangles, Rectangles
XML 2003
http://www.idealliance.org/papers/dx_xml03/papers/06-02-01/06-02-01.html
I ! Mixed Content
text <O/> text
<O> text </O>
Don’t Databind?
• XSLT
• DOM
• LINQ
• E4X
• XJ
• etc
Abstraction Scale
XML
Text
InfosetObjects
DOMTypedDOM
Bits
Templating
They Don’t Like XML!
Abstraction
?
XML Schema is Big ..
• Lot’s of ways to describe the concrete
• Lot’s of ways to represent the abstract
Partial Implementations
“Our tool doesn’t support xs:foo.Change your schema.”
* vendor
“The Barf Dance”
So begins ..
it’s not so much that schema sucks ...
or that databinding tools suck ...
it’s that all databinding tools suck
differently
W3C Working Group
?
WS-I
• Basic Profile
• XML Schema Work Plan Working Group
W3C WorkshopXML Schema 1.0 User Experiences
Discussion
Don’t Just Change Schema!
… 300,000+ developers use XSD … There is tremendous value in XML Schema. Don't just change it…
Soumitra Sengupta,Microsoft
Discussion Topics
• versioning
• profiles and patterns of use
• code generation (v) validation
• Unique Particle Attribution (UPA)
• XML Schema 1.1
• test suite
W3C XML Schema Patterns for Databinding
Working Group
!
Deliverables
• W3C Recommendation for Basic Patterns
• W3C Recommendation for Advanced Patterns
• Test Suite
• Mechanism to Detect patterns
Out of Scope:
• Profile of Schema
• Language Specific Detail
Patterns
!
AnyURIElement
.//xs:element/@type[resolve-QName(.,..) = xs:QName('xs:anyURI')]
http://www.w3.org/2002/ws/databinding/patterns/6/09/AnyURIElement
<xs:element name="anyURIElement"
type="xs:anyURI" />
ElementMinOccurs0MaxOccursUnbounded
.//xs:element[@minOccurs = '0' and @maxOccurs = 'unbounded']/ (@minOccurs, @maxOccurs)
http://www.w3.org/2002/ws/databinding/patterns/6/09/ElementMinOccurs0MaxOccursUnbounded
SequenceSingleRepeatedElement
.//xs:sequence[count(xs:element) = 1]/ xs:element[@maxOccurs = 'unbounded']/ (., @maxOccurs)
http://www.w3.org/2002/ws/databinding/patterns/6/09/SequenceSingleRepeatedElement
Overlapping!
StringEnumerationType
.//xs:simpleType/xs:restriction[ @base/resolve-QName(.,..) = xs:QName('xs:string') and xs:enumeration]/ (., @base, xs:enumeration/(., @value))
http://www.w3.org/2002/ws/databinding/patterns/6/09/StringEnumerationType
<xs:simpleType name="Beatle">
<xs:restriction base="xs:string"> <xs:enumeration value="John" /> <xs:enumeration value="Paul" /> <xs:enumeration value="George" /> <xs:enumeration value="Ringo" /> </xs:restriction>
SOAP Encoded Array
./xs:complexType[@name]/xs:complexContent/ xs:restriction[ @base/resolve-QName(.,..) = xs:QName ('soap11enc:Array')]/ xs:attribute[(@ref/resolve-QName(.,..) = xs:QName('soap11enc:arrayType')) and @wsdl11:arrayType]/(../.., ../(., @base), ., @ref, @wsdl11:arrayType)
http://www.w3.org/2002/ws/databinding/patterns/6/09/SOAPEncodedArray
Palatability
?
Value Judgement
• xs:any becomes XMLElement
• xs:anyURI becomes String
• xs:decimal becomes String
Examples
!
ElementMinOccurs0MaxOccursUnbounded
<xs:element name="durationList" type="ex:DurationList" />
<xs:complexType name="DurationList">
<xs:sequence>
<xs:element name="durationValue" type="xs:short"
! ! ! ! ! minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
http://www.w3.org/2002/ws/databinding/examples/6/09/ElementMinOccurs0MaxOccursUnbounded
Example Descriptions
• ComplexTypeSequenceExtension.xsd
• echoComplexTypeSequenceExtension.xsd
• echoComplexTypeSequenceExtension.wsdl
• echoComplexTypeSequenceExtension-wsdl20.wsdl
Example Instances
• ElementMinOccurs0MaxOccursUnbounded-01.xml
• echoElementMinOccurs0MaxOccursUnbounded-01.xml
• echoElementMinOccurs0MaxOccursUnbounded-01-soap11.xml
• echoElementMinOccurs0MaxOccursUnbounded-01-soap12.xml
Test Suite
Toolkit
Output
Example
Description
Instance
Model
Test Reports
Patterns Detector
!
Patterns Detector
DetectorPatterns
(URIs)XML
Schema
Buckets
!
Basic Patterns
• known to work with “state of the art” implementations
• they’re, um, very Basic
Publishers of Schemas Take Note!
TargetNamespace
.[@targetNamespace]/ (., @targetNamespace)
http://www.w3.org/2002/ws/databinding/patterns/6/09/TargetNamespace
An [XML Schema 1.0] document conforming to this
specification MUST define a targetNamespace whose
value is an absolute URI. †
“State of the Art”
?
SLIPPERY SLOPE
Value Judgement
“Bring out your implementations”
• new tools arrive
• old tools become defunct
• some tools are very lame
• we can’t test every tool
Advanced Patterns
• exhibited by real schemata
• they’re, um, not very interoperable
Developers of Implementations Take Note!
Not Advanced
?
SLIPPERY SLOPE
Value Judgement
“Bring out your schemata”
• XML Schema is big
• Coverage or Possible to Databind?
• always another Schema
Patterns in the Wild
Build Your Own Bucket
• List Patterns your schemas use
• List Patterns your toolkit supports
• Analyse schemas “in the wild”
Other Topics
?
DocumentConformance
ImplementationConformance
WS-I Basic Profile
• Detector works on WSDL 1.1
• Composable with Basic Profile 1.1
Annotations
• Tools Generate them
• Useful for “round tripping”
• No-one is submitting them
Versioning
• Concrete patterns exist
• They’re all Advanced
XML Schema 1.1 is the answer?
Progress
?
Schedule
Participants
• BT
• Health Level 7
• National Association of Convenience Stores (NACS)
• Origo Services Limited
• SAP AG
• WSO2
• Invited Expert: Priscilla Walmsley
... and that’s It!
We Need Your Help!
www.w3.org/2002/ws/databinding
How You Can Help
• Participate in the Working Group
• Encourage your vendor of choice to participate
• Contribute to the test suite
• Contribute your Schemata
www.w3.org/2002/ws/databinding
Thank you! Any Questions
?www.w3.org/2002/ws/databinding