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/18 12:26:15 UTC

Still problem with unexpected PSVI content

Hello everybody!

I still have a problem getting the 'correct' 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:sequence>
 </xsd:complexType>

 <xsd:complexType name="USAddress">
   ...
 </xsd:complexType>
</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:


parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://apache.org/xml/features/validation/schema", true);
parser.setProperty("http://apache.org/xml/properties/dom/document-class-name",
                   "org.apache.xerces.dom.PSVIDocumentImpl");
...
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}" (cf. W3C Schema Part I, section 3.3.5).

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

Sorry for posting this question again, but I really would appreciate
any help on this since I need the PSVI functionality to proceed on my
project.


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


Re[2]: Still problem with unexpected PSVI content

Posted by Matthias Ferdinand <ma...@matthiasferdinand.de>.
Hi Elena!

You wrote:

> There was a bug in our implementation and I've just committed the
> fix. Please, test it and let us know if there are any problems.

I could test the fixed version only by the previously posted example
program and within my own project. It works great and now behaves as
expected.

This helps me a lot, thank you very much!

 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


Re: Still problem with unexpected PSVI content

Posted by Elena Litani <el...@ca.ibm.com>.
Matthias, 

Thank you for providing the files. 
There was a bug in our implementation and I've just committed the fix.
You can either check out the files from CVS or download tomorrow the
newly build Xerces jars:
http://gump.covalent.net/jars/latest/xml-xerces2/.

Please, test it and let us know if there are any problems. 

Thank you,
-- 
Elena Litani / IBM Toronto

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


Re[2]: Still problem with unexpected PSVI content

Posted by Matthias Ferdinand <ma...@matthiasferdinand.de>.
Hi Elena!

You wrote:
> I am not able to reproduce your problem. Can you please send sample
> Java program and data files (xml, xsd).

In the attachment, there is the Java program, the XML file and the
corresponding XML schema file.

Execute the program with the parameter "po.xml". It traverses the DOM
tree and prints the elements with their types it retrieves from the
PSVI via DOM. I am using Xerces 2.2.0 and J2SE 1.3.0_05 under Windows
98.

------------------------------------------------------------------
Here are the first lines of my output which include the problem:

Element: purchaseOrder
  type = PurchaseOrderType 

Element: shipTo
  type = PurchaseOrderType 

Element: name
  type = USAddress 

Element: street
  type = USAddress 

...
------------------------------------------------------------------

Thanks,
 Matthias                            

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

Re: Still problem with unexpected PSVI content

Posted by Elena Litani <el...@ca.ibm.com>.
Hi Matthias, 

I am not able to reproduce your problem. Can you please send sample Java
program and data files (xml, xsd).


Thanks,
-- 
Elena Litani / IBM Toronto

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