Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 1st, 2007, 05:16 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Preceding-sibling question.

Hello,

I did check my book (XSLT 2.0) before posting and I thought I understood the preceding-sibling function which appears on pages 77 & 763.

I want to check to see if the sibling above the context node has a certain value.

Below is what I tried:

preceding-sibling::*/@eol
preceding-sibling::/@eol

Neither of these work, I wasn't sure about how to attack this one. I thought maybe someone ran across this before. Thanks for your time.

Reply With Quote
  #2 (permalink)  
Old March 1st, 2007, 05:19 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I figured it out guys, thanks.

preceding-sibling::*[1]/@eol

Reply With Quote
  #3 (permalink)  
Old March 1st, 2007, 05:31 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quick question if anyone read my earlier post I want to add to my original statement and check for a eol attribute (@eol) and see if the preceding-sibling is not a 'TXT' element.


This is my attempt:

<xsl:when test="preceding-sibling::*[not(name() = 'TXT')]/@eol">


Anyone come across this one?

Reply With Quote
  #4 (permalink)  
Old March 1st, 2007, 07:26 PM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This:

preceding-sibling::/@eol

is a syntax error. You can't leave out the node-test.

This:

preceding-sibling::*/@eol

selects the @eol attribute of all the preceding siblings. In a boolean context, it returns true if any preceding sibling has an @eol attribute.

I suspect you want

test="preceding-sibling::*[1]/@eol"

which tests whether the immediately preceding sibling has an @eol attribute.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #5 (permalink)  
Old March 1st, 2007, 07:27 PM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This:

preceding-sibling::*[not(name() = 'TXT')]/@eol

tests whether there is a preceding sibling whose name is not TXT and that has an eol attribute. I think you want

preceding-sibling::*[1][not(self::text)][@eol]

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #6 (permalink)  
Old March 5th, 2007, 11:55 AM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mhkay,

Can I ask you one more quick question.

I have the following:

preceding-sibling::*[1][. != '']

Which finds the first non empty sibling this works great for most of my code but anytime the node whose previous sibling has attributes on it (i.e. @something) it never finds that node with the above statement (preceding-sibling::*[1][. != '']) Just wondering if you had any input.

Reply With Quote
  #7 (permalink)  
Old March 5th, 2007, 12:20 PM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Then perhaps you want

preceding-sibling::*[1][. != '' or @*]

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #8 (permalink)  
Old March 5th, 2007, 12:35 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
preceding-sibling::comment() bonekrusher XSLT 11 October 1st, 2008 11:38 AM
Using preceding-sibling mcanne98 Infopath 0 September 11th, 2008 11:09 PM
preceding-sibling descendant xaun XSLT 3 February 28th, 2006 02:48 PM
preceding-sibling jonesyp XSLT 2 November 22nd, 2005 12:29 PM
preceding-sibling after sort rushman XSLT 3 January 18th, 2005 11:08 AM



All times are GMT -4. The time now is 02:50 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.