How to use multiple xpath datasets on XML datasource using PHP Jasper?

不羁的心 提交于 2020-07-08 00:34:43

问题


I have designed a report in Jasper Studio that use XML as datasource and two XPATH datasets. I am able to generate the report and the data is filled from the first dataset (/data/invoice), but the second dataset (/data/invoice_items/row) is not found and returns null.

How can I add a second xpath to the php script for 'xml_xpath' => '/data/invoice_items/row'

This is my XML data:

<?xml version="1.0" encoding="utf-8"?>
<data>
    <invoice>
        <ID_Invoice>54654</ID_Invoice>
        <Invoice_Code>FCS</Invoice_Code>
        <Invoice_No>1</Invoice_No>
        <Invoice_Date>09/08/2019</Invoice_Date>
        <Seller_Name>Seller</Seller_Name>
        <Seller_VAT_Code>123123</Seller_VAT_Code>
        <Seller_Adress>New York</Seller_Adress>
        <Seller_Email/>
        <Partner_Name>John</Partner_Name>
        <Partner_VAT_Code>123456789</Partner_VAT_Code>
        <Partner_Adress>Atlanta</Partner_Adress>
        <Partner_Email/>
    </invoice>
    <invoice_items>
        <row>
            <ID_Invoice_Row>29433</ID_Invoice_Row>
            <Denumire>Product 1</Denumire>
            <Valoare>555.0000</Valoare>
            <VAT>0.0000</VAT>
            <TOTAL>555.0000</TOTAL>
        </row>
        <row>
            <ID_Invoice_Row>42345</ID_Invoice_Row>
            <Denumire>Product 2</Denumire>
            <Valoare>555.0000</Valoare>
            <VAT>0.0000</VAT>
            <TOTAL>555.0000</TOTAL>
        </row>
        <row>
            <ID_Invoice_Row>11234</ID_Invoice_Row>
            <Denumire>Product 3</Denumire>
            <Valoare>555.0000</Valoare>
            <VAT>0.0000</VAT>
            <TOTAL>555.0000</TOTAL>
        </row>
    </invoice_items>
</data>

The jrxml sample

