When I try to validate my xml document with schema, it checks if the input xml has the elements in the order/sequence they are defined in the schema.
But problem is, my xml document can contain these elements in any sequence. Example if elements x, y,z are defined in the schema in the sequence below. <x> <y/> <z/> </x>
then my xml document may not necessarily get the elements in the same sequence. All I want to check is if my xml has those elements in them. I am not much considered about the sequence.
Is there is any setting while validating xml document which ignores the sequence?
Hmm.....usually we use schemas are used to define the structure of your XML and validate the structure. So if you have random elements in your XML, then its debatable whether you need a schema or otherwise. That said, you can as well write a schema that does not enforce......welll.....nooo.
The more I think about this the more I am inclined to say I wouldn't bother with a schema. If I were to do this, I would get rid of the schema (if that is possible) and move that business logic into the JDOM code. Logically validate if the elements are present or otherwise.
I am interested in any other ways of doing this. Other thoughts please.
- m
Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Thanks a lot for both your replys. You are correct Frank, The schema is defined with ordered grouping that is xs:sequence.
I thought of using xs:all but the schema is owned by some other group and I cannot change it. Hence, I was thinking if there is any way that this feature can be switched programatically.
The XML document that is fed into my application gets processed by an XSLT. Hence as a work around, we have updated XSLT to ensure the sequence of the elements.
I wouldn't call that a "workaround". The schema says the elements are supposed to be in a certain sequence. So changing your XSLT to produce the elements in that sequence would be called a "bug fix".