You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Paul French <pa...@kirona.com> on 2008/01/23 12:57:08 UTC
XMLObject Validation
I don't see the desired behaviour when validating an XMLObject using
validate(XMLOptions) method.
If the XMLObject contains 3 mandatory fields and the 2nd one is missing the
contents of the 3rd is not validated. Is this correct?
Here is a snippet of the relevant part of the schema. If the SICCode is not
given inside a Classification element then the contents of LACORSCode is
never validated. If I add in a SICCode then the LACORSCode is validated?
<xs:element name="Classification">
<xs:complexType>
<xs:sequence>
<xs:element name="BCLCode" type="xs:string">
</xs:element>
<xs:element name="SICCode">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{5}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="LACORSCode">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{5}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Another thing which I have noticed is if I have a mandatory element in the
schema and it is not present in the XML document then when I validate it I
get loads of messages saying
Expected element "the mandatory element" instead of "element A"
Expected element "the mandatory element" instead of "element B"
Expected element "the mandatory element" instead of "element C"
Expected element "the mandatory element" before the end of the content in
element......
Surely one message is sufficient that the mandatory element is missing? Is
there anyway of eliminating the redundant messages?
Thanks
Paul
xml node name
Posted by Pierre De Leusse <pi...@newcastle.ac.uk>.
Hi everybody,
In my schema I have a complexType (myComplexType) that extends another
(myBasicType), this last one being abstract. myBasicType is referenced
as element in another complexType (myContainerType). This translates by
inheritance amongst the classes in Java. But when I build a document
from scratch using XmlBeans' object model, in the xml output of
myContainerType, the node name of this specific element is
systematically myBasicType with an attribute xsi:type="myComplexType".
I have tried :
myBasicTypeInstance.changeType(myComplexTypeInstance.schemaType());
myBasicTypeInstance = myComplexTypeInstance;
and
myContainerTypeInstance.setmyBasicType(myComplexTypeInstance);
But in both cases it doesn't work.
Could somebody please let me know how to sort this?
Thanks,
Pierre