[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: get immediat preceeding node, if it is a comment

Subject: RE: get immediat preceeding node, if it is a comment
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Fri, 4 Oct 2002 13:47:50 +0100
xsl self comment
It seems that any predicates after the positional predicate refer to
that node, not to the node that the predicates before the positional
predicate refer to... 

So,

on this data:

<root>
   <!--   test     -->
   <test>test1</test>
   <test>test2</test>
   <!--   test     -->
   <test>test3</test>
   <test>test4</test>
</root>

preceding-sibling::node()[normalize-space()][1][self::comment()]

this gets 'test1' and 'test3' as we would expect

preceding-sibling::node()[normalize-space()][self::comment()][1]

this gets all of them, as they all have a preceding-sibling that returns
true for all three predicates individually

preceding-sibling::node()[normalize-space()][3][contains(self::test,'tes
t2')]

this returns 'test4' as the third preceding-sibling contains 'test2'

So is it the case that all predicates to the right of the positional
predicate refer to that node? (they change the context node)

In which case, as Joerg pointed out, it definetly does matter when the
positional predicate goes as this alters which node the following
predicates refer to.

But what about multiple positional predicates:

preceding-sibling::node()[normalize-space()]
  [3][contains(self::test,'test2')]
  [1][contains(self::test,'test2')]

this also returns 'test4', why doesnt the [1] alter the evaluation of
the second contains()?

Also, why if I change the second [1] to [2] (and even drop the final
test) does it return nothing:

preceding-sibling::node()[normalize-space()]
  [3][contains(self::test,'test2')]
  [2]

why would this fail, when this is fine:

preceding-sibling::node()[normalize-space()]
  [3][contains(self::test,'test2')]
  [1]

hmm, confused.

 

> -----Original Message-----
> From: David Carlisle [mailto:davidc@xxxxxxxxx]
> Sent: 04 October 2002 13:03
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  get immediat preceeding node, if it is a comment
> 
> 
> 
> > Sure.  But aren't they both the same (they select the same node)? 
> 
> No.
> 
> If you are in <a/> in 
> 
> <x>
>  <a/><b>b</b><!--x--><c/>
> </x>
> 
>  preceding-sibling::node()[normalize-space()][self::comment()][1]
> 
> selects the comment <!--x--> as that is the first node that is
> non empty string value and is a comment.
> 
> preceding-sibling::node()[normalize-space()][1][self::comment()]
> 
> selects the empty node set as the first node with non empty 
> string value
> is not a comment.
> 
> David
> 
> _____________________________________________________________________
> This message has been checked for all known viruses by Star Internet
> delivered through the MessageLabs Virus Scanning Service. For further
> information visit http://www.star.net.uk/stats.asp or 
> alternatively call
> Star Internet for details on the Virus Scanning Service.
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002
>  
> 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002
 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.