anyType question 2003-02-05 - By Jesus M. Salvo Jr.
Given the following snippets from a schema definition ( look in particular on the element name "Details" .. ):
<xs:complexType name="responseStatusType"> <xs:annotation> <xs:documentation>Status information conveyed in responses</xs:documentation> </xs:annotation> <xs:all> <xs:element name="StatusCode"> <xs:simpleType> <xs:restriction base="tns:statusCodeType"/> </xs:simpleType> </xs:element> <xs:element name="StatusText" type="tns:statusTextType"/> <xs:element name="Details" type="tns:anyDataType" minOccurs="0"/> </xs:all> </xs:complexType>
... and this ...:
<xs:complexType name="anyDataType"> <xs:annotation> <xs:documentation>Any element and attribute </xs:documentation> </xs:annotation> <xs:complexContent> <xs:restriction base="xs:anyType"> <xs:sequence> <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType>
... and given the following snipped from the XML document:
<Status> <StatusCode>4001</StatusCode> <StatusText>Improper identification</StatusText> <Details>Not a valid VASPID</Details> </Status>
JAXP + Xerces 2.2.1 with schema validation reports this error:
org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element 'Details' must have no character [children], because the types content type is element-only. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError (Unknown Source
It's complaining about the Details element ... but I thought that <xs:restriction base="xs:anyType"> means that you can have a string in there, based on this tree: http://www.w3.org/TR/xmlschema-2/#built-in-datatypes ... where string a is an anySimpleType which in turn is an anyType, which is the base restriction of the completxType anyDataType?
Am I wrong?
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|