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

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

From: Waris, Faisal \(F.\) <fwaris@ford.com>
Date: Mon, 24 Jul 2006 10:00:41 -0400
Message-ID: <7BBDEC341954734CB7C025D38AE57A6708BB50B4@na1ecm55.dearborn.ford.com>
To: <public-xsd-databinding@w3.org>
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

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 Monday, 24 July 2006 14:23:55 UTC

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