Missing header directive- Standalone = "Yes"

54 views
Skip to first unread message

Yuvraj Shinde

unread,
May 6, 2020, 3:23:19 AM5/6/20
to jacks...@googlegroups.com

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.

Tatu Saloranta

unread,
May 6, 2020, 1:22:45 PM5/6/20
to jacks...@googlegroups.com
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 +-
Reply all
Reply to author
Forward
0 new messages