- From: Waris, Faisal \(F.\) <fwaris@ford.com>
- Date: Mon, 24 Jul 2006 10:00:41 -0400
- To: <public-xsd-databinding@w3.org>
- Message-ID: <7BBDEC341954734CB7C025D38AE57A6708BB50B4@na1ecm55.dearborn.ford.com>
Here is a schema usage pattern that will result in: A: Good mapping to Object-Oriented languages (Java, C#, etc.) B: Supports loosely coupled interfaces via extensible content models C: Largely side steps the issue of versioning by supporting easy extensibility The main idea is to stick to derivation by extension, local elements and use runtime type substitution. Consider the base schema: .... <complexType name="Part" > <sequence> <element name="Number" type="string" /> </sequence> </complexType> <complexType name="Assembly" /> <sequence> <element name="Part" type="tns:Part" minOccurs="0" maxOccurs="unbounded" /> </sequence> </complexType> <element name="Assembly" type="tns:Assembly" /> .... This can be easily extended in an OO way as follows: <complexType name="Part2" > <complexContent> <extension base="tns:Part"> <sequence> <element name="Description" type="string" /> </sequence> <extension> </complexContent> </complexType> At runtime we can use "Type Substitution" as follows: <Assembly xmlns="..." xmlns:tns="..." xmlns:xsi="..."> <Part> <Name>p1</Name> </Part> <Part xsi:Type="tns:Part2"> <Name>p2</Name> <Description> extended part </Description> </Part> </Assembly> Tooling behavior: I have noticed that this pattern is supported by .Net and WebSphere's web service databinding (the only ones that I have tested). Specifically, if a field is of type Part but actually contains an instance of Part2, the runtime serialization will include the xsi:Type tag. Similary upon deserialization, the xsi:Type tag's value would be used to actually instantiate an instance of Part2 subtype. I know that axis2's based databinding does not claim to support this pattern. I think axis2 alternate databinding mechanisms (such as XML Beans) should support this. Faisal
Received on Monday, 24 July 2006 14:23:55 UTC