Xerces2-J
  1. Xerces2-J
  2. XERCESJ-1524

Xerces should be adding prefix for defaulted/fixed attibutes in a namespace from XMLSchema validation.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.11.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      All

      Description

      This issue has appeared in various forms before. See https://issues.apache.org/jira/browse/XERCESJ-455 and https://issues.apache.org/jira/browse/XERCESJ-1474

      At its simplest, the issue is that, when you have an XMLSchema that declares an attribute to be form="qualified" and either fixed="some-val" or default="some-val" then the Xerces SAX (and DOM) parsers do not include namespace prefix data to the DOM hierarchy, or ContentHandler.startElement() call. For example, with the XSD (./MySchema.xsd):

      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema xmlns="myns"
      xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="myns"
      elementFormDefault="qualified">
      <xs:element name="doc">
      <xs:complexType>
      <xs:attribute name="att" default="defval" form="qualified"/>
      </xs:complexType>
      </xs:element>
      </xs:schema>

      A simple document is:
      <doc xmlns="myns"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="myns ./MySchema.xsd">

      We define the root element 'doc' should have an attribute 'att' with the default value 'defval'. This 'att' attribute should be in the namespace 'myns'.

      When startElement() is called on the ContentHandler, the current 2.11 Xerces parser sets the Attribute details for the 'att' attribute as:
      LocalName -> 'att'
      QName -> 'att'
      URI -> 'myns'
      Value -> 'defval'

      The issue is that the QName for this attribute has no namespace prefix.

      This issue has been previously discussed, but, the previous discussions are now out of date, and the XMLSchema specification has now included this particular situation. The current xerces parser is no longer conforming with XSD 1.1.

      The particular references in XSD 1.1 are:
      http://www.w3.org/TR/xmlschema11-1/#sec-ctdsic <-- This section indicates that 'namespace fixup' should be performed, and it indicates that [prefix] is part of the infoset. Further, namespacefixup is defined here:
      http://www.w3.org/TR/xmlschema11-1/#term-ns-fixup

      Together, these indicate that the validating parser should use an existing 'prefixed' namespace declaration's prefix for the defautled/fixed attribute, or, in the absense of a prefixed namespace, it should create a 'impelentation dependant' prefix for the namespace.

        Issue Links

          Activity

          Hide
          Rolf added a comment -

          This is the same issue as 455, but with XSD1.1 the context is different

          Show
          Rolf added a comment - This is the same issue as 455, but with XSD1.1 the context is different

            People

            • Assignee:
              Unassigned
              Reporter:
              Rolf
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Development