RE: Type Substitution Schema Usage Pattern to Object-Oriented and Extensible Content Model

Hi Faisal,

I first read this as an instance of 
ISSUE-21:

http://www.w3.org/2002/ws/databinding/issues/21/
\
as i proposed the schema pattern for:

http://lists.w3.org/Archives/Public/public-xsd-databinding/2006May/0038

but will record the use of xsi:type for substitution as a
new issue. We'll build an example and test cases around this ..

Paul

-----Original Message-----
From: public-xsd-databinding-request@w3.org on behalf of Waris, Faisal (F.)
Sent: Mon 7/24/2006 3:00 PM
To: public-xsd-databinding@w3.org
Subject: Type Substitution Schema Usage Pattern to Object-Oriented and Extensible Content Model
 
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 Wednesday, 26 July 2006 17:12:08 UTC