Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » xsd:Any, marshalling, and escaping(xsd:Any, marshalling, and escaping)
xsd:Any, marshalling, and escaping [message #905504] Thu, 30 August 2012 10:06 Go to next message
Eclipse UserFriend
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 &lt; 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);
Re: xsd:Any, marshalling, and escaping [message #989873 is a reply to message #905504] Sat, 08 December 2012 17:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jeffrey,

It looks like you've uncovered a bug here. What you should be able to do is provide an EclipseLink bindings file to specify that the 'any' mapping is CDATA, which would prevent it from being escaped. Unfortunately it looks like we're not picking up CDATA information on any mappings, and escaping is still occurring. I've entered a bug for this which you can track here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=395984

Thanks,
Rick
Re: xsd:Any, marshalling, and escaping [message #990092 is a reply to message #905504] Mon, 10 December 2012 15:39 Go to previous message
Eclipse UserFriend
Hi Jeffrey,

By default JAXB implementations store XML fragments within an Any as DOM elements, but you can specify a DomHandler to support alternate representations such as String. Below is a link to a complete example:

- http://blog.bdoughan.com/2011/04/xmlanyelement-and-non-dom-properties.html

-Blaise
Previous Topic:eclipselink.ddl-generation and JTA datasources
Next Topic:query a subpart of complex graph and get a smallest object
Goto Forum:
  


Current Time: Fri Jul 04 18:42:13 EDT 2025

Powered by FUDForum. Page generated in 0.03132 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top