Printing & in Jasper

0
Dear All, I am printing some text in a Field. Along with text it contains "&" symbol. While generating report it throw some exceptions. How can I avoid this? Regards, Arunagiri.K
arunize's picture
Joined: Aug 23 2006 - 4:29pm
Last seen: 8 years 2 months ago

4 Answers:

0
Can you list the expression in the field along with the exception it throws please? Robin
rsilver@ns.sympatico.ca's picture
Joined: Aug 4 2006 - 3:46am
Last seen: 8 years 2 months ago
0
rsilver@bfm.bm wrote:
Can you list the expression in the field along with the exception it throws please? Robin
My Field is "<style isBold=\"true\">"+ "GROSS : " + "</style>" + $F{gross}.replaceAll("\t", " ") I passed value for gross is "5.5cms in length & 0.5cms in dia" My Error is [Fatal Error] :1:102: The entity name must immediately follow the '&' in the entity reference. 09 Oct 2006 10:32:59,550 WARN JRFillTextElement [AWT-EventQueue-0][]: Invalid styled text. org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:133) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:453) at net.sf.jasperreports.engine.fill.JRFillTextElement.getText(JRFillTextElement.java:479) at . . . . . . java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822) [Fatal Error] :1:102: The entity name must immediately follow the '&' in the entity reference. at java.awt.Container.dispatchEventImpl(Container.java:2010) at java.awt.Window.dispatchEventImpl(Window.java:1774) at java.awt.Component.dispatchEvent(Component.java:3803) at . . . .
Post edited by: arunize, at: 2006/10/09 05:10
arunize's picture
Joined: Aug 23 2006 - 4:29pm
Last seen: 8 years 2 months ago
0
Hey I got the solution Use &amp;amp; to print the & . I used like this $F{gross}.replaceAll("&","&amp;amp;") Thanks Arunagiri.K
arunize's picture
Joined: Aug 23 2006 - 4:29pm
Last seen: 8 years 2 months ago
0
Sorry, i guess i started a new topic about the same issue without searching the forum. I did the same thing replaceAll("&", "&amp;"), but still got the error. the only difference is that i do this replaceAll in my data source... I'm also confused as to how you were able to show the escape sequence on the forum, since my escape sequence gets converted into an ampersand!
jo_atman's picture
Joined: Sep 6 2006 - 9:11am
Last seen: 8 years 1 month ago
Feedback