Hello Castor-List,

This is a question that been asked a number of times before in various
forms, but I still don't know _the_ definitive answer.

Q: what is the simplest way to include a chunk of arbitrary xml when using
Castor-XML unmarshalling so that it is mapped as a String.

e.g. I am specifying a set of tests, one field contains a chunk of xml input
data and a second field contains the expected result. My users want to be
able to edit the xml by hand in an xml editor, so that they can see that the
xml is valid.

A(1): output-escape it using < > etc. This is the default behaviour.

A(2): After the user has finished editing, enclose the arbitrary xml chunks
in CDATA blocks.

A(3): A previous answer involved defining a handler, but I think that i may
have it wrong as Eclipse is telling me that org.xml.sax.DocumentHandler is
deprecated:

 String[] cdata = {"html-tag","contents","question","text","feedback"};
 format.setCDataElements(cdata);
 format.setNonEscapingElements(cdata);
 XMLSerializer serializer = new XMLSerializer(writer,format);
 org.xml.sax.DocumentHandler handler = serializer.asDocumentHandler();
 Marshaller marsh = new Marshaller(handler);

Regards,
       Jez
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.6/111 - Release Date: 23/09/2005


-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to