Having read some more, I think it's correct xslt behaviour, but it's still
not what I want.
I need to control the context size to be what I require it to be, maybe with
an apply-templates select clause.
Here is my new xslt which seems to fit the bill:
<xsl:template match="/x/y[1]">
<xsl:apply-templates select="/x/y[@Position='Top']" mode="test"/>
</xsl:template>
<xsl:template match="y" mode="test">
p=<xsl:value-of select="position()"/>
l=<xsl:value-of select="last()"/>
x
</xsl:template>
Martin
"Martin" <x@y.z> wrote in message
news:OMluiqfQGHA.2436@TK2MSFTNGP11.phx.gbl...[color=blue]
> Oops sorry, the data should read (1 x root, 2 y children)[color=green][color=darkred]
>>> <x>
>>> <y Position='Top'/>
>>> <y/>
>>> </x>[/color][/color]
>
> The rest of the problem description remains.
> Thanks
> Martin
>
> "Martin Honnen" <mahotrash@yahoo.de> wrote in message
> news:eGhsvjfQGHA.5400@TK2MSFTNGP09.phx.gbl...[color=green]
>>
>>
>> Martin wrote:
>>[color=darkred]
>>> I have some data like:
>>> <x>
>>> <y Position='Top'/>
>>> <y/>
>>> <x/>[/color]
>>
>> Where is the closing </x> then? It is not clear whether that first x
>> element has two y child elements as well as an x child element.
>>[color=darkred]
>>> and a template like:
>>> <xsl:template match="/x/y[@Position='Top']">
>>> <li>
>>> <xsl:if test="position()=last()">
>>> <xsl:attribute name="class">last</xsl:attribute>
>>> </xsl:if>
>>> </li>
>>> </xsl:template>
>>>
>>> I want to catch the last y with a position of Top
>>> unfortunately position and last work on a list of y elements, not a list
>>> of y[@Position='Top'] elements.[/color]
>>
>> The template does not change the type and size of the current node list.
>> You simply need to use xsl:apply-templates to filter out nodes first e.g.
>> <xsl:apply-templates select="y[@Position = 'Top']" />
>>
>> --
>>
>> Martin Honnen --- MVP XML
>>
http://JavaScript.FAQTs.com/[/color]
>
>[/color]