Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zebrada opened this issue Feb 25, 2019 · 1 comment

Comments

@zebrada
Copy link

zebrada commented Feb 25, 2019

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
Copy link
Author

zebrada commented Feb 25, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant