Set variable based on ancestor node in XML datasoure

0

First newbie question ... 3 days in and still grappling with some of the fundamentals .... have searched extensively but have not been able to find what I'm looking for .... hopefully I'm able to articulate what I want in a way that can be understood .....

How do I set a variable in the report that returns the <id> element from an ancestor node in an an XML data source, the selection based on the node with the most recent <date> field in the ancestor node?  

A simplified example of my data source is as follows:

<data>
  <meta>
    <term>
      <code><![CDATA[TERM1]]></code>
      <year><![CDATA[2017]]></year>
      <start><![CDATA[2017-02-01]]></start>
      <description><![CDATA[FIRST TERM DESCRIPTION]]></description>
      <end><![CDATA[2017-06-30]]></end>
      <id><![CDATA[7]]></id>
    </term>
    <term>
        <code><![CDATA[TERM2]]></code>
        <year><![CDATA[2017]]></year>
        <start><![CDATA[2017-07-17]]></start>
        <description><![CDATA[NEXT TERM DESCRIPTION]]></description>
        <end><![CDATA[2017-12-08]]></end>
        <id><![CDATA[9]]></id>
    </term>
    ......
  </meta>
  <student>
    <id><![CDATA[1187]]></id>
    <code><![CDATA[POTTH19]]></code>
    <surname><![CDATA[Potter]]></surname>
    <firstname><![CDATA[Harry]]></firstname>
    ....
    <node>
      <id><![CDATA[1346]]></id>
      <title><![CDATA[Potions]]></title>
       .....
      <childNode>
        <id><![CDATA[54313]]></id>
        <template_id><![CDATA[10]]></template_id>
        <type_id><![CDATA[1]]></type_id>
        <term_id><![CDATA[7]]></term_id>
        ....
      </childNode>
    </node>
    <node>
      <id><![CDATA[1367]]></id>
      <title><![CDATA[History of Magic]]></title>
      ....
      <childNode>
          <id><![CDATA[54453]]></id>
          <template_id><![CDATA[10]]></template_id>
          <type_id><![CDATA[1]]></type_id>
          <term_id><![CDATA[7]]></term_id>
          ....
      </childNode>
    </node>
    .......
    <node>
        <id><![CDATA[1462]]></id>
        <title><![CDATA[Potions]]></title>
        .....
        <childNode>
            <id><![CDATA[54313]]></id>
            <template_id><![CDATA[10]]></template_id>
            <type_id><![CDATA[1]]></type_id>
            <term_id><![CDATA[9]]></term_id>
            ....
        </childNode>
    </node>
    <node>
        <id><![CDATA[1679]]></id>
        <title><![CDATA[History of Magic]]></title>
        ....
        <childNode>
            <id><![CDATA[54453]]></id>
            <template_id><![CDATA[10]]></template_id>
            <type_id><![CDATA[1]]></type_id>
            <term_id><![CDATA[9]]></term_id>
            ....
        </childNode>
    </node>
  </student>
  <student>
      .....
  </student>
  <student>
      .....
  </student>
  <student>
      .....
  </student>
  <student>
      .....
  </student>

The root node of the report is /data/student. Elements at node/childNode/term_id reference /data/meta/term/id.

How do I set a variable "thisTerm" with the value "9" {TERM2 <id>} based on the fact that "TERM2" <end> is greater that "TERM1" <end>?

The idea is that subreports will present child/Node data differnetly based on which term it belongs to ....

Not a developer so also new to the syntax - have never dealt with Java, JavaScript or Groovy ....

Any assistance would be greatly appreciated.

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

0 Answers:

No answers yet
Feedback
randomness