[
https://issues.apache.org/jira/browse/XERCESJ-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13412599#comment-13412599
]
Radu Coravu commented on XERCESJ-1569:
--------------------------------------
Hi,
I am using the Xerces schema 1.1 beta release.
The XML Schema has 1.1 constructs in it (it is an XML Schema 1.1).
As I said, the NPE happens when you parse it as if it was an XML Schema 1.0
If you parse that XML Schema as if it were an XML Schema of version 1.0 the
following error should be obtained:
s4s-elt-invalid: Element 'assertion' is not a valid element in a schema
document.
Right now the "Xerces schema 1.1 beta release" throws the NPE instead.
If you look at the code, the class XSDAbstractTraverser contains at some point
an if:
else if (facet.equals(SchemaSymbols.ELT_ASSERTION)) {
Then it calls:
attrs = fAttrChecker.checkAttributes(content, false, schemaDoc);
which returns NULL because the schema is parsed as if it were an 1.0 XML Schema.
But the code does not guard this possible case when the "attrs" is NULL.
> NPE when validating XML with XML Schema 1.1 (but validation is made in 1.0
> compatibility mode)
> ----------------------------------------------------------------------------------------------
>
> Key: XERCESJ-1569
> URL: https://issues.apache.org/jira/browse/XERCESJ-1569
> Project: Xerces2-J
> Issue Type: Bug
> Components: XML Schema 1.1 Structures
> Reporter: Radu Coravu
> Fix For: 2.11.0
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> I validate an XML:
> <root xmlns="http://xstest-tns/schema11_D4_3_15"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://xstest-tns/schema11_D4_3_15 npeXerces.xsd"/>
> with an XML Schema 1.1:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:tns="http://xstest-tns/schema11_D4_3_15"
> targetNamespace="http://xstest-tns/schema11_D4_3_15"
> elementFormDefault="qualified">
> <xs:element name="root">
> <xs:simpleType>
> <xs:restriction base="xs:string">
> <xs:assertion test="/root = 'present'"
> xpathDefaultNamespace="##targetNamespace" />
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> </xs:schema>
> Although the schema is 1.1, it is parsed in 1.0-mode.
> The NPE is like:
> java.lang.NullPointerException
> at
> org.apache.xerces.impl.xs.traversers.XSDAbstractTraverser.traverseFacets(XSDAbstractTraverser.java:468)
> at
> org.apache.xerces.impl.xs.traversers.XSDSimpleTypeTraverser.getSimpleType(Unknown
> Source)
> at
> org.apache.xerces.impl.xs.traversers.XSDSimpleTypeTraverser.traverseLocal(Unknown
> Source)
> at
> org.apache.xerces.impl.xs.traversers.XSDElementTraverserXerces.traverseNamedElement(XSDElementTraverserXerces.java:397)
> at
> org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseNamedElement(XSDElementTraverser.java:69)
> at
> org.apache.xerces.impl.xs.traversers.XSDElementTraverserXerces.traverseGlobal(XSDElementTraverserXerces.java:240)
> at
> org.apache.xerces.impl.xs.traversers.XSDHandlerXerces.traverseSchemas(XSDHandlerXerces.java:1557)
> at
> org.apache.xerces.impl.xs.traversers.XSDHandlerXerces.parseSchema(XSDHandlerXerces.java:694)
> at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
> at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
> at
> org.apache.xerces.parsers.XMLGrammarPreparserXerces.preparseGrammar(XMLGrammarPreparserXerces.java:210)
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]