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

ISSUE-67: using xsi:type to assert Type Substitution

From: Databinding Issue Tracker <dean+cgi@w3.org>
Date: Wed, 26 Jul 2006 23:43:21 +0000 (UTC)
To: public-xsd-databinding@w3.org
Message-Id: <20060726234321.362E8DAE79@w3c4-bis.w3.org>


ISSUE-67: using xsi:type to assert Type Substitution

http://www.w3.org/2005/06/tracker/databinding/issues/67

Raised by: Paul Downey
On product: Basic

Pattern from Faisel Waris which employs xsi:type
to perform type substitution.

"""
<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>
"""

http://lists.w3.org/Archives/Public/public-xsd-databinding/2006Jul/0014.html
Received on Wednesday, 26 July 2006 23:43:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 18 December 2010 18:20:37 GMT