XML: Allow adding <?xml-stylesheet ...>
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);
}
(will move to correct repo)
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.