[
https://issues.apache.org/jira/browse/XERCESJ-1351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12657142#action_12657142
]
Michael Glavassevich commented on XERCESJ-1351:
-----------------------------------------------
Mukul, I get different behaviour when I try your test. The only error I'm
getting is:
org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0'
is not facet-valid with respect to minLength '1' for type 'shortString'.
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
at
org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:132)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:394)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:282)
at
org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:466)
at
org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3473)
at
org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidComplexType(XMLSchemaValidator.java:3387)
at
org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3356)
at
org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3258)
at
org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2349)
at
org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:888)
I would have expected that an error be reported for the schema, because your
example isn't actually valid. Each type alternative must be substitutible [1]
for the declared type, however ShortAddress isn't derived from LongAddress.
When I replace the declared type with xs:anyType, I get yet another error:
java.lang.NullPointerException
at
org.apache.xerces.impl.xpath.XPath20$NodeTest.evaluateNodeTest(XPath20.java:1356)
at org.apache.xerces.impl.xpath.XPath20.visitNode(XPath20.java:93)
at org.apache.xerces.impl.xpath.XPath20.traverseTree(XPath20.java:72)
at org.apache.xerces.impl.xs.alternative.Test.evaluateTest(Test.java:56)
at
org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2261)
at
org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:782)
so it seems there are a bunch of problems which need to be addressed/fixed.
[1] http://www.w3.org/TR/xmlschema11-1/#d0e13952
> Type alternatives implementation seems to be broken
> ---------------------------------------------------
>
> Key: XERCESJ-1351
> URL: https://issues.apache.org/jira/browse/XERCESJ-1351
> Project: Xerces2-J
> Issue Type: Bug
> Components: XML Schema 1.1 Structures
> Environment: Windows XP, JRE 1.5.0_15
> Reporter: Mukul Gandhi
>
> I am running the latest Xerces-J development code from SVN repository. I
> tried the following sample XML document, and the XML Schema document.
> XML document:
> <PERSON xsi:noNamespaceSchemaLocation="person.xsd"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <FNAME>Mukul</FNAME>
> <LNAME>Gandhi</LNAME>
> <DOB>1999-06-02</DOB>
> <ADDRESS type="short">my address</ADDRESS>
> </PERSON>
> Schema:
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:element name="PERSON" type="PersonType" />
> <xs:complexType name="PersonType">
> <xs:sequence>
> <xs:element name="FNAME" type="xs:string" />
> <xs:element name="LNAME" type="xs:string" />
> <xs:element name="DOB" type="xs:date" />
> <xs:element name="ADDRESS" type="LongAddress">
> <xs:alternative test="@type='short'" type="ShortAddress"/>
> <xs:alternative test="@type='long'" type="LongAddress"/>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="ShortAddress">
> <xs:simpleContent>
> <xs:extension base="shortString">
> <xs:attribute name="type" type="xs:string"/>
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
> <xs:simpleType name="shortString">
> <xs:restriction base="xs:string">
> <xs:minLength value="1" />
> <xs:maxLength value="50" />
> </xs:restriction>
> </xs:simpleType>
> <xs:complexType name="LongAddress">
> <xs:sequence>
> <xs:element name="street1" type="xs:string" />
> <xs:element name="street2" type="xs:string" minOccurs="0" />
> <xs:element name="city" type="xs:string" />
> <xs:element name="state" type="xs:string" />
> <xs:element name="pin" type="xs:string" />
> <xs:element name="country" type="xs:string" />
> </xs:sequence>
> <xs:attribute name="type" type="xs:string"/>
> </xs:complexType>
> </xs:schema>
> When I apply validation using the above examples, with Xerces, I get
> following errors:
> [Error] person.xsd:11:69: s4s-elt-must-match.1: The content of 'ADDRESS' must
> match (annotation?, (simpleType
> | complexType)?, alternative*, (unique | key | keyref)*)). A problem was
> found starting at: alternative.
> [Error] person.xml:5:45: cvc-complex-type.2.3: Element 'ADDRESS' cannot have
> character [children], because the
> type's content type is element-only.
> [Error] person.xml:5:45: cvc-complex-type.2.4.b: The content of element
> 'ADDRESS' is not complete. One of '{st
> reet1}' is expected.
> It seems to me, that type alternative support in Xerces is not working as
> expected.
> Some comments about the Java class, org.apache.xerces.impl.xpath.XPath20
> (which I think is used by type alternatives)
> The method,
> public boolean evaluateNodeTest(QName element, XMLAttributes attributes)
> doesn't use the parameter, "element" anywhere in the method body.
> Please correct me, on any of the points I have mentioned.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]