<?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="Factura" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="153c2ff6-b65d-49fa-80de-5c1a093eafcc">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="FC_XML"/>
    <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="Factura_pozitii" uuid="1ee50e5a-b071-4886-8407-2ac843fb9ad1">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="FC_XML"/>
        <queryString language="XPath">
            <![CDATA[/data/invoice_items/row]]>
        </queryString>
        <field name="ID_Invoice_Row" class="java.lang.Integer">
            <property name="net.sf.jasperreports.xpath.field.expression" value="ID_Invoice_Row"/>
            <fieldDescription><![CDATA[ID_Invoice_Row]]></fieldDescription>
        </field>
        <field name="Denumire" class="java.lang.String">
            <property name="net.sf.jasperreports.xpath.field.expression" value="Denumire"/>
            <fieldDescription><![CDATA[Denumire]]></fieldDescription>
        </field>
        <field name="Valoare" class="java.lang.Float">
            <property name="net.sf.jasperreports.xpath.field.expression" value="Valoare"/>
            <fieldDescription><![CDATA[Valoare]]></fieldDescription>
        </field>
        <field name="VAT" class="java.lang.Float">
            <property name="net.sf.jasperreports.xpath.field.expression" value="VAT"/>
            <fieldDescription><![CDATA[VAT]]></fieldDescription>
        </field>
        <field name="TOTAL" class="java.lang.Float">
            <property name="net.sf.jasperreports.xpath.field.expression" value="TOTAL"/>
            <fieldDescription><![CDATA[TOTAL]]></fieldDescription>
        </field>
    </subDataset>
    <queryString language="XPath">
        <![CDATA[/data/invoice]]>
    </queryString>
    <field name="Seller_Name" class="java.lang.String">
        <property name="net.sf.jasperreports.xpath.field.expression" value="Seller_Name"/>
        <fieldDescription><![CDATA[Seller_Name]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <columnHeader>
        <band height="34" splitType="Stretch">
            <textField>
                <reportElement x="90" y="0" width="175" height="15" uuid="e9843cbc-f80d-4d43-ba3e-12abb7c1ed11"/>
                <textFieldExpression><![CDATA[$F{Seller_Name}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="0" width="80" height="15" uuid="449ed594-81b1-420c-b361-55709bd951c7"/>
                <text><![CDATA[Seller name:]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="92" splitType="Stretch">
            <componentElement>
                <reportElement x="0" y="0" width="555" height="60" uuid="93a83571-11ee-4173-9726-846f15cbdfec"/>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" whenNoDataType="Blank">
                    <datasetRun subDataset="Factura_pozitii" uuid="8a5ec067-61b0-4580-8aee-4fe353996db3">
                        <datasetParameter name="XML_DATA_DOCUMENT">
                            <datasetParameterExpression><![CDATA[$P{XML_DATA_DOCUMENT}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="XML_INPUT_STREAM">
                            <datasetParameterExpression><![CDATA[$P{XML_INPUT_STREAM}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="XML_FILE">
                            <datasetParameterExpression><![CDATA[$P{XML_FILE}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="net.sf.jasperreports.xml.source">
                            <datasetParameterExpression><![CDATA[$P{net.sf.jasperreports.xml.source}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="XML_DATE_PATTERN">
                            <datasetParameterExpression><![CDATA[$P{XML_DATE_PATTERN}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="XML_NUMBER_PATTERN">
                            <datasetParameterExpression><![CDATA[$P{XML_NUMBER_PATTERN}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="XML_LOCALE">
                            <datasetParameterExpression><![CDATA[$P{XML_LOCALE}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="XML_TIME_ZONE">
                            <datasetParameterExpression><![CDATA[$P{XML_TIME_ZONE}]]></datasetParameterExpression>
                        </datasetParameter>
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="40" uuid="d360ed7c-1960-426e-8541-07a125682d7e">
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="15">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField>
                                <reportElement x="0" y="0" width="40" height="15" uuid="cdea816f-81e3-4b32-bec6-7791d9862c37"/>
                                <box>
                                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="400" uuid="042fc8f1-a37e-412f-a4e8-f6f747d3054c">
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="400" height="30" uuid="015596ef-4660-4c7f-9b6d-96b6ddf3858d"/>
                                <text><![CDATA[Denumire]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="15">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="400" height="15" isPrintWhenDetailOverflows="true" uuid="983e6d52-1734-4ace-b791-ec8cfc03cf7c"/>
                                <box>
                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textFieldExpression><![CDATA[$F{Denumire}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="50" uuid="69c6f7bc-1e99-4ced-afcd-adfc2d8930a9">
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="50" height="30" uuid="0aa9d86a-dda0-469d-9923-b3d1e996b583"/>
                                <text><![CDATA[valoare]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="15">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField pattern="#,##0.###">
                                <reportElement x="0" y="0" width="50" height="15" uuid="11006503-d218-4a64-b8d4-240f611c4727"/>
                                <box>
                                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textFieldExpression><![CDATA[$F{Valoare}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
</jasperReport>

The php code:

use PHPJasper\PHPJasper;

$input = '/your_input_path/your_report.jasper';
$output = '/your_output_path';
$data_file = __DIR__ . '/your_data_files_path/your_xml_file.xml';
$options = [
    'format' => ['pdf'],
    'params' => [],
    'locale' => 'en',
    'db_connection' => [
        'driver' => 'xml',
        'data_file' => $data_file,
        'xml_xpath' => '/data/invoice'
    ]
];

$jasper = new PHPJasper();

$jasper->process(
    $input,
    $output,
    $options
)->execute();

If I run in terminat it says:

WARN JRXpathQueryExecuter:130 - No XML source was provided

I think it is for the second dataset, because the first is OK.


回答1:


Currently in your jrxml you are expecting two datasources (1 for main, 1 for table), in fact this report will work for example in JasperSoft Studio defining a correct data adapter.

However lets find a solution using only 1 datasource as defined in your php code.

In jasper reports you can create a new datasource from an xml datasource by using subDataSource in this case on main datasource.

Creates a sub data source using the current node (record) as the root of the document. An additional XPath expression specifies the select criteria applied to this new document and that produces the nodes (records) for the data source.

current node, is bold because this is our first issue, your current main XPath query /data/invoice is too deep since we want to create a datasource on data/invoice_items

Solution

  1. Select only data in main XPath query both in php and jrxml.

    <queryString language="XPath">
        <![CDATA[/data]]>
    </queryString>
    
  2. Adjust your main fields accordingly, you need to navigate down to invoice see fieldDescription.

    <field name="Seller_Name" class="java.lang.String">
        <property name="net.sf.jasperreports.xpath.field.expression" value="Seller_Name"/>
        <fieldDescription><![CDATA[invoice/Seller_Name]]></fieldDescription>
    </field>
    
  3. Create the subDataSource for the table

    <datasetRun subDataset="Factura_pozitii" uuid="8a5ec067-61b0-4580-8aee-4fe353996db3">
         .. params ..
         <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/data/invoice_items/row")]]></dataSourceExpression>
    </datasetRun>
    

Complete 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="Factura" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="153c2ff6-b65d-49fa-80de-5c1a093eafcc">
    <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="Factura_pozitii" uuid="1ee50e5a-b071-4886-8407-2ac843fb9ad1">
        <queryString language="XPath">
            <![CDATA[/data/invoice_items/row]]>
        </queryString>
        <field name="ID_Invoice_Row" class="java.lang.Integer">
            <property name="net.sf.jasperreports.xpath.field.expression" value="ID_Invoice_Row"/>
            <fieldDescription><![CDATA[ID_Invoice_Row]]></fieldDescription>
        </field>
        <field name="Denumire" class="java.lang.String">
            <property name="net.sf.jasperreports.xpath.field.expression" value="Denumire"/>
            <fieldDescription><![CDATA[Denumire]]></fieldDescription>
        </field>
        <field name="Valoare" class="java.lang.Float">
            <property name="net.sf.jasperreports.xpath.field.expression" value="Valoare"/>
            <fieldDescription><![CDATA[Valoare]]></fieldDescription>
        </field>
        <field name="VAT" class="java.lang.Float">
            <property name="net.sf.jasperreports.xpath.field.expression" value="VAT"/>
            <fieldDescription><![CDATA[VAT]]></fieldDescription>
        </field>
        <field name="TOTAL" class="java.lang.Float">
            <property name="net.sf.jasperreports.xpath.field.expression" value="TOTAL"/>
            <fieldDescription><![CDATA[TOTAL]]></fieldDescription>
        </field>
    </subDataset>
    <queryString language="XPath">
        <![CDATA[/data]]>
    </queryString>
    <field name="Seller_Name" class="java.lang.String">
        <property name="net.sf.jasperreports.xpath.field.expression" value="Seller_Name"/>
        <fieldDescription><![CDATA[invoice/Seller_Name]]></fieldDescription>
    </field>
    <columnHeader>
        <band height="34" splitType="Stretch">
            <textField>
                <reportElement x="90" y="0" width="175" height="15" uuid="e9843cbc-f80d-4d43-ba3e-12abb7c1ed11"/>
                <textFieldExpression><![CDATA[$F{Seller_Name}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="0" width="80" height="15" uuid="449ed594-81b1-420c-b361-55709bd951c7"/>
                <text><![CDATA[Seller name:]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="92" splitType="Stretch">
            <componentElement>
                <reportElement x="0" y="0" width="555" height="60" uuid="93a83571-11ee-4173-9726-846f15cbdfec"/>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" whenNoDataType="Blank">
                    <datasetRun subDataset="Factura_pozitii" uuid="8a5ec067-61b0-4580-8aee-4fe353996db3">
                        <datasetParameter name="XML_DATE_PATTERN">
                            <datasetParameterExpression><![CDATA[$P{XML_DATE_PATTERN}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="XML_NUMBER_PATTERN">
                            <datasetParameterExpression><![CDATA[$P{XML_NUMBER_PATTERN}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="XML_LOCALE">
                            <datasetParameterExpression><![CDATA[$P{XML_LOCALE}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="XML_TIME_ZONE">
                            <datasetParameterExpression><![CDATA[$P{XML_TIME_ZONE}]]></datasetParameterExpression>
                        </datasetParameter>
                        <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/data/invoice_items/row")]]></dataSourceExpression>
                    </datasetRun>
                    <jr:column width="40" uuid="d360ed7c-1960-426e-8541-07a125682d7e">
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="Table_TD" height="15">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField>
                                <reportElement x="0" y="0" width="40" height="15" uuid="cdea816f-81e3-4b32-bec6-7791d9862c37"/>
                                <box>
                                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="400" uuid="042fc8f1-a37e-412f-a4e8-f6f747d3054c">
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="400" height="30" uuid="015596ef-4660-4c7f-9b6d-96b6ddf3858d"/>
                                <text><![CDATA[Denumire]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="15">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField isStretchWithOverflow="true">
                                <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="400" height="15" isPrintWhenDetailOverflows="true" uuid="983e6d52-1734-4ace-b791-ec8cfc03cf7c"/>
                                <box>
                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textFieldExpression><![CDATA[$F{Denumire}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="50" uuid="69c6f7bc-1e99-4ced-afcd-adfc2d8930a9">
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="50" height="30" uuid="0aa9d86a-dda0-469d-9923-b3d1e996b583"/>
                                <text><![CDATA[valoare]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="15">
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField pattern="#,##0.###">
                                <reportElement x="0" y="0" width="50" height="15" uuid="11006503-d218-4a64-b8d4-240f611c4727"/>
                                <box>
                                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textFieldExpression><![CDATA[$F{Valoare}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
</jasperReport>


来源:https://stackoverflow.com/questions/57459716/how-to-use-multiple-xpath-datasets-on-xml-datasource-using-php-jasper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!