Add feature to include standalone='yes' in xml declaration - #745
Merged
cowtowncoder merged 3 commits intoApr 16, 2025
Merged
Conversation
Member
|
Please describe why you even need standalone='yes'. That flag is only supposed to used with DTDs - and hardly anyone uses DTDs any more. |
pjfanning
reviewed
Apr 12, 2025
pjfanning
reviewed
Apr 12, 2025
pjfanning
reviewed
Apr 12, 2025
pjfanning
reviewed
Apr 12, 2025
Contributor
Author
First of all thank you so much for reviewing this so quickly. We work with a very nasty consumer on the other end which refuses to read the XML if standalone=yes is missing. |
duoduobingbing
force-pushed
the
feature/standalone-in-xml-declaration
branch
2 times, most recently
from
April 12, 2025 13:23
ec29218 to
633140f
Compare
duoduobingbing
force-pushed
the
feature/standalone-in-xml-declaration
branch
2 times, most recently
from
April 12, 2025 13:25
e95bf81 to
a619e5c
Compare
cowtowncoder
approved these changes
Apr 16, 2025
standalone='yes' in xml declarationstandalone='yes' in xml declaration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By default there is no easy way with Jackson XML to include
standalone='yes'inside the XML declaration. It requires swapping out thexmlWriterwhich is really cumbersome because the implementations ofBaseStreamWriterfrom Woodstox are final likeRepairingNsStreamWriter. Hence to change this the entirety of e.g.RepairingNsStreamWriterneeds to be copied to the project only to overrideBaseStreamWriter#writeStartDocumentto calldoWriteStartDocument(version, encoding, "yes");instead of the defaultdoWriteStartDocument(version, encoding, null);.This PR adds
ToXmlGenerator.Feature.WRITE_STANDALONE_YES_TO_XML_DECLARATIONwhich isfalseby default.When enabled
standalone='yes'will be added to the XML declaration if including it is enabled as well:will cause the first line to have
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>There is definetely a need for this as demonstrated by these posts: