How to get JasperReports JRXmlDataSource to Validate Against Schema



I have modified the XML that my JasperReports project reads (and made the corresponding changes to the .jrxml files) but have not yet gotten around to modifying the XSD so that it corresponds to the changes I've made to the XML file.


The JasperReports are generated fine; no problem there. What surprised me was that JasperRunManager.runReportToPdfFile didn't throw any type of validation exception when I passed it an instance of JRXmlDataSource whose referenced XML file contains a reference to an XSD file that is (at the moment) out of date.


A snippet of the beginning of the XML looks like this:


<?xml version="1.0" encoding="utf-8"?> <Fund xmlns:xsi="http://ift.tt/ra1lAU" xsi:noNamespaceSchemaLocation="http:\\host:8080\EstateAccounting.xsd"> <FundName><![CDATA[Fund A2 & B]]></FundName> <Beneficiary> <BeneficiaryName><![CDATA[Michael - GSTT Non-Exempt]]></BeneficiaryName> <Month> <MonthValue>September 1, 2008</MonthValue>


and EstateAccounting.xsd currently does NOT accurately describe the XML.


The line of code that creates the data source is:


JRXmlDataSource xmlDataSource = new JRXmlDataSource(inputXmlFileName, "/Fund/Beneficiary/Month", true);


I am passing true as the isNamespaceAware parameter. This parameter is really not explained anywhere that I could find, so I just assumed that it would enforce the schema. But apparently not.


Why no validation exception?


No comments:

Post a Comment