Xpath failure where XML consists of a list of lists

0

Hi,

I'm working with studio 6.1 and trying to generate a series of chart/table pairs. Each chart and table will use the same recordset.

My first step is to come up with an XML structure that serves both purposes. Essentially I have a list of records; each record contains a few  preamble nodes, followed by a list of data nodes. The snippet below captures what I'm currently working with.

<data>
    <top_level>Blah</top_level>
    <records>
        <record>
            <preamble>Blah</preamble>
            <more_preamble>Blah</more_preamble>
            <dateset>
                <month>Jan</month>
                <data attrib="A">10</data>
                <data attrib="B">40</data>
                <data attrib="C">20</data>
                <data attrib="D">60</data>
            </dataset>
            <dateset>
                <month>Feb</month>
                <data attrib="A">30</data>
                <data attrib="B">60</data>
                <data attrib="C">80</data>
                <data attrib="D">10</data>
            </dataset>
            <dateset>
                <month>Mar</month>
                <data attrib="A">70</data>
                <data attrib="B">90</data>
                <data attrib="C">100</data>
                <data attrib="D">20</data>
            </dataset>
        </record>
        <record>
            <dateset>
                <month>Aug</month>
                <data attrib="A">90</data>
                <data attrib="B">40</data>
                <data attrib="C">70</data>
                <data attrib="D">20</data>
            </dataset>
            <dateset>
                <month>Sep</month>
                <data attrib="A">60</data>
                <data attrib="B">70</data>
                <data attrib="C">10</data>
                <data attrib="D">20</data>
            </dataset>
            <dateset>
                <month>Oct</month>
                <data attrib="A">20</data>
                <data attrib="B">10</data>
                <data attrib="C">0</data>
                <data attrib="D">60</data>
            </dataset>
        </record>
    </records>
</data>

To start with I've created a subreport and placed a chart in the detail band. Setting the record node to /data/records/record would enable me to create one chart per record. The fields are defined as follows:

preamble: preamble
more_preamble: more_preamble
month: //dateset/month
typeA: //dateset/data[@="A"]
typeB: //dateset/data[@="B"]
typeC: //dateset/data[@="C"]
typeD: //dateset/data[@="D"]

I'm using a stacked bar chart with Series A, B, C, and D; Category is set to $F{month} and value set to $F{typeA}, $F{typeB},$F{typeC},$F{typeD} respectively. I have also tried .//dataset... which make no difference.

What I get when I preview are 2 charts where each contains the first dateset from record 1 and the first dataset from record 2. Presumably, if I had a third record, it's first record would also be displayed.

I have a couple of questions:
1. Is there a better XML structure I should be using? What I have is easy to read but possibly isn't optimal when it come to charts and tables.
2. Can anyone explain what the heck is going on with my current setup? I can't understand why the xpath expressions fail.

Cheers

Chris

cbrown_1's picture
Joined: Apr 14 2015 - 11:19pm
Last seen: 2 months 1 week ago

0 Answers:

No answers yet
Feedback