JDK-6840792 : sjsxp issue 70 XmlStreamReaderImpl.getAttributeValue namespace arg. not interpreted properly
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.stream
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-05-13
  • Updated: 2012-04-25
  • Resolved: 2009-06-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
1.4.0 h1141Fixed 6u18Fixed 7Fixed
Related Reports
Relates :  
Description
Attribute namespace in XmlStreamReaderImpl.getAttributeValue is not interpreted 
according to JSR 173.

Expected: Argument namespace "null" means: ignore namespace
Actual: Attribute is found if and only if namespace is null (for unqualified 
attribute) or namespace matches exactly (for qualified attribute).

Java default implementation has same bug. Test class my be provided or can be 
found in Java Bug Parade.

SJSXP Issue 63
This was a similar issue reported in issue 63:
XMLStreamReader.getAttributeValue(uri, ln) fails if uri == ""
Looks like implementation of XMLStreamReader.getAttributeValue(uri, localName)
only works if namespace URI is passed as null, but not when passed as "".
So, for example, following:

XMLInputFactory f = XMLInputFactory.newInstance();
XMLStreamReader sr = f.createXMLStreamReader(new StringReader("<root attr='1' />"));
        sr.next();
        String val1 = sr.getAttributeValue("", "attr");
        String val2 = sr.getAttributeValue(null, "attr");
        assertEquals(val1, val2)

fails; val2 gets correct value ("1") whereas val1 gets null.
This is incorrect: both should return "1".

I noticed this problem when verifying operation of StaxMate when using sjsxp as
the stax implementation: otherwise things work ok, but this is a significant
problem (for time being, I can mostly work around it by explicitly converting ""
to null for all calls)

Comments
EVALUATION When calling getAttributeValue(uri, local) with uri = null, the uri comparison must be ignored. Also if uri = "", then it must be mapped to null for internal use.
09-06-2009