Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:06 Go to next message
Jeffrey Andrews is currently offline Jeffrey AndrewsFriend
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 &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:choice minOccurs="0">
<xs:element name="TXM_Payload">
<xs:documentation xml:lang="en">Any payload</xs:documentation>
<xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
<xs:element ref="txmf:TXM_Fault"/>
<xs:element ref="txmr:TXM_Report"/>

// this is where I set the text for the payload.
payload.getAny().add("<FreeText>This is a test</FreeText>");

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 22:45 Go to previous messageGo to next message
Rick Barkhouse is currently offline Rick BarkhouseFriend
Messages: 22
Registered: July 2009
Junior Member
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:

Re: xsd:Any, marshalling, and escaping [message #990092 is a reply to message #905504] Mon, 10 December 2012 20:39 Go to previous message
Blaise Doughan is currently offline Blaise DoughanFriend
Messages: 163
Registered: July 2009
Senior Member

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:


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: Tue Apr 24 12:52:01 GMT 2018

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

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