W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > July to September 2002

Typed "href" and traversal across "href"

From: Ricky Ho <riho@cisco.com>
Date: Fri, 06 Sep 2002 12:40:35 -0700
Message-Id: <4.3.2.7.2.20020906120436.0273eb50@franklin.cisco.com>
To: www-xml-schema-comments@w3.org
Most of the current XML processing (such as XPATH processing, schema 
validation), cannot traverse across an "href".  Like the following, I won't 
get the string if I use the XPATH expression "/Root/A/AA/BB".

<Root>
     <A>
         <AA href="0001" />
     </A>
     <B id="0001">
         <BB>I am here</BB>
     </B>
</Root>

The XML schema of this document will be ...

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema>
         <xsd:element name="ROOT">
                 <xsd:complexType>
                         <xsd:sequence>
                                 <xsd:element name="A" type="A-Type"/>
                                 <xsd:element name="B" type="B-Type"/>
                         </xsd:sequence>
                 </xsd:complexType>
         </xsd:element>
         <xsd:complexType name="A-Type">
                 <xsd:sequence>
                         <xsd:element name="AA">
                                 <xsd:complexType>
                                         <xsd:attribute name="href" 
type="xsd:IDREF"/>
                                 </xsd:complexType>
                         </xsd:element>
                 </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="B-Type">
                 <xsd:sequence>
                         <xsd:element name="BB" type="xsd:string"/>
                 </xsd:sequence>
                 <xsd:attribute name="id" type="xsd:ID" use="required"/>
         </xsd:complexType>
</xsd:schema>


The major reason why the XML processing cannot traverse across an href is 
because the type information about the href is missing.  I guess if we 
provide that type information to the href, then traverse across a reference 
will be possible.  Think about this new schema (I have highlighted the 
difference from the previous one)

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema>
         <xsd:element name="ROOT">
                 <xsd:complexType>
                         <xsd:sequence>
                                 <xsd:element name="A" type="A-Type"/>
                                 <xsd:element name="B" type="B-Type"/>
                         </xsd:sequence>
                 </xsd:complexType>
         </xsd:element>
         <xsd:complexType name="A-Type">
                 <xsd:sequence>
<!-- 
************************************************************************************ 
-->
                         <xsd:reference name="AA" type="B-Type"/>
<!-- 
************************************************************************************ 
-->
                 </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="B-Type">
                 <xsd:sequence>
                         <xsd:element name="BB" type="xsd:string"/>
                 </xsd:sequence>
                 <xsd:attribute name="id" type="xsd:ID" use="required"/>
         </xsd:complexType>
</xsd:schema>


To illustrate why I need this.  Lets look at the web service SOAP encoding.

In WSDL, every complex type is described in XML-Schema.  So if you have a 
"Customer" who has an "Address", the XML schema will look as the following ...

<complexType name="Customer">
         <sequence>
                 <element name="name" type="xsd:string"/>
                 <element name="addr" type="tns:Address"/>
         </sequence>
</complexType>

<complexType name="Address">
         <sequence>
                 <element name="street" type="xsd:string"/>
                 <element name="city" type="xsd:string"/>
         </sequence>
</complexType>


However, if you pass a "Customer" object as a parameter in a SOAP request, 
the "soap-encoding" will encode the parameter into ...

<multiRef id="id0" xsi:type="Customer">
         <name>....</name>
         <addr href="#id1"/>
</multiRef>
<multiRef id="id1" xsi:type="Address">
         <street>....</street>
         <city>....</city>
</multiRef>


Therefore, the XML after encoding is using a "href" but the WSDL is saying 
that the Address should be embedded into the Customer.  So it seems SOAP 
encoding and WSDL is inconsistent.

It seems to me there is a fundamental mismatch between XML schema and SOAP 
encoding.  XML schema does have a very limited concept of reference 
(id/idref is typeless), complex object will mainly be embedded into another 
complex object.  However, SOAP encoding almost use reference 
exclusively.  Complex object will has a "href" into another complex object.

It seems to me that the problem can be solved if we ....
1) Add a "typed reference" concept in XML-schema.
2) Schema validation can traverse across the "href"

Best regards,
Ricky
Received on Friday, 6 September 2002 15:41:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:13:01 GMT