Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6974551

XML Schema API exposes whitespace facet for xs:anySimpleType and xs:anyAtomicType

XMLWordPrintable

    • 1.4
    • generic
    • generic
    • Verified

        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

              joehw Joe Wang
              lkuskov Leonid Kuskov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: