aalto-xml icon indicating copy to clipboard operation
aalto-xml copied to clipboard

XMLReaderImpl.getAttributeValue(String, String) does not ignore namespace if null

Open zebrada opened this issue 6 years ago • 1 comments

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 ?

zebrada avatar Feb 25 '19 18:02 zebrada

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.

zebrada avatar Feb 25 '19 18:02 zebrada