Hi,

I instantiate an Unmarshaller passing the class that was generated for the
root element of my schema
and use it to read an XML document. I would expect that if the Unmarshaller
returns an instance of
the root element class the XML document was correct. However the actual root
tag can be anything - it
is always accepted (marshalling validation is set to true in
castor.properties).

This seems to be a bug / missing feature.

Bye,

Laslo


E.g. the following XML document is accepted when read with an Unmarshaller
(passing Root.class to it):

DOCUMENT

   <?xml version="1.0" encoding="UTF-8"?>
   <Foobar>
       <Element1>A</Element1>
       <Element2>B</Element2>
       <Element3>C</Element3>
   </Foobar>

SCHEMA

   <?xml version = "1.0" encoding = "UTF-8"?>
   <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; >
 
   <xsd:element name="Root">
   <xsd:complexType>
      <xsd:sequence>
         <xsd:element name="Element1" type="xsd:string" />
         <xsd:element name="Element2" type="xsd:string" />
         <xsd:element name="Element3" type="xsd:string" />
      </xsd:sequence>
   </xsd:complexType>
   </xsd:element>       

   </xsd:schema>


CODE SNIPPET

         org.exolab.castor.xml.Unmarshaller um = new
org.exolab.castor.xml.Unmarshaller(Root.class);
         InputStreamReader ir = new InputStreamReader( new FileInputStream(
"in1.xml"),"UTF-8");
         Root r = (Root)um.unmarshal(ir);
         ir.close();

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to