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

FromXMLParser nextTextValue() incorrect for attributes #204

Closed
frederikz opened this issue Aug 3, 2016 · 4 comments
Closed

FromXMLParser nextTextValue() incorrect for attributes #204

frederikz opened this issue Aug 3, 2016 · 4 comments
Milestone

Comments

@frederikz
Copy link

As of #129 the Method nextTextValue of FromXMLParser will no longer return a value for attributes. As the _currToken is JsonToken.VALUE_STRING in this case I think it is wrong to return null and it should return _currText.

@cowtowncoder
Copy link
Member

Quite possible. Do you have a simple reproduction to show the problem, and to make sure fix would resolve the problem.

@frederikz
Copy link
Author

frederikz commented Aug 9, 2016

Modified test from XmlParserTest:

public void testXmlAttributesWithNextTextValue() throws Exception
    {
        final String XML = "<data max=\"7\" offset=\"9\"/>";

        FromXmlParser xp = (FromXmlParser) _xmlFactory.createParser(new StringReader(XML));

        // First: verify handling without forcing array handling:
        assertToken(JsonToken.START_OBJECT, xp.nextToken()); // <data>
        assertToken(JsonToken.FIELD_NAME, xp.nextToken()); // <max>
        assertEquals("max", xp.getCurrentName());
        assertEquals("7", xp.nextTextValue());

        assertToken(JsonToken.FIELD_NAME, xp.nextToken()); // <offset>
        assertEquals("offset", xp.getCurrentName());

        StringWriter w = new StringWriter();
        assertEquals(6, xp.getText(w));
        assertEquals("offset", w.toString());

        assertEquals("9", xp.nextTextValue());

        w = new StringWriter();
        assertEquals(1, xp.getText(w));
        assertEquals("9", w.toString());

        assertToken(JsonToken.END_OBJECT, xp.nextToken()); // </data>
        xp.close();
    }

@cowtowncoder
Copy link
Member

@frederikz Forgot to ask which versions this is with?

@cowtowncoder cowtowncoder added this to the 2.7.7 milestone Aug 18, 2016
@cowtowncoder
Copy link
Member

Was occurring at least with 2.7 and 2.8; and since earlier branches not maintained any more bit of a moot point. Fix will be in 2.7.7 / 2.8.2; was a simple case of not actually returning the text...

Thank you for reporting this!

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

2 participants