How to connect content page in a report book with XML data source?

0

Hi everyone,

I am trying to use the ‘AddressBook’ example XML file as a data source for generating PDF report and I want to use a report book template to have a cover page for my report. My problem is that the final report only shows my cover page and it does not display the content page. How I should connect the content page in the main report so that its content can be displayed?

I have tried an example using the sql database, and it shows the content with no problem. However, I cannot manage to do the same with XML data source.

Thanks in advance for your help.

Kind regards,
Mohammad

 

Here is the code of my content page:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->

<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="SampleXMLReport_Content" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0c0bcffa-a833-46bc-948c-4dcf12a320a4">

       <property name="com.jaspersoft.studio.data.defaultdataadapter" value="AddressBookDataAdapter"/>

       <queryString language="xPath">

              <![CDATA[/addressbook/category/person]]>

       </queryString>

       <field name="id" class="java.lang.Integer">

              <property name="net.sf.jasperreports.xpath.field.expression" value="@id"/>

              <fieldDescription><![CDATA[@id]]></fieldDescription>

       </field>

       <field name="lastname" class="java.lang.String">

              <property name="net.sf.jasperreports.xpath.field.expression" value="lastname"/>

              <fieldDescription><![CDATA[lastname]]></fieldDescription>

       </field>

       <field name="firstname" class="java.lang.String">

              <property name="net.sf.jasperreports.xpath.field.expression" value="firstname"/>

              <fieldDescription><![CDATA[firstname]]></fieldDescription>

       </field>

       <field name="email" class="java.lang.String">

              <property name="net.sf.jasperreports.xpath.field.expression" value="email"/>

              <fieldDescription><![CDATA[email]]></fieldDescription>

       </field>

       <background>

              <band splitType="Stretch"/>

       </background>

       <columnHeader>

              <band height="48" splitType="Stretch">

                     <staticText>

                           <reportElement x="10" y="10" width="100" height="30" uuid="0f550c86-012e-452c-9e6b-936d1a912fe6">

                                  <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="0b9c621a-4341-4bf6-8edd-ad0f18988df3"/>

                           </reportElement>

                           <text><![CDATA[id]]></text>

                     </staticText>

                     <staticText>

                           <reportElement x="120" y="10" width="100" height="30" uuid="80763a1b-583d-48e2-beba-9e229128f033">

                                  <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d8fead41-5697-4811-beab-21422221daa3"/>

                           </reportElement>

                           <text><![CDATA[lastname]]></text>

                     </staticText>

                     <staticText>

                           <reportElement x="230" y="10" width="100" height="30" uuid="03fb803e-12a2-40b9-a847-afb064a625f8">

                                  <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="3eaacca1-2a73-4408-ad47-9365482e73a1"/>

                           </reportElement>

                           <text><![CDATA[firstname]]></text>

                     </staticText>

                     <staticText>

                           <reportElement x="340" y="10" width="100" height="30" uuid="0cddf3d3-9eb2-4ec0-86fd-7a422e10d43c">

                                  <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="03b21eb4-6a25-4b18-a090-2640bc222c43"/>

                           </reportElement>

                           <text><![CDATA[email]]></text>

                     </staticText>

              </band>

       </columnHeader>

       <detail>

              <band height="47" splitType="Stretch">

                     <textField>

                           <reportElement x="10" y="10" width="100" height="30" uuid="2d18555d-edf5-4b58-b650-5b754cde9019">

                                  <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="0b9c621a-4341-4bf6-8edd-ad0f18988df3"/>

                           </reportElement>

                           <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>

                     </textField>

                     <textField>

                           <reportElement x="120" y="10" width="100" height="30" uuid="49258f9f-8c56-4b78-a899-7745a617ec22">

                                  <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d8fead41-5697-4811-beab-21422221daa3"/>

                           </reportElement>

                           <textFieldExpression><![CDATA[$F{lastname}]]></textFieldExpression>

                     </textField>

                     <textField>

                           <reportElement x="230" y="10" width="100" height="30" uuid="b257dc61-2c5c-4786-86c1-3cb285ad976f">

                                  <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="3eaacca1-2a73-4408-ad47-9365482e73a1"/>

                           </reportElement>

                           <textFieldExpression><![CDATA[$F{firstname}]]></textFieldExpression>

                     </textField>

                     <textField>

                           <reportElement x="340" y="10" width="100" height="30" uuid="913cbea8-3576-46e8-a4e8-664c4dec87c6">

                                  <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="03b21eb4-6a25-4b18-a090-2640bc222c43"/>

                           </reportElement>

                           <textFieldExpression><![CDATA[$F{email}]]></textFieldExpression>

                     </textField>

              </band>

       </detail>

</jasperReport>

 

 

 

And here is the code for my main report:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->

<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="Sample_AddressBook" pageWidth="595" pageHeight="842" sectionType="Part" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" uuid="d2716064-8ae4-40cf-a575-33afba400e3a">

       <property name="com.jaspersoft.studio.data.defaultdataadapter" value="AddressBookDataAdapter"/>

       <property name="net.sf.jasperreports.print.create.bookmarks" value="true"/>

       <property name="com.jaspersoft.studio.book.group.cover.header" value="Cover and Table of Contents"/>

       <property name="com.jaspersoft.studio.book.group.cover.footer" value="Backcover"/>

       <queryString language="xPath">

              <![CDATA[/addressbook/category/person]]>

       </queryString>

       <field name="id" class="java.lang.Integer">

              <property name="net.sf.jasperreports.xpath.field.expression" value="@id"/>

              <fieldDescription><![CDATA[@id]]></fieldDescription>

       </field>

       <field name="lastname" class="java.lang.String">

              <property name="net.sf.jasperreports.xpath.field.expression" value="lastname"/>

              <fieldDescription><![CDATA[lastname]]></fieldDescription>

       </field>

       <field name="firstname" class="java.lang.String">

              <property name="net.sf.jasperreports.xpath.field.expression" value="firstname"/>

              <fieldDescription><![CDATA[firstname]]></fieldDescription>

       </field>

       <field name="email" class="java.lang.String">

              <property name="net.sf.jasperreports.xpath.field.expression" value="email"/>

              <fieldDescription><![CDATA[email]]></fieldDescription>

       </field>

       <group name="cover">

              <groupHeader>

                     <part uuid="7aed05b9-1301-4a53-b47e-34289560bc0c">

                           <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">

                                  <subreportExpression><![CDATA["Sample_AddressBook_cover.jasper"]]></subreportExpression>

                           </p:subreportPart>

                     </part>

              </groupHeader>

       </group>

       <detail>

              <part uuid="a13ebcac-24f9-4e8e-a29f-198b96c1edcb">

                     <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">

                           <subreportParameter name="REPORT_DATA_SOURCE">

                           <subreportParameterExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/addressbook/category/person")]]></subreportParameterExpression>

                           </subreportParameter>

                            <subreportExpression><![CDATA["SampleXMLReport_Content.jasper"]]></subreportExpression>

                     </p:subreportPart>

              </part>

       </detail>

</jasperReport>

smnabavieh's picture
Joined: Jul 4 2018 - 12:59am
Last seen: 1 year 4 months ago

0 Answers:

No answers yet
Feedback
randomness