Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1202

DTD validation on XIncluded documents when the schema language is set to XML Schema

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.8.1
    • 2.9.0
    • XInclude 1.0
    • None

    Description

      When a validation is performed with the schema language property set to XML Schema the DTDs should not be used for validation. This happens when validating a document but not on the included documents. Below you can find an example to reproduce the problem and a proposed patch.

      foos.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <foos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="foo.xsd"
      xmlns:xi="http://www.w3.org/2001/XInclude">
      <xi:include href="foo.xml"/>
      </foos>

      foo.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE foo [ ]>
      <foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="foo.xsd"/>

      foo.xsd
      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="foo"/>
      <xs:element name="foos">
      <xs:complexType>
      <xs:sequence>
      <xs:element ref="foo" maxOccurs="unbounded"/>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:schema>

      Proposed pacth
      At the end of the reset method in XIncludeHandler we should check if the schema language property is set to XML Schema and disable the validation and dynamic validation features for the XIncluded documents as we perform the validation only on the main document with the XInclude resolved. One possible implementation of the above is to add the following lines at the end of XIncludeHandler.reset()

      boolean schemaLanguage = false;
      try

      { schemaLanguage = "http://www.w3.org/2001/XMLSchema".equals(componentManager.getProperty( "http://java.sun.com/xml/jaxp/properties/schemaLanguage" )); }

      catch (XMLConfigurationException e) {}
      if (schemaLanguage)

      { fSettings.setFeature(DYNAMIC_VALIDATION, false); fSettings.setFeature(VALIDATION, false); }

      Thanks,
      George

      Attachments

        Activity

          People

            mrglavas@ca.ibm.com Michael Glavassevich
            george@sync.ro George Cristian Bina
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: