RE: [xsl] how to set the pattern to get the node

Subject: RE: [xsl] how to set the pattern to get the node
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 30 Nov 2004 21:03:46 -0000
> I am so confused that why I can use
>  <xsl:when test="Parent_ID=1 or
> not(preceding-sibling::List[List_ID = $self/Parent_ID]
>  or following-sibling::List[List_ID =
> $self/Parent_ID])"> 
> 
>  to get node which I wnat 
> but when I 
> use 
> 
>  <xsl:template match="List[Parent_ID=1or
> not(preceding-sibling::List[List_ID=Parent_ID]  or
> following-sibling::List[List_ID=Parent_ID])]">
> 
> It is not filter properly 
> 

You're having trouble understanding context. Within a predicate, path
expressions are evaluated relative to the node that you're testing. So 

List[List_ID=Parent_ID]

means "find List elements whose List_ID is equal to their Parent_ID", for
example

<List>
  <List_ID>12</List_ID>
  <Parent_ID>12</Parent_ID>
</List>

If your data contained

<List>
  <List_ID>12</List_ID>
  <Parent_ID>12</Parent_ID>
  <Parent_ID>23</Parent_ID>
</List>

that would be selected as well.

But when you write

List[List_ID=$self/Parent_ID]

then you are selecting List elements whose List_ID is equal to the Parent_ID
of the node held in variable $self.

Michael Kay
http://www.saxonica.com/

Current Thread