aalto-xml
aalto-xml copied to clipboard
XMLReaderImpl.getAttributeValue(String, String) does not ignore namespace if null
Stax javadoc says :
String javax.xml.stream.XMLStreamReader.getAttributeValue(String namespaceURI, String localName) Returns the normalized attribute value of the attribute with the namespace and localName If the namespaceURI is null the namespace is not checked for equality
That's not the behavior implemented by com.fasterxml.aalto.stax.StreamReaderImpl If namespace is set at null StreamReaderImpl checks if the localValue of the attribute has no namespace.
Why would you do that, making a useful method so useless ?
Alternative is :
private static String getAttributeValueByLocalName(XMLStreamReader2 element, String localName) {
for (int i = 0; i < element.getAttributeCount(); i++) {
if(localName.equals(element.getAttributeLocalName(i))) {
return element.getAttributeValue(i);
}
}
return null;
}
This is way less attractive.