xsd:Any, marshalling, and escaping [message #905504] |
Thu, 30 August 2012 14:06 |
Jeffrey Andrews Messages: 1 Registered: August 2012 |
Junior Member |
|
|
I have a schema (xsd) that one of my elements can take anything, including sub-xml.
My issue is that when I go to marshall my object, it escapes the '<' as < and I don't want it to.
I've implemented a CharacterEscapeHandler, but that applies to the whole document, whereas I just want
this one piece not to be escaped. I use xjc to create my classes from an xsd. Any ideas?
A snippet from my xsd is below and a snippet of my code follows.
<xs:complexType>
<xs:choice minOccurs="0">
<xs:element name="TXM_Payload">
<xs:annotation>
<xs:documentation xml:lang="en">Any payload</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:element ref="txmf:TXM_Fault"/>
<xs:element ref="txmr:TXM_Report"/>
</xs:choice>
</xs:complexType>
body.setTXMPayload(payload);
// this is where I set the text for the payload.
payload.getAny().add("<FreeText>This is a test</FreeText>");
envelope.setTXMBody(body);
try
{
JAXBContext context = JAXBContext.newInstance("aero.sita.messaging.typex.jaxb");
Marshaller marshaller = context.createMarshaller();
FileWriter writer = new FileWriter("xatap_send_message.xml");
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
// marshaller.setProperty("eclipselink.character-escape-handler", NoEscapeHandler.theInstance);
marshaller.marshal(envelope, writer);
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02957 seconds