How can I retrieve immediate preceding node text value
I am currently trying to retrieve an immediate preceding node text value when the node text value is not null in xslt 1.0.
When it is null I would like to go on to the next node and so forth. Currently, I can retrieve the immediate preceding node when it is not null. However, when the immediate node text is null or empty then I am unable to move on to the next null. I can move there if I specify the exact position as in :for-each preceding-sibling::row[$iPosition -2][col_0]...... but I would like to do this programmatically as there could be unspecified number of records in between the non null col_0 node and the node value.
Below is my sample file: Each chapter is a record in my xlst. However, if a chapter node col_0 is empty then I need to use the preceding chapter col_0 node value. When I am at the third or fourth record, I can not get the text value for col_0 because the immediate node col_0 text value is null. I need to go back to the non null value and use it. Please help.
<books>
<chapter>
<col_0>8848</col_0>
<col_1>09/06/2010 2:07</col_1>
<col_2>YYYY4</col_2>
<col_3>1</col_3>
</chapter>
<chapter>
<col_0/>
<col_1>09/06/2010 2:08</col_1>
<col_2>YYYY5</col_2>
<col_3>1</col_3>
</chapter>
<chapter>
<col_0/>
<col_1>09/06/2010 2:08</col_1>
<col_2>YYYY6</col_2>
<col_3>1</col_3>
</chapter>
<chapter>
<col_0/>
<col_1>09/06/2010 2:12</col_1>
<col_2>YYYY2</col_2>
<col_3>2</col_3>
</chapter>
..................
</books>
Last edited by smandeh; March 17th, 2011 at 08:03 AM..
Reason: To be readable
|