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?
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?