Jacob is correct. Only the '<' needs to be escaped, not the '>'.
XML predefines exactly 5 entity references: 
&lt;
&amp;
&gt;
&quot;
&apos;
but only &lt; and &amp; must be used instead of the literal characters in 
element content; the others are optional, with the exception that the 
3-character sequence "]]>" cannot appear in character data and must be written 
as "]]&gt;".
- Wing Yew

  _____  

From: Jacob Danner [mailto:jacob.dan...@gmail.com] 
Sent: Friday, October 02, 2009 1:55 PM
To: user@xmlbeans.apache.org
Subject: Re: Invalid escaping of XML


Off the top of my head I think this is as expected. The > does not need to be 
escaped only < .
-jacobd


On Fri, Oct 2, 2009 at 1:17 PM, Artem Portnoy <HYPERLINK 
"mailto:artem.portnoy....@gmail.com"artem.portnoy....@gmail.com> wrote:


Hello,

 

We have an XmlBean that takes in a String. The problem is that if we pass in an 
XML String, the XML characters are not properly escaped.

 

Here's a simple program I use to test.

 

  public static void main(String[] args) {

    Trace trace = TestProcessFlowV2Res.Traces.Trace.Factory.newInstance();

    trace.setStringValue("<test>");

    System.out.println(trace);

  }

 

The output produced looks as follows.

 

<xml-fragment>&lt;test></xml-fragment>

 

For some reason the '>' character is not getting escaped. We are currently 
using XmlBeans 2.1.0. I've tried searching for similar bug reports on the 
mailing list archive and couldn't find anything. If anybody could shed some 
light on this issue it would be greatly appreciated.




Thanks,





Artem Portnoy

Information Builders, Inc


Reply via email to