Jump to content
Changes to the Jaspersoft community edition download ×

Report layout using XMLDatasource


2004 IR Help

Recommended Posts

By: java123 - mcevikce

Report layout using XMLDatasource

2005-07-07 07:06

I am trying to read tags and populate each value to individual columns. Here the part of XML that I am trying to read:

 

<row >

<data col_tag="1M">3.2363</data>

<data col_tag="3M">3.4137</data>

<data col_tag="6M">5.0565</data>

<data col_tag="1Yr">3.5350</data>

<data col_tag="2Yr">3.7080</data>

<data col_tag="3Yr">3.7780</data>

</row>

 

I want to assign these values to following columns:

 

1M 3M 6M 1Yr 2Yrs 3Yrs

 

 

 

Part of my .jrxml file:

 

This is how I read the values.

 

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

<fieldDescription><![CDATA[/row/data]]></fieldDescription>

</field>

 

I have columns defined in the header section.Static columns names. Those are fine.

 

 

Now in the detail section I want to assign all the individual data to corresponding column.

 

If I do the following only one value is read:

This is part of my .jrxml file.....

<detail>

<band height="15">

<elementGroup>

<textField>

<reportElement x="0" y="0" width="100" height="15" isPrintWhenDetailOverflows="true"/>

<textElement>

<font reportFont="Arial_Bold"/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{col_tag}]]></textFieldExpression>

</textField>

<textField>

<reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="100" y="0" width="100" height="15"/>

<box leftBorder="Thin" leftPadding="10" bottomBorder="Thin"/>

<textElement/>

<textFieldExpression class="java.lang.String"><![CDATA[$F{col_tag}]]></textFieldExpression>

</textField>

 

 

This outputs the following:

 

1M 3M 6M 1Yr 2Yrs 3Yrs

3.2363 3.2363 3.2363 3.2363 3.2363 3.2363

 

Now the question is how can I make this so each value for data tag can be read. Obviously ![CDATA[$F{col_tag} doesn't do the job.

 

Your help is appriciated.

 

Thank you in advance.

 

 

 

 

By: Harlequin - di0hank

RE: Report layout using XMLDatasource

2005-07-07 23:59

Hi, how about trying to use the col_tag attribute when selecting the data, should be able to if the select ? You could try creating several fields, like this:

 

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

<fieldDescription><![CDATA[/data[@col_tag='1M]]]></fieldDescription>

</field>

 

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

<fieldDescription><![CDATA[/data[@col_tag=3M]]]></fieldDescription>

</field>

 

And then using them like this...

 

<detail>

<band height="15">

<elementGroup>

<textField>

<reportElement x="0" y="0" width="100" height="15" isPrintWhenDetailOverflows="true"/>

<textElement>

<font reportFont="Arial_Bold"/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{col_tag1m}]]></textFieldExpression>

</textField>

<textField>

<reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="100" y="0" width="100" height="15"/>

<box leftBorder="Thin" leftPadding="10" bottomBorder="Thin"/>

<textElement/>

<textFieldExpression class="java.lang.String"><![CDATA[$F{col_tag3M}]]></textFieldExpression>

</textField>

 

Also, make sure that the XPath-expression for the report ends with the element you want repeated in the detail band. In this case I guess that is '/row'.

 

Just a little suggestion, haven't tried it but I hope it helps...

 

Good luck!

 

/Hanna

 

(for some helpful (?) examples on XPaths http://www.zvon.org/xxl/XPathTutorial/General/examples.html )

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...