-
Bug
-
Resolution: Fixed
-
P3
-
7
-
1.4
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2206348 | 7 | Joe Wang | P3 | Closed | Fixed | b134 |
XML Schema API exposes whitespace facet for xs:anySimpleType and xs:anyAtomicType, but those types have no facets. In our case SAX,DOM API collapse whitespace facet for xs:anySimpleType
Attached schema and xml document do not leads to a failure if either SAXParser or DOM API is used:
---------------- SAXParser ---------
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
spf.setSchema(schema);
SAXParser parser = spf.newSAXParser();
parser.parse(xmlDoc, validationHandler);
----------------- DocumentBuilder ---
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(true);
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", W3C_XML_SCHEMA_NS_URI);
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdFiles);
DocumentBuilder db = dbf.newDocumentBuilder();
db.setErrorHandler(errorCollector);
db.parse(xmlDoc);
-----end of code snippet-------------
If validation API is used an application fails as expected:
-------------------------------------
Validator validator = schema.newValidator();
validator.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", W3C_XML_SCHEMA_NS_URI);
validator.setErrorHandler(errorCollector);
validator.validate(xmlSource);
-----end of code snippet-------------
with exception:
SAX error: file:/analysis/test93160.xml(9,12): cvc-elt.5.2.2.2.2: The value '
test
information
' of element 'fooTest' does not match the {value constraint} value 'test information'.
-----end of exception-------------
See the corresponding Apache issue: https://issues.apache.org/jira/browse/XERCESJ-1459
Attached schema and xml document do not leads to a failure if either SAXParser or DOM API is used:
---------------- SAXParser ---------
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
spf.setSchema(schema);
SAXParser parser = spf.newSAXParser();
parser.parse(xmlDoc, validationHandler);
----------------- DocumentBuilder ---
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(true);
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", W3C_XML_SCHEMA_NS_URI);
dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdFiles);
DocumentBuilder db = dbf.newDocumentBuilder();
db.setErrorHandler(errorCollector);
db.parse(xmlDoc);
-----end of code snippet-------------
If validation API is used an application fails as expected:
-------------------------------------
Validator validator = schema.newValidator();
validator.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", W3C_XML_SCHEMA_NS_URI);
validator.setErrorHandler(errorCollector);
validator.validate(xmlSource);
-----end of code snippet-------------
with exception:
SAX error: file:/analysis/test93160.xml(9,12): cvc-elt.5.2.2.2.2: The value '
test
information
' of element 'fooTest' does not match the {value constraint} value 'test information'.
-----end of exception-------------
See the corresponding Apache issue: https://issues.apache.org/jira/browse/XERCESJ-1459
- backported by
-
JDK-2206348 XML Schema API exposes whitespace facet for xs:anySimpleType and xs:anyAtomicType
- Closed