how to use a java imported class in report

Hi,

I have a report with special caracters

when I generate the jrxml String it includes special characters and I get an error at line 2 (see the following)

(in jrxml, I have for example a static Text  "<text><![CDATA[" + field.getFldText() + "]]></text>" with special characters in field.getFldText())

line 1 - InputStream jrxmlInputStream = new ByteArrayInputStream(jrxml.toString().getBytes());

line 2 - JasperDesign jasperDesign = JRXmlLoader.load(jrxmlInputStream);

 

So, I try to escape special characters (xml escaping) the raw data ( field.getFldText() ) and to use an   imported class in jrxml to unescape back ( xml unescaping ) the data

<import value=\\"org.apache.commons.lang.StringEscapeUtils\\" /> under jasperReport tag

And for the static Text

<text><![CDATA[StringEscapeUtils.unescapeXml(").append(StringEscapeUtils.escapeXml(field.getFldText())).append(")]]></text>

 

But it seems that org.apache.commons.lang.StringEscapeUtils.unescapeXml() is not used as a java class but as a raw String (in jrxml, I can see the following: <text><![CDATA[StringEscapeUtils.unescapeXml(Do NOT use the following symbols: \\ (backward slash), &#233;, &#196;, &#223;, &#181; (non-English language symbols), &#176;C (superscripts), &#190; (fractions), symbols &lt; and &gt; and quotation marks)]]></text>

 

I conclude that I don't use the right way to use imported java class. Do you have an idea ?

 

Thank you in advance for your answers

flamant's picture
56
Joined: Nov 16 2011 - 12:48am
Last seen: 11 years 10 months ago

0 Answers:

No answers yet
Feedback
randomness