I have just started using Castor XML with the Source Generator. I have an existing XML Schema (.xsd) file, and I generated the source for it using the default options of the Source Generator. I want to perform strict validation of an XML file coming from a client against the existing schema, so I am executing the following code:


   Unmarshaller unmarshaller = new Unmarshaller(Order.class);
   try {
     Order order = (Order)unmarshaller.unmarshal(reader);
   }
   catch ( Exception e )
   {
     System.out.println( e.getMessage() );
   }

The root element of the schema is <Order>. I expect that any validation error will throw an exception. This code works fine for identifying mis-spelled element names, or enumerations with invalid content, but it does not identify if an element is in the wrong place in the XML file. For example, the schema specfies that the correct order of elements is (in part):

<Order>
   <Order_No>text</Order_No>
   <Product_Type>enumeration</Product_Type>
   <Special_Instructions>text</Special_Instructions>
</Order>

But Castor will allow the following XML without throwing an exception:

<Order>
   <Product_Type>enumeration</Product_Type>
   <Order_No>text</Order_No>
   <Special_Instructions>text</Special_Instructions>
</Order>

According to "strict" XML Schema validation rules, elements must appear in the correct order as specified by the schema. Is there any way to have Castor enforce this?

Thank you,
Jeremy

_________________________________________________________________
Express yourself with the new version of MSN Messenger! Download today - it's FREE! http://messenger.msn.com/go/onm00200471ave/direct/01/




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

Reply via email to