-
Notifications
You must be signed in to change notification settings - Fork 114
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
Formatted output (ident) not working when using XMLAnyElement #1707
Comments
Was providing a PR for that but in fact, your test case is wrong. By marshalling the Test.xml to Job class, you create "text nodes" that will contains the whitespaces between xml tag and closing tags. <baz>
<value name="xxx"/>
</baz> will create a Baz tag, having child tag value and a text node of By marshalling this, it will output the You should try with constructing the Job element from java code (or remove all the whitespaces that are irrelevant), you'll then see that output is conform to expected. Regards |
Hello Laurent, thank you for your explanation. I was expecting that the JAXB_FORMATTED_OUTPUT option deals with "additional" whitespaces. But I agree. How shall the Marshaller know which one is additional and which one is not. But you gave me a good hint. I might just need to scan the elements list for "whitespace only" text elements and remove them. This might be "cheaper" than starting up an entire xslt processor. Perhaps you can close this issue with "won't fix". |
That's what I was trying to do in my PR original submission, ignoring every "whitespace only" characters output in processing of formatted output. But was a bit curious why it wanted to output |
@lukasj : as suggested, maybe close this issue with "won't fix" tag ? |
closing as suggested |
I read that it is possible to write out pretty printed xml with the help of
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
When using XMLAnyElement, I get an unexpected result. Only the start tags are indented, but the end-tags are not.
Is there any method to fix it (except piping it through an xsl formatter)?
See my example below.
I have an extremely simple model like so:
The test program looks like this
Test.xml content is this:
The program generates this output:
I was expecting something like this:
The text was updated successfully, but these errors were encountered: