2013-04-28 70 views
0

這裏是我的xml文件:XML編寫SAX異常

<?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中編譯。有任何想法嗎?謝謝。

回答