Thanks - this is a good start... Followup question for Those Who Know...

The first solution is less desirable - I need something namespace-aware, and I'd prefer to keep things in code - the serialization I'm concerned about is actually happening in the guts of AXIS...  Yah, I could probably further hack the wsdd, but...

I like the idea of the second one, but I fear that I am missing something - I guess I don't understand where the quoting is happening given this fragment - the default (XMLFieldHandler) just passes back the raw (unescaped) string.  If I use the below handler, I'm just passing back the raw string surrounded by CDATA escaping - shouldn't whatever was escaping it in the first place just escape the CDATA-augmented string (e.g. result in "&lt;![CDATA[x&lt;y]]&gt;" rather than "<![CDATA[x<y]]>" .

Thanks again,
    mik

Jez Nicholson wrote:
Hi Mik,
 
I've wrestled with this one for an age. I refer you to an answer I got on the list yesterday to my email "easiest way to include arbitrary xml"....
 
OutputFormat format = new OutputFormat(Method.XML, "UTF-8", true);
String[] cdata = {"html-tag","contents","question","text","feedback"};
format.setCDataElements(cdata);
format.setNonEscapingElements(cdata);
XMLSerializer serializer = new XMLSerializer(new StringWriter(),format);
...

An alternative could be to create a simple FieldHandler

public class CDataFieldHandler extends AbstractFieldHandler
{

 /**
  * uses reflection to retrieve the value then wraps
  * it in a CDATA section
  */
 public Object getValue(Object object) throws IllegalStateException
 {
  FieldDescriptor f = getFieldDescriptor();
  String fieldName = f.getFieldName();

  Object value = PropertyUtils.getProperty(object,fieldName);
  if (value==null)
  {
   value = "";
  }
  return "<![CDATA[" + value.toString() + "]]>";
 }

}

Keith and co. please jump in if I am misguided.

Regards,

     Jez


--
Michael Thome
BBN Technologies 10 Moulton St, Cambridge MA 02138 USA
phone: +1 617 873 1853
------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] -------------------------------------------------

Reply via email to