commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Crossman <>
Subject RE: Betwixt appears to escape special characters
Date Tue, 23 Mar 2004 18:03:56 GMT
I am also interested in the answer here. 
Maxim: How do you get certain elements to be given <![CDATA[ ]]/> treatment?  And is
it possible to only have CDATA applied when the contained text-value is HTML or equivalent?
 How do we control this in the .betwixt file?

-----Original Message-----
From: Nechiporenko, Maxim [mailto:Maxim.Nechiporenko@FMR.COM] 
Sent: Monday, March 22, 2004 10:41 AM
Subject: Betwixt appears to escape special characters

I am having trouble marshalling a JavaBean with one of its attribute values set to a text
which is an XML  string. It looks like Betwixt escapes special characters coverting them to
ASCII. I have a JavaBean, and I use Commons Betwixt to marshall JavaBean in XML.
Here is what  I am doing:

// JavaBean 
public class Foo 
  private String val = null; 

  public void setVal (String val) 
    this.val = val; 

  public String getVal() 
    return this.val; 

// Test program 

public class test 
  public static void main (String [] args) 
    test t = new test(); 
  public void doStuff() 
    Foo bean = new Foo(); 
    bean.setVal("<![CDATA[<error>Some Error</error>]]"); 

    StringWriter outputWriter = new StringWriter(); 
    BeanWriter beanWriter = new BeanWriter(outputWriter); 
    beanWriter.write("foo", bean); 
    System.out.println("XML:  "+ outputWriter.toString()); 
The XML I am getting looks the following: 

    &lt;![CDATA[&lt;error&gt;Some Error&lt;/error&gt;]]&gt; 

when I would need it to be: 

    <![CDATA[<error>Some Error</error>]] 

I have no issues marshalling this Bean using Castor. Any help on how to get Betwixt to produce
the desired  XML string is welcome.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message