Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 16th, 2011, 08:45 PM
Authorized User
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old March 17th, 2011, 03:27 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I can't read your post. Could you edit it please so it is readable.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get preceding node child element value smandeh XSLT 7 June 9th, 2010 09:50 AM
Retrieve numbered node path from xml jeft0nes XSLT 6 July 20th, 2007 03:59 PM
How Retrieve data of a node or from an element chandu.mca007 XML 1 December 16th, 2006 03:11 PM
How to use XPath to retrieve a node tag rs:data? y10k XML 1 May 5th, 2006 01:11 PM
Retrieve the escaped node content carlos.bravo XSLT 4 September 16th, 2005 03:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.