You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Derek Denny-Brown (JIRA)" <xe...@xml.apache.org> on 2006/09/19 02:36:22 UTC

[jira] Created: (XERCESJ-1191) Incorrect serialize of attribute sharing namespace as owning element

Incorrect serialize of attribute sharing namespace as owning element
--------------------------------------------------------------------

                 Key: XERCESJ-1191
                 URL: http://issues.apache.org/jira/browse/XERCESJ-1191
             Project: Xerces2-J
          Issue Type: Bug
          Components: Serialization
    Affects Versions: 2.8.1
            Reporter: Derek Denny-Brown


I found this in the copy of Xerces incorporated into J2SE 5.  I verified that the issue still exists in the current source for XMLSerializer.  The issue is that if an attributes.getQName() returns "", and attributes.getURI() returns the same namespace as the element tag where the attribute occurs, no prefix is applied.  This is incorrect.  According to the XML + XML-Namespace specs, the following are different documents (they represents different XML InfoSets, XPath claims they are different, and DOM also claims they are different).
  <p:e p:a="123" xmlns:p="test" />
  <p:e a="123" xmlns:p="test" />
The current XMLSerializer code will serialize the first as the 2nd.

Here is the offending code block.  I indicate the erroneous test which causes this issue.

                        if (( attrURI != null && attrURI.length() != 0 ) &&
                            ( namespaceURI == null || namespaceURI.length() == 0 ||
                              ! attrURI.equals( namespaceURI ) )) { <------------------------ this equality test should _not_ be there
                            prefix = getPrefix( attrURI );
                            if (prefix != null && prefix.length() > 0)
                                name = prefix + ":" + name;
                        }

The correct fix (according to the various XML specs) would be to remove the "attrURI.equals( namespaceURI )" test entirely.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org