这是我的xml文件:
<?xml version= "1.0" encoding = "windows-1251"?>
<!DOCTYPE jasperReport
PUBLIC "-//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd" >
<jasperReport name = "first">
<style
name = "Base"
isDefault = "true"
hAlign = "Center"
vAlign = "Middle"
fontName = "Arial"
pdfFontName = "C:\Windows\Fonts\arial.ttf"
pdfEncoding = "Cp1251"
isPdfEmbedded = "true"
fontSize = "10"
/>
<field name = "Faculty_Name" class = "java.lang.String" />
<field name = "StudSurname" class = "java.lang.String" />
<detail>
<band height = "20" >
<textField>
<reportElement x = "100" y = "0" width = "100" height = "20" />
<textFieldExpression class = "java.lang.String" >
<![CDATA[$F{Faculty_Name}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x = "200" y = "0" width = "100" height = "20" />
<textFieldExpression class = "java.lang.String" >
<![CDATA[$F{StudSurname}]]>
</textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
这是我的代码:
try {
String configFileText = JasperConfigMaker.getConfig(columnList, "first");
File configFile = new File("jasper.jrxml");
configFile.createNewFile();
FileWriter writer = new FileWriter(configFile);
BufferedWriter buffered = new BufferedWriter(writer);
buffered.write(configFileText);
buffered.flush();
buffered.close();
writer.close();
System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");
JasperReport jasperReport = JasperCompileManager.compileReport("jasper.jrxml");
// configFile.delete();
// JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, new HashMap(), new JRResultSetDataSource(reportData));
/// JasperExportManager.exportReportToPdfFile(jasperPrint, "reports/" + pdfFileName);
} catch (Exception e) {
e.printStackTrace();
}
我得到例外:
net.sf.jasperreports.engine.JRException: org.xml.sax.SAXException: http://java.sun.com/xml/jaxp/properties/schemaSource
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:247)
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:230)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:218)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:172)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:156)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:171)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:448)
at univer.oko.jasper.JasperReportWriter.WriteToPdf(JasperReportWriter.java:34)
at univer.oko.jasper.JasperReportWriter.main(JasperReportWriter.java:83)
Caused by: org.xml.sax.SAXException: http://java.sun.com/xml/jaxp/properties/schemaSource
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1892)
at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:243)
... 8 more
请帮我理解原因。我在一小时内对抗这个错误。它也很有趣,它不是在Eclipse中编译,而是在IDEA中编译。有任何想法吗?谢谢。
答案 0 :(得分:0)
Parser不喜欢您的SmbFile作为架构源。 看一下SmbFile的文档: