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

XML: Allow adding <?xml-stylesheet ...> #452

Open
OndraZizka opened this issue Feb 10, 2021 · 2 comments
Open

XML: Allow adding <?xml-stylesheet ...> #452

OndraZizka opened this issue Feb 10, 2021 · 2 comments
Labels
adding-declarations Issues related to adding non-content declarations to XML output

Comments

@OndraZizka
Copy link

Describe the solution you'd like
Allow adding to the resulting XML.

Usage example
I want to serialize Java POJOs to XML in Spring REST endpoint, but include XSLT reference so that the browsers render it as HTML.

Additional context
The only similar feature I found is a flag WRITE_XML_DECLARATION.

ObjectMapper mapper = builder.createXmlMapper(true).build();
    ((XmlMapper) mapper).enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION);
    return new MappingJackson2XmlHttpMessageConverter(mapper);
}
@cowtowncoder
Copy link
Member

(will move to correct repo)

@cowtowncoder cowtowncoder transferred this issue from FasterXML/jackson-databind Feb 10, 2021
@cowtowncoder
Copy link
Member

Right now the only way would be to explicitly contruct either underlying XMLStreamWriter, and write both xml declaration and style sheet PI (assuming it comes before root element); or, to construct ToXmlGenerator similarly, use writeRaw() to force output of declaration.

It would be good to add new mechanism(s), I think #150 is related to this. Not sure of the best way to model this; I don't think a feature flag will work well enough, but while configuring XmlMappers is possible via new Builder API, this may be something where per-write option would be preferable.

I hope to tackle something in this space for 2.13, tagging.

@cowtowncoder cowtowncoder added the adding-declarations Issues related to adding non-content declarations to XML output label Jul 7, 2021
@cowtowncoder cowtowncoder removed the 2.13 label Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adding-declarations Issues related to adding non-content declarations to XML output
Projects
None yet
Development

No branches or pull requests

2 participants