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="positio n()"/>
l=<xsl:value-of select="last()"/>
x
</xsl:template>
Martin
"Martin" <x@y.z> wrote in message
news:OM******** ******@TK2MSFTN GP11.phx.gbl...
Oops sorry, the data should read (1 x root, 2 y children) <x>
<y Position='Top'/>
<y/>
</x>
The rest of the problem description remains.
Thanks
Martin
"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:eG******** ******@TK2MSFTN GP09.phx.gbl...
Martin wrote:
I have some data like:
<x>
<y Position='Top'/>
<y/>
<x/>
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.
and a template like:
<xsl:template match="/x/y[@Position='Top']">
<li>
<xsl:if test="position( )=last()">
<xsl:attribut e name="class">la st</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.
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/