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

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


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


      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"
      <xs:element name="doc">
      <xs:attribute name="att" default="defval" form="qualified"/>

      A simple document is:
      <doc xmlns="myns"
      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:

      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



              • Assignee:
                rolfl Rolf
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: