Referencing ancestor nodes in an XML datasource

2

The documentaion on XML datasources says:

To move to the parent value of the current node (for example, to determine the category to which a person belongs), use a slightly different syntax:

ancestor::category/@name

The ancestor keyword indicates that you are referring to a parent node of the current node;

A simplified example of the data is as follows:

<data>
  <meta>
    <unrelated>
      <id>18</id>
      <description>description</description>
      <year>2014</year>
      <code>2014GBN</code>
    </unrelated>
    <different>
      <id>3</id>
      <label>My label</label>
    </different>
  </meta>
  <person>
    <id>1308</id>
    <code>Amj/3177</code>
    <surname>Amj</surname>
    <firstname>Jbswjt</firstname>
    <middlename>Pbvm</middlename>
    <gender>m</gender>
    .....
    <username>jbswjt/bmj</username>
    <parent_node>
      <id>1467</id>
      <title>A title</title>
      <priority>99</priority>
      <code>09EN</subject_code>
      <id>109</subject_id>
      <description>English</subject_description>
      <department_code>6</subject_department_code>
      <node>
        <id>39480</id>
        <template_id>1</template_id>
        <different_id>3</different_id>
        <unrelated_id>18</unrelatedid>
        ....
      </node>
    </parent_node>
    <parent_node>
      ....
      <node>
        ....
      </node>
    </parent_node>
  </person>
</data>

How do you reference an element that is in an "unrelated" node? i.e. how do I reference /data/meta/unrelated/code from node ?

The datasource for the subreport is:

<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("person[id]/parent_node/node")]]></dataSourceExpression>

Any assistance would be greatly appreciated.

garry_3's picture
13
Joined: Jan 3 2016 - 11:53pm
Last seen: 1 year 9 months ago

0 Answers:

No answers yet
Feedback
randomness