Geven XML file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ExternalRequestContext [
<!ELEMENT ExternalRequestContext EMPTY>
<!ATTLIST ExternalRequestContext
requestType CDATA #REQUIRED
deepEnrichment (true | false) "false"
channelMandatory (true | false) "true">
]
>
<ExternalRequestContext requestType="News" deepEnrichment="false" />
And xStream code
@XStreamAlias("ExternalRequestContext")
class ERC {
private String requestType;
private boolean deepEnrichment;
private boolean channelMandatory;
}
...
XStream x = new XStream();
x.processAnnotations(ERC.class);
ERC erc = (ERC)x.fromXML(new FileReader("C:/Projects/Forwarder/Test.xml"));
x.toXML(erc, System.out);
My browser renders it as following:
<ExternalRequestContext requestType="News" deepEnrichment="false" channelMandatory="true" />
Note that channelMandatory="true" (browser processed the DTD instruction)
while xStream produces
<ExternalRequestContext>
<deepEnrichment>false</deepEnrichment>
<channelMandatory>false</channelMandatory>
</ExternalRequestContext>
Here channelMandatory="false" (xStream ignored the "channelMandatory (true | false) "true"" DTD instruction)
What do I miss? How to "tell" xStream to process DTD instructions? And how do I enable DTD validation in xStream?