JasperReports:使用xml子报告xPath报告

时间:2012-07-25 11:46:47

标签: xpath jasper-reports

我有一个主报告,当小组改变时调用子报告 我传递两个XML文档,它们是主数据库和子报告的不同数据源 子报表正在打印,但每个子报表都会丢失数据的2个第一个记录 我认为这是一个错误的 xPath 表达式,但我尝试了几个解决方案,但没有人适合我。

主人报告jrxml档案的片段:

<queryString language="xPath"><![CDATA[riepilogo-ec/dettagli/dettaglio]]></queryString>
<group name="GiroGroup" isStartNewColumn="false" isStartNewPage="false"
    isReprintHeaderOnEachPage="true" keepTogether="true">
    <groupExpression>
        <![CDATA[$F{giro}]]>
    </groupExpression>

    <groupFooter>
        <band height="20" isSplitAllowed="false">
            <subreport>
                <reportElement isPrintRepeatedValues="true" x="0" y="0" width="507" height="10"
                    isRemoveLineWhenBlank="true" backcolor="#ffcc99"> </reportElement>
                <subreportParameter name="REPORT_DATA_SOURCE">
                    <subreportParameterExpression>
                        <![CDATA[new net.sf.jasperreports.engine.data.JRXmlDataSource( $P{subTotale}).dataSource("totali/totale[@giro=" + $F{giro}+ "]/tot-cau")]]>
                        <!--<![CDATA[new net.sf.jasperreports.engine.data.JRXmlDataSource( $P{subTotale})]]>-->
                        <!--<![CDATA[new net.sf.jasperreports.engine.data.JRXmlDataSource( $P{subTotale}).subDataSource("/totali/totale[@giro=1]")]]>-->
                    </subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="XML_DATE_PATTERN">
                    <subreportParameterExpression>$P{XML_DATE_PATTERN}</subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="XML_NUMBER_PATTERN">
                    <subreportParameterExpression>$P{XML_NUMBER_PATTERN}</subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="XML_LOCALE">
                    <subreportParameterExpression>$P{XML_LOCALE}</subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="XML_TIME_ZONE">
                    <subreportParameterExpression>$P{XML_TIME_ZONE}</subreportParameterExpression>
                </subreportParameter>

                <subreportParameter name="pageNumberMaster">
                    <subreportParameterExpression>$V{PAGE_NUMBER}</subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="giro">
                    <subreportParameterExpression>$F{giro}</subreportParameterExpression>
                </subreportParameter>

                <subreportExpression class="net.sf.jasperreports.engine.JasperReport"
                    >$P{subReport}</subreportExpression>
            </subreport>


        </band>
    </groupFooter>
</group>

子报告查询:

 <queryString language="xPath"><![CDATA[totali/totale/tot-cau]]></queryString>

主数据:

<dettagli>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>1</cod-riv>
            <check-digit>G</check-digit>
            <desc-riv>FUSARO GIANCARLO</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>1.162,44 </forniture>
            <addebiti/>
            <rese>461,46 </rese>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>700,98 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>2</cod-riv>
            <check-digit>H</check-digit>
            <desc-riv>BENINI LAURA</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>785,16 </forniture>
            <addebiti/>
            <rese>250,92 </rese>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>534,24 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>4</cod-riv>
            <check-digit>J</check-digit>
            <desc-riv>CAMPOLONGO FLAVIO</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>7.472,82 </forniture>
            <addebiti/>
            <rese>443,84 </rese>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>7.028,98 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>5</cod-riv>
            <check-digit>K</check-digit>
            <desc-riv>LA COMETA S.N.C.</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>877,32 </forniture>
            <addebiti/>
            <rese>29,48 </rese>
            <accrediti/>
            <saldo-contabile>302,40 </saldo-contabile>
            <saldo-ec>847,84 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>68</cod-riv>
            <check-digit>V</check-digit>
            <desc-riv>BENINI DAVIDE</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>1.073,16 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile>1.507,56 </saldo-contabile>
            <saldo-ec>1.073,16 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>101</cod-riv>
            <check-digit>C</check-digit>
            <desc-riv>AMBROSI CARLA</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>1.127,34 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile>1.276,80 </saldo-contabile>
            <saldo-ec>1.127,34 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>110</cod-riv>
            <check-digit>L</check-digit>
            <desc-riv>JANA HAVRLANTOVA</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>579,06 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>579,06 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>228</cod-riv>
            <check-digit>Z</check-digit>
            <desc-riv>PIZZINI ARTURO</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>985,50 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>985,50 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>252</cod-riv>
            <check-digit>X</check-digit>
            <desc-riv>PERINA ROBERTO</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>5.099,76 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile>1.347,36 </saldo-contabile>
            <saldo-ec>5.099,76 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>279</cod-riv>
            <check-digit>Y</check-digit>
            <desc-riv>FASOLI GIUSEPPE</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>611,10 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>611,10 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>256</cod-riv>
            <check-digit>B</check-digit>
            <desc-riv>MIGLIORINI VITTORINA</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>1.077,66 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>1.077,66 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>309</cod-riv>
            <check-digit>C</check-digit>
            <desc-riv>CASTIONI SERGIO</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>8.302,44 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile>447,30 </saldo-contabile>
            <saldo-ec>8.302,44 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>310</cod-riv>
            <check-digit>D</check-digit>
            <desc-riv>EDICOLA MANCALACQUA SNC</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>716,40 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>716,40 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>332</cod-riv>
            <check-digit>Z</check-digit>
            <desc-riv>VILLABONI ANNA MARIA</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>571,68 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>571,68 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>376</cod-riv>
            <check-digit>R</check-digit>
            <desc-riv>ZARAMELLA NADIA</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>581,94 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>581,94 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>404</cod-riv>
            <check-digit>T</check-digit>
            <desc-riv>CASTIONI GIORGIO</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>1.508,94 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>1.508,94 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>405</cod-riv>
            <check-digit>U</check-digit>
            <desc-riv>CARTOLERIA AMBROSI DANIEL</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>1.029,42 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>1.029,42 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>395</cod-riv>
            <check-digit>K</check-digit>
            <desc-riv>EDERLE MIRELLA</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>304,20 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile>178,80 </saldo-contabile>
            <saldo-ec>304,20 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>486</cod-riv>
            <check-digit>X</check-digit>
            <desc-riv>RAGUSO ANTONIO</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>545,40 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>545,40 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>558</cod-riv>
            <check-digit>R</check-digit>
            <desc-riv>TROIANI SAS</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>3.741,66 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>3.741,66 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>514</cod-riv>
            <check-digit>Z</check-digit>
            <desc-riv>IL PUNTO DI COPPINI M.</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>959,22 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile>1.194,48 </saldo-contabile>
            <saldo-ec>959,22 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>515</cod-riv>
            <check-digit>A</check-digit>
            <desc-riv>GIOACHINI LAURA</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>5.450,30 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>5.450,30 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>624</cod-riv>
            <check-digit>F</check-digit>
            <desc-riv>GDO PRESS S.R.L.</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>190,08 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>190,08 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>700</cod-riv>
            <check-digit>D</check-digit>
            <desc-riv>MACH 2 AUTOGR.SCAL.NORD</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>1.118,52 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>1.118,52 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>701</cod-riv>
            <check-digit>E</check-digit>
            <desc-riv>MACH 2 AUTOGR.SCAL.SUD</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>1.118,52 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>1.118,52 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>1</giro>
            <cod-riv>814</cod-riv>
            <check-digit>N</check-digit>
            <desc-riv>MACH DUE C/O IL SOLE SOMM</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>785,16 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>785,16 </saldo-ec>
        </dettaglio>
        <dettaglio>
            <giro>2</giro>
            <cod-riv>259</cod-riv>
            <check-digit>E</check-digit>
            <desc-riv>EL GIORNALAR</desc-riv>
            <riporto/>
            <versamenti-acconti/>
            <riporto/>
            <forniture>1.051,20 </forniture>
            <addebiti/>
            <rese/>
            <accrediti/>
            <saldo-contabile/>
            <saldo-ec>1.051,20 </saldo-ec>
        </dettaglio>
