This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: get immediat preceeding node, if it is a 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@nag.co.uk]
> Sent: 04 October 2002 13:03
> To: xsl-list@lists.mulberrytech.com
> Subject: Re: [xsl] 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]