youbarb Posted November 17, 2008 Share Posted November 17, 2008 Hi,I've designed a main report with a subreport using this tutorial :http://ireport.sourceforge.net/cap7.htmlThe XML source is the same for the 2 reports (see XML and JRXML files below).As said in the tutorial, I create a Field type "object " with Xpath to the datasource in the description.I use this field as datasource expression for connection of the subreport.The subreport is working well alone.The main report working well too but there's no data in the area of the subreport. Even the static text I put in the subreport detail area.Could someone help me please ?Here's the XML datasource (soory but it's in french language):<?xml version="1.0" encoding="ISO-8859-1" ?><ListeAttestation> <UneAttestation> <sSociete>STRUCTIS</sSociete> <sNumvoi>1</sNumvoi> <sNomvoi>AVENUE EUGENE FREYSSINET</sNomvoi> <sCpladr>CHALLENGER</sCpladr> <sCodpos>78280</sCodpos> <sCommune>GUYANCOURT</sCommune> <sQualit>Madame</sQualit> <sNomuse>BERTHO</sNomuse> <sPrenom>Nathalie</sPrenom> <sNumsec>274042813412867</sNumsec> <sLibcon>Contrat à durée indéterminée</sLibcon> <sLibmut>Gras savoye</sLibmut> <sDatmut>01/01/2006</sDatmut> <nbrenf>3</nbrenf> <Enfant> <sTyppar> </sTyppar> <sNaienf>13/09/1974</sNaienf> <sPreenf>Baptiste</sPreenf> <sNompar>BERTHO</sNompar> </Enfant> <Enfant> <sTyppar> </sTyppar> <sNaienf>07/05/2003</sNaienf> <sPreenf>Manon</sPreenf> <sNompar>BERTHO</sNompar> </Enfant> <Enfant> <sTyppar> </sTyppar> <sNaienf>24/04/1974</sNaienf> <sPreenf>Nathalie</sPreenf> <sNompar>BERTHO</sNompar> </Enfant> <sDatexx> </sDatexx> <sLieuxx> </sLieuxx> </UneAttestation></ListeAttestation> The main report based on "UneAttestation" as datasource :<?xml version="1.0" encoding="UTF-8" ?><!-- Created with iReport - A designer for JasperReports --><!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"><jasperReport name="AttestationMutuelle" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="70" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString language="xPath"><![CDATA[/ListeAttestation/UneAttestation]]></queryString> <field name="sSociete" class="java.lang.String"> <fieldDescription><![CDATA[sSociete]]></fieldDescription> </field> <field name="sNumvoi" class="java.lang.String"> <fieldDescription><![CDATA[sNumvoi]]></fieldDescription> </field> <field name="sNomvoi" class="java.lang.String"> <fieldDescription><![CDATA[sNomvoi]]></fieldDescription> </field> <field name="sCpladr" class="java.lang.String"> <fieldDescription><![CDATA[sCpladr]]></fieldDescription> </field> <field name="sCodpos" class="java.lang.String"> <fieldDescription><![CDATA[sCodpos]]></fieldDescription> </field> <field name="sCommune" class="java.lang.String"> <fieldDescription><![CDATA[sCommune]]></fieldDescription> </field> <field name="sQualit" class="java.lang.String"> <fieldDescription><![CDATA[sQualit]]></fieldDescription> </field> <field name="sNomuse" class="java.lang.String"> <fieldDescription><![CDATA[sNomuse]]></fieldDescription> </field> <field name="sPrenom" class="java.lang.String"> <fieldDescription><![CDATA[sPrenom]]></fieldDescription> </field> <field name="sNumsec" class="java.lang.String"> <fieldDescription><![CDATA[sNumsec]]></fieldDescription> </field> <field name="sLibcon" class="java.lang.String"> <fieldDescription><![CDATA[sLibcon]]></fieldDescription> </field> <field name="sLibmut" class="java.lang.String"> <fieldDescription><![CDATA[sLibmut]]></fieldDescription> </field> <field name="sDatmut" class="java.lang.String"> <fieldDescription><![CDATA[sDatmut]]></fieldDescription> </field> <field name="nbrenf" class="java.lang.String"> <fieldDescription><![CDATA[nbrenf]]></fieldDescription> </field> <field name="sDatexx" class="java.lang.String"> <fieldDescription><![CDATA[sDatexx]]></fieldDescription> </field> <field name="sLieuxx" class="java.lang.String"> <fieldDescription><![CDATA[sLieuxx]]></fieldDescription> </field> <field name="Enfant" class="java.lang.Object"> <fieldDescription><![CDATA[ListeAttestation/UneAttestation/Enfant]]></fieldDescription> </field> <variable name="Today" class="java.lang.String" resetType="Report" calculation="Nothing"> <variableExpression><![CDATA[(new SimpleDateFormat("dd/MM/yyyy")).format(new Date())]]></variableExpression> </variable> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="736" isSplitAllowed="true" > <staticText> <reportElement x="25" y="94" width="87" height="18" key="staticText-1"/> <box></box> <textElement> <font/> </textElement> <text><![CDATA[Nous soussignés,]]></text> </staticText> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="121" y="94" width="250" height="18" key="textField-1"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{sSociete}]]></textFieldExpression> </textField> <staticText> <reportElement x="25" y="126" width="87" height="18" key="staticText-2"/> <box></box> <textElement> <font/> </textElement> <text><![CDATA[sise]]></text> </staticText> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="121" y="126" width="250" height="18" key="textField-2"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{sNumvoi}+" "+$F{sNomvoi}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="121" y="151" width="100" height="18" key="textField-3"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{sCpladr}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="121" y="176" width="250" height="18" key="textField-4"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{sCodpos}+" "+$F{sCommune}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="32" y="206" width="346" height="18" key="textField-5"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["Certifions que : "+$F{sQualit}+" "+$F{sNomuse}+" "+$F{sPrenom}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="87" y="231" width="134" height="18" key="textField-6"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["N° SS : "+$F{sNumsec}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="32" y="258" width="445" height="34" key="textField-7"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["Est employé(e) dans notre société en "+$F{sLibcon}+", est affilié(e) au régime obligatoire de notre mutuelle "+$F{sLibmut}+" depuis le "+$F{sDatmut}+"."]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="32" y="520" width="445" height="28" key="textField-10"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["En foi de quoi la présente attestation est délivrée pour servir et valoir ce que de droit"]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="228" y="563" width="249" height="30" key="textField-11"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["à "+(($F{sLieuxx}.equals(" "))? "Guyancourt" : $F{sLieuxx} )+", le "+(($F{sDatexx}.equals(" "))? $V{Today} : $F{sDatexx})]]></textFieldExpression> </textField> <staticText> <reportElement x="25" y="10" width="452" height="43" forecolor="#009999" key="staticText-3"/> <box></box> <textElement> <font fontName="Calibri" size="26" isBold="false"/> </textElement> <text><![CDATA[ATTESTATION D'ADHESION MUTUELLE]]></text> </staticText> <staticText> <reportElement x="228" y="699" width="237" height="23" key="staticText-4"/> <box></box> <textElement> <font/> </textElement> <text><![CDATA[DIRECTION DES RESSOURCES HUMAINES]]></text> </staticText> <staticText> <reportElement x="32" y="297" width="445" height="21" key="staticText-5"/> <box></box> <textElement> <font/> </textElement> <text><![CDATA[Les bénéficiaires désignés sont :]]></text> </staticText> <subreport isUsingCache="false"> <reportElement x="32" y="323" width="445" height="190" key="subreport-1"/> <dataSourceExpression><![CDATA[$F{Enfant}]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA["/test.jasper"]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary></jasperReport> And the subreport :<?xml version="1.0" encoding="UTF-8" ?><!-- Created with iReport - A designer for JasperReports --><!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"><jasperReport name="test" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString language="xPath"><![CDATA[/ListeAttestation/UneAttestation/Enfant]]></queryString> <field name="sTyppar" class="java.lang.String"> <fieldDescription><![CDATA[sTyppar]]></fieldDescription> </field> <field name="sNaienf" class="java.lang.String"> <fieldDescription><![CDATA[sNaienf]]></fieldDescription> </field> <field name="sPreenf" class="java.lang.String"> <fieldDescription><![CDATA[sPreenf]]></fieldDescription> </field> <field name="sNompar" class="java.lang.String"> <fieldDescription><![CDATA[sNompar]]></fieldDescription> </field> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="32" isSplitAllowed="true" > <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="111" y="3" width="100" height="18" key="textField"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{sTyppar}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="426" y="3" width="100" height="18" key="textField"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{sNaienf}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="216" y="3" width="100" height="18" key="textField"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{sNompar}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="321" y="3" width="100" height="18" key="textField"/> <box></box> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{sPreenf}]]></textFieldExpression> </textField> <staticText> <reportElement x="7" y="3" width="83" height="25" key="staticText-5"/> <box></box> <textElement> <font/> </textElement> <text><![CDATA[sous-rapport]]></text> </staticText> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary></jasperReport> Thanks for ur help.Youenn Link to comment Share on other sites More sharing options...
youbarb Posted November 25, 2008 Author Share Posted November 25, 2008 up ! Link to comment Share on other sites More sharing options...
PlexPro Posted November 25, 2008 Share Posted November 25, 2008 Bonjour,You specified a data source for the subreport to be the object: <dataSourceExpression><![CDATA[$F{Enfant}]]></dataSourceExpression> Replace that with <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//Enfant")]]></dataSourceExpression> That worked for me! I thought perhaps specifying it thusly would work: ((net.sf.jasperreports.engine.data.JRXmlDataSource)$F{Enfant})or((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource($F{Enfant}) but these did not work. I was thinking that there were a means of using the node defined as field $F{Enfant}, but I'm not finding documentation on it at the moment. René youbarbWrote: Hi, I've designed a main report with a subreport using this tutorial : http://ireport.sourceforge.net/cap7.html The XML source is the same for the 2 reports (see XML and JRXML files below). As said in the tutorial, I create a Field type "object " with Xpath to the datasource in the description. I use this field as datasource expression for connection of the subreport. The subreport is working well alone. The main report working well too but there's no data in the area of the subreport. Even the static text I put in the subreport detail area. Could someone help me please ? Here's the XML datasource (soory but it's in french language): ... The main report based on "UneAttestation" as datasource : <?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="AttestationMutuelle" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="70" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString language="xPath"><![CDATA[/ListeAttestation/UneAttestation]]></queryString> ... <detail> <band height="736" isSplitAllowed="true" > ... <subreport isUsingCache="false"> <reportElement x="32" y="323" width="445" height="190" key="subreport-1"/> <dataSourceExpression><![CDATA[$F{Enfant}]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA["/test.jasper"]]></subreportExpression> </subreport> </band> </detail> ... </jasperReport> And the subreport : ... Thanks for ur help. Youenn Post Edited by René Valencourt at 11/26/08 13:54 Link to comment Share on other sites More sharing options...
youbarb Posted March 10, 2009 Author Share Posted March 10, 2009 Hi, sorry to be sooooo late but I just come to visit the website today. I immediatly test ur solution. It's working so well !! Thank you verry much. best regards. Youenn Link to comment Share on other sites More sharing options...
daiana Posted October 18, 2010 Share Posted October 18, 2010 I've had a similar problem, and thanks to that I could fix it.Thanks so much! Link to comment Share on other sites More sharing options...
pikehunter Posted August 13, 2012 Share Posted August 13, 2012 HelloI have same problem. I tried to use datasource expression((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//root") but it does not work for me.My source xml:<?xml version="1.0" encoding="UTF-8"?><root> <client> <addressbook> <person> <name>ETHAN</name> <phone type="mobile">+1 (415) 111-1111</phone> <phone type="home">+1 (415) 111-1112</phone> <phone type="work">+1 (415) 111-1113</phone> <phone type="fax">+1 (415) 111-1114</phone> </person> <person> <name>CALEB</name> <phone type="mobile">+1 (415) 222-2222</phone> <phone type="home">+1 (415) 222-2223</phone> </person> <person> <name>WILLIAM</name> <phone type="work">+1 (415) 333-3333</phone> <phone type="mobile">+1 (415) 333-3334</phone> </person> </addressbook> </client></root>my report:<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="" xmlns:xsi="" xsi:schemaLocation="" name="null" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d36cca6a-bfcb-43aa-9c27-b52814c61e45"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <style name="Crosstab Data Text" hAlign="Center"/> <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA["C:\Documents and Settings\iam\docs\NetBeansProjects\JavaFXApplication2\src\javafxapplication2\"]]></defaultValueExpression> </parameter> <queryString language="xPath"> <![CDATA[/root/client/addressbook/person]]> </queryString> <field name="name" class="java.lang.String"> <fieldDescription><![CDATA[name]]></fieldDescription> </field> <variable name="variable1" class="java.lang.String" calculation="Sum"> <variableExpression><![CDATA[$F{name}]]></variableExpression> </variable> <background> <band splitType="Stretch"/> </background> <title> <band height="221" splitType="Stretch"> <textField isStretchWithOverflow="true" pattern=""> <reportElement uuid="98a21be7-c050-4688-88bf-c6a4bbbdb98b" x="136" y="22" width="406" height="48"/> <textElement/> <textFieldExpression><![CDATA[$P{SUBREPORT_DIR}]]></textFieldExpression> </textField> <textField> <reportElement uuid="8d420d99-bf88-47f2-a3b6-a5484f7df10a" x="136" y="90" width="419" height="20"/> <textElement/> <textFieldExpression><![CDATA[""+$P{REPORT_DATA_SOURCE}]]></textFieldExpression> </textField> <textField> <reportElement uuid="475b2437-18b7-4a78-8a4b-3397d7db2675" x="136" y="130" width="419" height="20"/> <textElement/> <textFieldExpression><![CDATA[""+$P{JASPER_REPORT}]]></textFieldExpression> </textField> <textField> <reportElement uuid="7386cd54-d1fd-4ea0-a676-cf6357f4fa27" x="136" y="170" width="419" height="20"/> <textElement/> <textFieldExpression><![CDATA[""+$P{REPORT_SCRIPTLET}]]></textFieldExpression> </textField> <textField> <reportElement uuid="e4b09a10-3de5-4a22-9515-e3c1dfab1138" x="136" y="190" width="419" height="20"/> <textElement/> <textFieldExpression><![CDATA[""+$P{XML_DATA_DOCUMENT}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="b36ad160-d29d-4329-8f84-fb98fe529eed" x="0" y="22" width="136" height="48"/> <textElement/> <text><![CDATA[sUBREPORT_DIR]]></text> </staticText> <staticText> <reportElement uuid="06681c86-2ae4-4c58-b5b4-66a407254b55" x="0" y="90" width="136" height="20"/> <textElement/> <text><![CDATA[REPORT_DATA_SOURCE]]></text> </staticText> <staticText> <reportElement uuid="e6d29eea-cfc0-427f-a693-e5541317172d" x="0" y="130" width="136" height="20"/> <textElement/> <text><![CDATA[JASPER_REPORT]]></text> </staticText> <staticText> <reportElement uuid="7a8e6ec6-2597-4555-a2f3-84df04a5f380" x="0" y="170" width="136" height="20"/> <textElement/> <text><![CDATA[REPORT_SCRIPTLET]]></text> </staticText> <staticText> <reportElement uuid="de796f97-9b5f-4b55-80a1-a74e39047820" x="0" y="190" width="136" height="20"/> <textElement/> <text><![CDATA[xml_DATA_DOCUMENT]]></text> </staticText> <staticText> <reportElement uuid="d8fb93ff-7736-4ddf-96b4-331c4cc1724c" x="0" y="108" width="136" height="22"/> <textElement/> <text><![CDATA[xmlinputstream]]></text> </staticText> <staticText> <reportElement uuid="ecf3e935-3f30-46e9-8188-280926a39e6f" x="0" y="150" width="136" height="20"/> <textElement/> <text><![CDATA[xmlfile]]></text> </staticText> <staticText> <reportElement uuid="c88a8f4b-9c3b-4dec-826f-5f64d6133514" x="0" y="70" width="136" height="20"/> <textElement/> <text><![CDATA[static text]]></text> </staticText> <textField> <reportElement uuid="817c6d10-f7f0-4f83-b05a-b109f6bee3e1" x="136" y="110" width="269" height="20"/> <textElement/> <textFieldExpression><![CDATA[""+$P{XML_INPUT_STREAM}]]></textFieldExpression> </textField> <textField> <reportElement uuid="84d36ac2-563e-404f-b085-0eb2228c1922" x="136" y="150" width="269" height="20"/> <textElement/> <textFieldExpression><![CDATA[""+$P{XML_FILE}]]></textFieldExpression> </textField> <textField> <reportElement uuid="dea099c6-8427-4d6a-8289-e83c912e3e50" x="136" y="70" width="269" height="20"/> <textElement/> <textFieldExpression><![CDATA[$P{net.sf.jasperreports.xml.source}]]></textFieldExpression> </textField> </band> </title> <pageHeader> <band height="16" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="32" splitType="Stretch"> <staticText> <reportElement uuid="c92adb6e-000c-493e-8caa-652853ba3d4d" x="0" y="0" width="119" height="21"/> <textElement> <font size="16" isBold="true" isItalic="true"/> </textElement> <text><![CDATA[name]]></text> </staticText> <staticText> <reportElement uuid="59135814-29b4-470e-a1ab-6079dcd596e2" x="119" y="0" width="143" height="21"/> <textElement> <font size="16" isBold="true" isItalic="true"/> </textElement> <text><![CDATA[detail]]></text> </staticText> </band> </columnHeader> <detail> <band height="140" splitType="Stretch"> <textField> <reportElement uuid="1cd80a8e-0433-460b-880d-314569d29763" x="0" y="0" width="119" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> <subreport> <reportElement uuid="53fcae45-4026-4a10-bdc6-139bdf84be68" x="0" y="20" width="555" height="120"/> <subreportParameter name="name"> <subreportParameterExpression><![CDATA[$F{name}]]></subreportParameterExpression> </subreportParameter> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//root")]]></dataSourceExpression> <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "subReport1.jasper"]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="18" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="15" splitType="Stretch"/> </pageFooter> <summary> <band height="13"/> </summary></jasperReport>http://jasperreports.sourceforge.net/xsd/jasperreport.xsdhttp://jasperreports.sourceforge.net/jasperreportshttp://www.w3.org/2001/XMLSchema-instancehttp://jasperreports.sourceforge.net/jasperreportsand subreport:<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="" xmlns:xsi="" xsi:schemaLocation="" name="report name" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d93924a6-3093-4c21-83c1-2f60a0f97807"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="name" class="java.lang.String"> <defaultValueExpression><![CDATA["CALEB"]]></defaultValueExpression> </parameter> <queryString language="xPath"> <![CDATA[/root/client/addressbook/person[./name/text()=$P{name}]/phone]]> </queryString> <field name="type" class="java.lang.String"> <fieldDescription><![CDATA[@type]]></fieldDescription> </field> <field name="phone" class="java.lang.String"> <fieldDescription><![CDATA[child::text()]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="22" splitType="Stretch"> <staticText> <reportElement uuid="7ec0c2ec-19e7-41d3-89a7-dfad639209ec" mode="Opaque" x="0" y="0" width="355" height="22" backcolor="#CCFF00"/> <textElement verticalAlignment="Middle"/> <text><![CDATA[subreport! Contact of person:]]></text> </staticText> <textField> <reportElement uuid="6b060ffe-9a72-4dd2-b3d6-0cdbb09282c9" x="442" y="2" width="100" height="20"/> <textElement/> <textFieldExpression><![CDATA[$P{name}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="2876e193-b617-4f89-8ce5-bb70b83d05ea" x="355" y="2" width="87" height="20"/> <textElement/> <text><![CDATA[parameter name:]]></text> </staticText> </band> </title> <columnHeader> <band height="22"> <staticText> <reportElement uuid="b460bcd8-df59-42dc-b206-239530398b2f" x="0" y="0" width="100" height="20"/> <textElement/> <text><![CDATA[type]]></text> </staticText> <staticText> <reportElement uuid="e77f26ae-f532-4409-8546-de676464e73e" x="100" y="0" width="194" height="20"/> <textElement/> <text><![CDATA[number]]></text> </staticText> </band> </columnHeader> <detail> <band height="22"> <textField> <reportElement uuid="7618919d-2c9d-4352-baf6-2088283d3274" x="0" y="0" width="100" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{type}]]></textFieldExpression> </textField> <textField> <reportElement uuid="18a0ed0e-ad0a-4898-b64f-fc872f97eea4" x="100" y="0" width="194" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{phone}]]></textFieldExpression> </textField> </band> </detail></jasperReport>http://jasperreports.sourceforge.net/xsd/jasperreport.xsdhttp://jasperreports.sourceforge.net/jasperreportshttp://www.w3.org/2001/XMLSchema-instancehttp://jasperreports.sourceforge.net/jasperreports Post Edited by pikehunter at 08/13/2012 08:11 Link to comment Share on other sites More sharing options...
pikehunter Posted August 13, 2012 Share Posted August 13, 2012 It works only if the subreport working with subtree of main xml.datasource expression:((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//phone")and subreport xpath://phone Link to comment Share on other sites More sharing options...
aalya Posted August 22, 2012 Share Posted August 22, 2012 Its really gd....Working properly Link to comment Share on other sites More sharing options...
mnarasimha888 Posted June 25, 2015 Share Posted June 25, 2015 hi i have below mentioned xml file .how to design a report to dispaly result in pdf format.i tried it is displaying all info but total count of pass,failed,skipped,total are not uadating according to test.if any having any idea please let me know. <?xml version="1.0" encoding="UTF-8"?><AutomationResults> <Deatils url="https://10.103.37.167:8443/" browserType="ff" /> <Suite name="IVPCourseCRUD"> <test name="CourseCRUD"> <method name="updateCourse " status="Passed " /> <method name="courseRead " status="Passed " /> <method name="deleteCourse " status="Passed " /> <method name="courseCreation " status="Passed " /> <total totalMethods="4" passed="4" failed="0" skipped="0"/> </test> <test name ="calender CRUD"> <method name="calnderCreation " status="Passed " /> <method name="calenderread" status="Passed " /> <method name="calenderDelete " status="failed " /> <total totalMethods="3" passed="2" failed="1" skipped="0"/> </test> </Suite> <Suite name="IVPUserCRUD"> <test name="UserCRUD "> <method name="userCreation " status="Passed " /> <total totalMethods="1" passed="1" failed="0" skipped="0" /> </test> </Suite> </AutomationResults> in my ireport designer i kept method as root to access xml file. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now