Skip to content

Missing START_OBJECT token in complex element starting with text #442

Closed
@richardsonwk

Description

@richardsonwk

In version 2.12.0, I think XmlTokenStream might be omitting START_OBJECT tokens when a complex element starts with text content. The following has two START_OBJECT tokens but three END_OBJECT tokens:

        final String example = String.join("\n", Arrays.asList(
            "<SomeXml>", // START_OBJECT
            "  <ParentElement>", // *Missing* START_OBJECT
            "     text",
            "     <ChildElement someAttribute=\"value\"/>", // START_OBJECT/END_OBJECT
            "     further text",
            "  </ParentElement>", // END_OBJECT
            "</SomeXml>")); // END_OBJECT

        final XmlFactory factory = new XmlFactory();
        final JsonParser parser = factory.createParser(example);

        while (parser.nextToken() != null) {
            System.out.println(parser.currentToken()
                + (parser.getValueAsString() != null ? "(" + parser.getValueAsString() + ")" : ""));
        }

The output is

START_OBJECT
FIELD_NAME(ParentElement)
FIELD_NAME()
VALUE_STRING(
     text
     )
FIELD_NAME(ChildElement)
START_OBJECT
FIELD_NAME(someAttribute)
VALUE_STRING(value)
END_OBJECT
FIELD_NAME()
VALUE_STRING(
     further text
  )
END_OBJECT
END_OBJECT

Maybe there's a point of configuration I'm missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions