Jump to content
We've recently updated our Privacy Statement, available here ×

What's the use of verifyDesign ?


Peanut

Recommended Posts

Hello,

 

I've discovered the function JasperCompileManager.verifyDesign, and I wanted to use it in order to avoid my program crashing if the JRXML is not correct.

But this function needs a JasperDesign for parameter: this means that you've already called one of the JRXmlLoader.load before... and your program would have certainly crashed in this function !

 

Indeed, I've tried to put different mistakes in my JRXML file, and each times my program crashes in JRXmlLoader.load, never reaching JasperCompileManager.verifyDesign.

 

What do I miss ? :huh:

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi,

 

Well, you wanted to validate your JRXML and you did that! Your file is invalid, this is why the load operation did not succeed.

Isn't that what you wanted to do? See if the JRXML is valid or not? It is not. So you can catch the exception and do something with it.

 

The verifyDesign is for after loading the JasperDesign object. Even if the JRXML was parsed OK, maybe there are invalid cross-references or layout problems that need to be validated too.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

OK, so the verifyDesign has nothing to do with XML checking. Thanks.

 

So, as you said, I'm trying to catch exceptions on JRXmlLoader.load :

Code:
JasperDesign jasperDesign = new JasperDesign();
try
{
jasperDesign = JRXmlLoader.load(sNomFicJrxml);
}
catch (JRException e)
{
System.out.println( "[ERREUR] Problème lors du chargement du modèle JRXML : " + e.getMessage());
}

That works but I'd like not all that exception buffer to be printed on the screen, but only my println (ie only the last line of this capture) : is it possible ?

 

5 oct. 2006 14:27:54 org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 19 column 29: L'élément racine du document "jasperReportKO" doit correspondre à la racine DOCTYPE "jasperReport".
org.xml.sax.SAXParseException: L'élément racine du document "jasperReportKO" doit correspondre à la racine DOCTYPE "jasperReport".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(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.dtd.XMLDTDValidator.rootElementSpecified(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(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.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1647)
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:238)
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:225)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:213)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:167)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:151)
at jasper_compile_modele.main(jasper_compile_modele.java:133)
[ERREUR] Problème lors du chargement du modèle JRXML : L'élément racine du document "jasperReportKO" doit correspondre à la racine DOCTYPE "jasperReport".

I admit it's more a question about Java than about Jasper. :blush:

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...