W3C home > Mailing lists > Public > public-xsd-databinding@w3.org > July 2006

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

From: <paul.downey@bt.com>
Date: Wed, 26 Jul 2006 18:07:48 +0100
Message-ID: <2A7793353757DB4392DF4DFBBC95225504BFEC3C@I2KM11-UKBR.domain1.systemhost.net>
To: <fwaris@ford.com>, <public-xsd-databinding@w3.org>

Hi Faisal,

I first read this as an instance of 

as i proposed the schema pattern for:


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


-----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" > 
        <element name="Number" type="string" /> 

<complexType name="Assembly" /> 
                <element name="Part" type="tns:Part" minOccurs="0" maxOccurs="unbounded" /> 

<element name="Assembly" type="tns:Assembly" /> 

This can be easily extended in an OO way as follows: 

<complexType name="Part2" > 
    <extension base="tns:Part"> 
        <element name="Description" type="string" /> 

At runtime we can use "Type Substitution" as follows: 

<Assembly xmlns="." xmlns:tns="." xmlns:xsi="."> 
  <Part xsi:Type="tns:Part2"> 
            <Description> extended part </Description> 

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.

Received on Wednesday, 26 July 2006 17:12:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:42:56 UTC