On Wed, May 6, 2020 at 12:23 AM Yuvraj Shinde <[email protected]> wrote:
>
> I am using Jackson API to return object from from rest API in spring boot 
> application.
>
> On the client side i am reading object as xml.
>
> In xml header i can see version and encoding element are present but 
> standalone directive is missing.
>
> Can any one help me on this , I am struggling since last one week and I need 
> this fix as it impacting one of production issue .
>
> <?xml version="1.0" encoding="UTF-8" >
>
> Missing
>
> standalone="yes"?
>
> in above header.
>
> Please help to fix this issue, i don't want to use jab since all production 
> code is using Jackson jar.

I think it can be done in 2 ways.

One, brute force approach, is to simply serialize content into a
String, then find and replace xml doc declaration (opening "<?xml"
MUST come at beginning of document, as per xml declaration; "?>" can
be safely matched after that as well.

Second method is one where you will need to create `XMLStreamWriter`
(from configured `XMLOutputFactory`), call its `writeStartDocument()`
method, and then call `writeValue(XMLStreamWriter, Object)` method on
`XmlMapper`.
This would also allow you to write custom "<!DOCTYPE ....>"
declaration if that was needed.
You will also need to close `XMLStreamWriter` after `writeValue()` call.

-+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-dev/CAL4a10gmVfoG0w-yW0hABoDedqiaUMcwaGj95Ad1Fy%3DctK0JDg%40mail.gmail.com.

Reply via email to