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

Mixed content not exposed through FromXmlParser, lost by JsonNode #405

Closed
cowtowncoder opened this issue May 22, 2020 · 1 comment
Closed
Milestone

Comments

@cowtowncoder
Copy link
Member

Currently (2.11) "Mixed content" is only exposed in case of textual content preceding an element, like:

<root>
   some text
  <child> ... </child>
</root>

but is not retained or exposed in token stream if it comes after a close element, so none of text segments in:

<root>
  <child>...</child>
  first text
  <child>...</child>
  last text
</root>

are exposed. This means that although as per #403 JsonNode could now express such content (considering nominal key of "" for text segements), but does not get them as FromXmlParser does not create matching logical tokens.
This should be fixed.

@cowtowncoder
Copy link
Member Author

Implemented for 2.12(.0). Couple of limitations:

  1. While ordering of text segments will be retained (wrt each other), since all will be under logical key of "" (empty String), total ordering for all segments is not retained
  2. Blank (all-whitespace) text segments are not retained (not even between end-start-element) -- currently they must be skipped to make indentation work for regular content.

So it may make sense to introduce something more specific for really accurate XML content (besides above-mentioned issues, element/attribute distinction is not preserved either).
Choices include:

  • Make DOM Element bind directly from underlying XML elements (instead of trying to parse textual values
  • Create something similar to DOM (JDOM, DOM4j); XmlNode for example, make that bind.

But work for those need to go under different issue.

alex-bel-apica pushed a commit to ApicaSystem/jackson-dataformat-xml that referenced this issue Sep 4, 2020
alex-bel-apica pushed a commit to ApicaSystem/jackson-dataformat-xml that referenced this issue Sep 4, 2020
alex-bel-apica pushed a commit to ApicaSystem/jackson-dataformat-xml that referenced this issue Sep 4, 2020
alex-bel-apica pushed a commit to ApicaSystem/jackson-dataformat-xml that referenced this issue Sep 4, 2020
# Conflicts:
#	release-notes/VERSION-2.x
#	src/test/java/com/fasterxml/jackson/dataformat/xml/deser/JsonNodeBasicDeserTest.java
#	src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UntypedObjectDeserTest.java
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