Strangeness with javax.xml.stream.XMLStreamReader

  • Thread starter Chronic Philharmonic
  • Start date
C

Chronic Philharmonic

I have a question about the behavior of

QName javax.xml.stream.XMLStreamReader.getName()

When I parse an XML file that looks like this (note "urn:time"),

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:xmlns:uppiano-karl:wxservice">
<soapenv:Header/>
<soapenv:Body>
<urn:getSensorData>
<urn:time>1193554861517</urn:time>
</urn:getSensorData>
</soapenv:Body>
</soapenv:Envelope>

I get a fully qualified qname from this:

String urn = "urn:xmlns:uppiano-karl:wxservice";
QName qname = reader.getName();

that is, qname.equals(new QName(urn, "time")) returns true.

When I parse an XML file that looks like this (note no "urn:" prefix on
"time"),

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:xmlns:uppiano-karl:wxservice">
<soapenv:Header/>
<soapenv:Body>
<urn:getSensorData>
<time>1193554861517</time>
</urn:getSensorData>
</soapenv:Body>
</soapenv:Envelope>

qname.equals(new QName(urn, "time")) returns false, because the parser does
not include the implied namespace in the QName. I thought that "time"
inherits the namespace of the enclosing element, and the parser should
reflect this. Does anyone know if this is normal behavior, or is it a bug?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top