我尝试在 iReport 上使用 XML ,所以我读过tutorial
但是当我编写报告时,我收到了这个错误:
Error filling print... XPath compilation failed. Expression:
net.sf.jasperreports.engine.JRException: XPath compilation failed. Expression:
at net.sf.jasperreports.engine.util.xml.JaxenXPathExecuter.getXPath JaxenXPathExecuter.java:66)
at net.sf.jasperreports.engine.util.xml.JaxenXPathExecuter.selectNodeList(JaxenXPathExecuter.java:77)
at net.sf.jasperreports.engine.data.JRXmlDataSource.moveFirst(JRXmlDataSource.java:415)
at net.sf.jasperreports.engine.data.JRXmlDataSource.<init>(JRXmlDataSource.java:189)
at net.sf.jasperreports.engine.query.JRXPathQueryExecuter.createDatasource(JRXPathQueryExecuter.java:113)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1087)
at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:668)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1258)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:877)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:126)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:464)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:300)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:757)
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:1003)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
Caused by: org.jaxen.XPathSyntaxException: Unexpected ''
at org.jaxen.BaseXPath.<init>(BaseXPath.java:118)
at org.jaxen.BaseXPath.<init>(BaseXPath.java:139)
at org.jaxen.dom.DOMXPath.<init>(DOMXPath.java:87)
at net.sf.jasperreports.engine.util.xml.JaxenXPathExecuter.getXPath(JaxenXPathExecuter.java:62)
... 15 more
Caused by: class org.jaxen.saxpath.XPathSyntaxException: : 0: Unexpected ''
at org.jaxen.saxpath.base.XPathReader.createSyntaxException(XPathReader.java:1084)
at org.jaxen.saxpath.base.XPathReader.pathExpr(XPathReader.java:190)
at org.jaxen.saxpath.base.XPathReader.unionExpr(XPathReader.java:1006)
at org.jaxen.saxpath.base.XPathReader.unaryExpr(XPathReader.java:994)
at org.jaxen.saxpath.base.XPathReader.multiplicativeExpr(XPathReader.java:943)
at org.jaxen.saxpath.base.XPathReader.additiveExpr(XPathReader.java:913)
at org.jaxen.saxpath.base.XPathReader.relationalExpr(XPathReader.java:860)
at org.jaxen.saxpath.base.XPathReader.equalityExpr(XPathReader.java:829)
at org.jaxen.saxpath.base.XPathReader.andExpr(XPathReader.java:809)
at org.jaxen.saxpath.base.XPathReader.orExpr(XPathReader.java:787)
at org.jaxen.saxpath.base.XPathReader.expr(XPathReader.java:780)
at org.jaxen.saxpath.base.XPathReader.parse(XPathReader.java:100)
at org.jaxen.BaseXPath.<init>(BaseXPath.java:113) ... 18 more
Print not filled. Try to use an EmptyDataSource...
XML 是:
<palette>
<color>Red</color>
<color>Green</color>
<color>Blue</color>
</palette>
我的 jrxml :
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a7fd885b-4cc6-40a2-a2e1-94538a942473">
<queryString language="xPath">
<![CDATA[]]>
</queryString>
<field name="color" class="java.lang.String">
<fieldDescription><![CDATA[/palette/color]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch">
<staticText>
<reportElement uuid="4d48ae42-2bf9-4b84-ba00-d55024428772" x="91" y="2" width="100" height="20"/>
<textElement/>
<text><![CDATA[/palette/color]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement uuid="e812c9c3-9aaa-4376-8a67-8ae386eaba13" x="91" y="51" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{color}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
有人能解释我发生了什么吗?
答案 0 :(得分:0)
使用/ palette / color作为查询字符串,并将字段描述更改为text()或“。”。 (删除引号)。
答案 1 :(得分:-1)
XML更改 从
<queryString language="xPath">
<![CDATA[]]>
</queryString>
到
<queryString language="xPath">
<![CDATA[*]]>
</queryString>
..是的,只有这一点,我需要2天才能解决你遇到的相同问题-.-