You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Matthias Ferdinand <ma...@matthiasferdinand.de> on 2002/10/16 18:48:21 UTC

Confusion about PSVI behaviour

Hello everybody!

I have a problem getting the appropriate type information about
elements in an XML document by accessing the PSVI via DOM. I have the
following XML schema (taken from the W3C primer):

--------------------------------------------------------------
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

 <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>

 <xsd:complexType name="PurchaseOrderType">
  <xsd:sequence>
   <xsd:element name="shipTo" type="USAddress"/>
 ...

 <xsd:complexType name="USAddress">
 ...

</xsd:schema> 
--------------------------------------------------------------

and this instance document:

<purchaseOrder
 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
 xsi:noNamespaceSchemaLocation='po.xsd'>
    <shipTo country="US">
        <name>Alice Smith</name><street>123 Maple Street</street>
        <city>Mill Valley</city>
        <state>CA</state>
        <zip>90952</zip>
    </shipTo>
...
</purchaseOrder>
--------------------------------------------------------------

I use DOM and this own code to get the type information:

...
Node node;
...
if (node.getNodeType() == Node.ELEMENT_NODE)
{
 XSTypeDefinition type = ((ElementPSVI) node).getTypeDefinition();
 System.out.print(type.getName());
}
...
--------------------------------------------------------------

PROBLEM:
Now, when processing the element "shipTo" in the instance
document, Xerces returns as its type "PurchaseOrderType". But instead,
from my point of view, it should return "USAddress" as this is the
element's schema "{type definition}".

What am I missing or doing wrong? How do I get the desired result
"USAddress"?


Regards,
 Matthias                          

--
Matthias Ferdinand
Distributed and Information Systems - VSIS
Computer Science, University of Hamburg
EMail: matthias@matthiasferdinand.de


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org