FasterXML / aalto-xml

Ultra-high performance non-blocking XML processor (Stax API + extensions)
Apache License 2.0
288 stars 70 forks source link

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

Open zebrada opened 5 years ago

zebrada commented 5 years ago

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 commented 5 years ago

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.