问题
I've been struggling with my problem since 7 days. I have 1 XML input data and want to convert that into desired PDF file with line chart
XML
<?xml version="1.0" encoding="utf-8"?>
<sample-data xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:ht="urn:xyz.com/xslt/extensions">
<section name="relative-performance">
<historic-valuations>
<valuation-list>
<valuation>
<value>890000</value>
<date>2014-12-01T00:00:00</date>
</valuation>
<valuation>
<value>923789</value>
<date>2015-12-01T00:00:00</date>
</valuation>
<valuation>
<value>897978</value>
<date>2016-12-01T00:00:00</date>
</valuation>
<valuation>
<value>957883</value>
<date>2017-12-01T00:00:00</date>
</valuation>
<valuation>
<value>919203</value>
<date>2018-12-01T00:00:00</date>
</valuation>
<valuation>
<value>950000</value>
<date>2019-12-01T00:00:00</date>
</valuation>
</valuation-list>
</historic-valuations>
<local-market-index>
<local-market>HA7 3</local-market>
<index-value-list>
<index-value>
<value>890000</value>
<date>2014-12-01T00:00:00</date>
</index-value>
<index-value>
<value>931069</value>
<date>2015-12-01T00:00:00</date>
</index-value>
<index-value>
<value>912244</value>
<date>2016-12-01T00:00:00</date>
</index-value>
<index-value>
<value>980893</value>
<date>2017-12-01T00:00:00</date>
</index-value>
<index-value>
<value>948882</value>
<date>2018-12-01T00:00:00</date>
</index-value>
<index-value>
<value>988654</value>
<date>2019-12-01T00:00:00</date>
</index-value>
</index-value-list>
</local-market-index>
</section>
</sample-data>
My JRXML
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.11.0.final using JasperReports Library version 6.11.0-0c4056ccaa4d25a5a8c45672d2f764ea3498bebb -->
<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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f3e693aa-b906-4972-95b4-4a7430cabd45">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="NewData"/>
<subDataset name="subData" uuid="87538cc6-4a9e-4953-acaa-3190030517a8">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="NewData"/>
<queryString language="xPath">
<![CDATA[/sample-data/section[@name='relative-performance']/historic-valuations/valuation-list/valuation]]>
</queryString>
<field name="value" class="java.lang.Integer">
<property name="net.sf.jasperreports.xpath.field.expression" value="value"/>
<fieldDescription><![CDATA[value]]></fieldDescription>
</field>
<field name="date" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="date"/>
<fieldDescription><![CDATA[date]]></fieldDescription>
</field>
</subDataset>
<queryString language="xPath">
<![CDATA[/sample-data/section[@name='relative-performance']/local-market-index/index-value-listindex-value]]>
</queryString>
<field name="value1" class="java.lang.Integer">
<property name="net.sf.jasperreports.xpath.field.expression" value="value1"/>
<fieldDescription><![CDATA[value]]></fieldDescription>
</field>
<field name="date1" class="java.lang.String">
<property name="net.sf.jasperreports.xpath.field.expression" value="date1"/>
<fieldDescription><![CDATA[date]]></fieldDescription>
</field>
<detail>
<band height="370" splitType="Stretch">
<lineChart>
<chart evaluationTime="Report">
<reportElement x="0" y="40" width="550" height="290" uuid="9bdc21fd-9b73-4ea9-919e-2c8807153f78"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset resetType="Report"/>
<categorySeries>
<seriesExpression><![CDATA["Estimated capital value"]]></seriesExpression>
<categoryExpression><![CDATA[$F{date}]]></categoryExpression>
<valueExpression><![CDATA[$F{value}]]></valueExpression>
<labelExpression><![CDATA[""]]></labelExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["Local market index"]]></seriesExpression>
<categoryExpression><![CDATA[$F{date1}]]></categoryExpression>
<valueExpression><![CDATA[$F{value1}]]></valueExpression>
<labelExpression><![CDATA[""]]></labelExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</linePlot>
</lineChart>
</band>
</detail>
</jasperReport>
I searched a lot and come to know that In my situation I need to make subDataSource so I did from How to use multiple xpath datasets on XML datasource using PHP Jasper?
But I'm still getting this error
There are compilation error please fix the design
Field not found:date ---net.sf.jasperreports.xpath.field.expression@95d1b2c
Field not found:date ---net.sf.jasperreports.xpath.field.expression@62032410
I want to make line chart in jasper report then make it pdf in java which is another part but main issue is I'm not able to make a desired PDF which is
来源:https://stackoverflow.com/questions/60407670/how-to-fix-field-not-found-error-in-case-using-two-xpath-expressions-in-single