</dettagli>

子报告数据:

<totali>
    <totale giro="1">
        <tot-cau>
            <cod-cau-tot>5</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Resa Periodici Esteri</desc-cau-tot>
            <importo-cau>9,74 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>201</cod-cau-tot>
            <tipo-cau-tot>1</tipo-cau-tot>
            <desc-cau-tot>NS.FATTURA 20%</desc-cau-tot>
            <importo-cau>6.254,70 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>52</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Fornitura Periodici esteri</desc-cau-tot>
            <importo-cau>15,10-</importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>11</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>RESA X CESS.ATTIVITA'</desc-cau-tot>
            <importo-cau>79,18 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>38</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Diff. resa quotidiani</desc-cau-tot>
            <importo-cau>169,32 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>76</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Add.lavorazione extra</desc-cau-tot>
            <importo-cau>0,00 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>54</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Fornitura Quot./Illus.</desc-cau-tot>
            <importo-cau>30,54 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>2</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Resa Quotidiani</desc-cau-tot>
            <importo-cau>28,26 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>1</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Versamento</desc-cau-tot>
            <importo-cau>23.319,64 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>8</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Integrazione resa periodici</desc-cau-tot>
            <importo-cau>210,16 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>3</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Resa PERIODICI</desc-cau-tot>
            <importo-cau>353,72 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>46</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Versamento RID</desc-cau-tot>
            <importo-cau>19.439,04 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>4</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Resa Periodici esteri</desc-cau-tot>
            <importo-cau>332,32 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>41</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>ACCREDITO RESA FUORI BOLLA</desc-cau-tot>
            <importo-cau>3,00 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>51</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Fornitura PERIODICI</desc-cau-tot>
            <importo-cau>26.464,00 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>108</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Insoluto RID</desc-cau-tot>
            <importo-cau>200,00 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>50</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Fornitura Quotidiani</desc-cau-tot>
            <importo-cau>90,10 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>86</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>ADDEBITO CONTO DEPOSITO</desc-cau-tot>
            <importo-cau>21.205,66 </importo-cau>
        </tot-cau>
    </totale>
    <totale giro="2">
        <tot-cau>
            <cod-cau-tot>201</cod-cau-tot>
            <tipo-cau-tot>1</tipo-cau-tot>
            <desc-cau-tot>NS.FATTURA 20%</desc-cau-tot>
            <importo-cau>2.539,80 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>51</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Fornitura PERIODICI</desc-cau-tot>
            <importo-cau>27.180,72 </importo-cau>
        </tot-cau>
        <tot-cau>
            <cod-cau-tot>1</cod-cau-tot>
            <tipo-cau-tot>10</tipo-cau-tot>
            <desc-cau-tot>Versamento</desc-cau-tot>
            <importo-cau>7.196,26 </importo-cau>
        </tot-cau>
    </totale>
</totali>

我看到,如果我把子报告放在它工作的摘要中,那么群组页脚的问题是什么意思?

我尝试调试Jasperreport库,我看到什么时候调用xPathExecuter.selectNodeList(document,selectExpression)

它返回正确数量的节点,但列表中的第一个节点不是xml文件中第一个显示xPath表达式的节点。

如何以正确的顺序获取节点?

0 个答案:

没有答案