hagar.zakaria.2011 Posted May 6, 2018 Share Posted May 6, 2018 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=" 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 Link to comment Share on other sites More sharing options...
hozawa Posted May 7, 2018 Share Posted May 7, 2018 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/"/>, Link to comment Share on other sites More sharing options...
hagar.zakaria.2011 Posted May 7, 2018 Author Share Posted May 7, 2018 I don't have control over the data that is passed to jasper so I am not able to remove the space Link to comment Share on other sites More sharing options...
szaharia Posted May 8, 2018 Share Posted May 8, 2018 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. Link to comment Share on other sites More sharing options...
hozawa Posted May 9, 2018 Share Posted May 9, 2018 Seems easier to just use .trim()e.g. if field name is $F{url}$F{url}.trim() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now