Subject:How can I get a value from the first child node ? Author:Alex Star Date:22 Jun 2007 12:37 PM
In the file below root element <MorganData> has multiple child records where each one is a combination of single <HeaderRecord> and multiple <DataRecord>.
Hovewer, both childs are on the same level.
My question is next: For each <HeaderRecord>, How can I get a value <ClosingBal> from the first child <DataRecord> node only? I do not care about all other nodes, but I need a very first child one.
Subject:How can I get a value from the first child node ? Author:Alex Star Date:25 Jun 2007 05:57 PM
I am trying to build XSLT template and it is not going well so far.
I do not understand how can I call first <DataRecord> node from the inside a <HeaderRecord> loop.
Here is what I got:
Inside first "for-each" I got next data:
<HeaderRecord>
<HeaderRecord>
<HeaderRecord>
<HeaderRecord>
<HeaderRecord>
<HeaderRecord>
I want to call template "firstnode" after the each iterations of the "HeaderRecord".
Next step is to get a value from the very first following <DataRecord> node, so my question is how can I access a its value?
The XPath /ns1:MorganData/HeaderRecord[position()=1]/HeaderRecord_Child1 does not work(it is pointed to the wrong node).
As you said, if file would have a different structude, it would be less difficult.
Hovewer, all "HederRecord" and "DataRecord" are on the same level.
Subject:How can I get a value from the first child node ? Author:Jamil Taylor Date:25 Jun 2007 06:43 PM Originally Posted: 25 Jun 2007 06:39 PM
My apologies. I thought your data was one header record followed by one data record. The position xpath would have worked in this case, if the position was passed as a parameter to another template.
You can still do something similar though. Like this:
This would retrieve the first ClosingBal following the second HeaderRecord, and etc.
So, you can construct a for-each, a template that requires a parameter, pass the position as that parameter, and use a similar xpath as the second example above to retrieve the ClosingBal you are interested in.
Subject:How can I get a value from the first child node ? Author:Alex Star Date:25 Jun 2007 11:18 PM
Thank you for the help. I finally made it work. I found a different solution. I could actually ignore completelly all "HederRecord" nodes since all information is repeted in the trailing "DataRecord" elements. So, I used next expression to look for new node only and disregards any other following nodes:
I am sorry, I did not explained before in more details. Also, the data-sample I gave in the original post does not represent properly a source document I have. Sorry about it.