2004 IR Help Posted August 22, 2006 Share Posted August 22, 2006 By: net ma - net_ma XMLDatasource fieldDescription 2005-07-05 07:58 Hi, I understand for XMLDatasource, fieldDescription is used to select the feild records. I tried some xmldatasource similar with northwind.xml in sample xmldatasource coming with jasperreports-0.6.8 source package, it works fine. But when I adjusted the source xml to a different tree structure (shown below), it only picked up the first note element given in the fieldDescription. Now here is the example xml datasource: <DS> <DSRows> <ID>1</ID> <R> </DSRows> <DSSub> <ID>1</ID> <SubRows> <A> <B> <C> </SubRows> <SubRows> <A> <B> <C> </SubRows> <SubTotals> <A> <B> <C> </SubTotals> <SubTotals> <A> <B> <C> </SubTotals> </DSSub> </DS> And I used such selection in subreport <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).dataSource("/DS/DSSub[iD=" + $F{ID} + "]")]]></dataSourceExpression> In subreport, I'd like to, for example, select element <A> under <SubRows> and <SubTotals>, respectively. So I define two fields as <field name="SubRowsA" class="java.lang.String"> <fieldDescription>SubRows/A</fieldDescription> </field> <field name="SubTotalsA" class="java.lang.String"> <fieldDescription>SubTotals/A</fieldDescription> </field> As a result, they only pick up the first element at <SubRows/A> and <SubTotals/A>, respectively. Could anybody point out to me what I am supposed to do to have all records selected under one <DSSub>? Thank you a lot. ma By: Harlequin - di0hank RE: XMLDatasource fieldDescription 2005-07-06 07:07 Hi, I belive that your problem comes from the XPath in your datasource expression ("/DS/DSSub[iD=" + $F{ID} + "]") and that you want to display two different kinds of elements (SubRows and SubTotals). Having this XPath means that all DSSub elements will be displayed in the detail band and there is only one such element. In order to display the SubRows and SubTotal you might need a common name for them and then have the XPath target that name. Not sure how to fit the ID into such an XPath. Good luck! /Hanna Karlsson 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