If I have the class A.java
:
@JacksonXmlRootElement(localName = "A")
public class A {
}
The output that gets produced is:
<A
xmlns="">
I want to add a few more namespaces to the output, i.e.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com example.xsd"
How do I configure A.java
to contain more custom namespaces like these?
Since xsi:schemaLocation is an attribute, you can add it like that:
public class A implements Serializable {
@JacksonXmlProperty(isAttribute = true, localName = "xsi:schemaLocation")
private String schemaLocation = "urn:path:to.your.schema";
It did the job for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With