The entity "nbsp" was referenced, but not declared

0

Hi All,

I am using crosstab and in one of the text fields I set the markup="html".

The data passed to the text field is something like : <a href=" http://www.google.com/"/>, and it is coverted in my report to <a href="&nbsp; http://www.google.com/"/> and causes the following exception:

 

018-03-30 01:14:43,930 ERROR n.s.j.e.util.JRStyledTextParser - Error parsing styled text.
org.xml.sax.SAXParseException: The entity "nbsp" was referenced, but not declared.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
    at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanAttribute(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:235)
    at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:268)
    at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:608)
    at net.sf.jasperreports.engine.fill.JRFillTextElement.getText(JRFillTextElement.java:640)

 

Does anyone have any idea how to fix this?

 

Thanks in advance

hagar.zakaria.2011's picture
Joined: May 4 2016 - 2:40am
Last seen: 3 months 2 days ago

4 Answers:

0

Have you tried deleting the space in front of "http:"?

There is a space in front of "http:". 

 <a href=" http://www.google.com/"/>,

Delete this space so it will be like below.

 <a href="http://www.google.com/"/>, 

hozawa's picture
52632
Joined: Apr 24 2010 - 4:31pm
Last seen: 5 months 1 week ago
0

I don't have control over the data that is passed to jasper so I am not able to remove the space

hagar.zakaria.2011's picture
Joined: May 4 2016 - 2:40am
Last seen: 3 months 2 days ago
0

In case your html text is stored in a parameter (for instance $P{HtmlText}), then try to use

$P{HtmlText}.replaceAll(" http:","http:")

in your textfield expression, instead of $P{HtmlText}. Try similar expressions if the html content is stored in field or variable.

shertage's picture
1940
Joined: Sep 26 2006 - 8:06pm
Last seen: 21 hours 7 min ago
0

Seems easier to just use .trim()

e.g. if field name is $F{url}

$F{url}.trim()

hozawa's picture
52632
Joined: Apr 24 2010 - 4:31pm
Last seen: 5 months 1 week ago
Feedback