Tuesday, August 08, 2006

xsd:all tag

I am using xsd schema to validate xml files and using xsd:all tag to group elements. Based on w3 documents, the default minOccurs of an element in xsd:all should be zero. (meaning it can just not show up without explicitly set its minOccurs to zero). But I found this is not true for any xsd validators I tested (XML spy, xerces SAXParser). I have to set the minOccurs to zero for each element if I want it to be optional.
What makes thing worse is the misleading parsing error message when I am using xerces packages in java. I started testing adding minOccurs attributes to some elements to see if this will solve the problem. However the error message does not change, i.e. the element I just added 'minOccurs=0' still seems mandatory based on the error message. I guess this is a bug in the xerces package. Only utill I fixed all the elements, the error message is gone. Whereas in XML spy, it's much better. Whenever I added minOccurs for an element, I can see it is no longer required when I try to validate the xml. This is how I figured the default value of minOccurs for elements in xsd:all group is one.

No comments: