[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] in XPath


Subject: Re: [xsl] <xsl:number> in XPath
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 9 Dec 2004 16:50:08 GMT

(your message came out one word per line, I had to reflow it to read it)


Just a comment on,


> To my understanding i canot use
> the axis in the select xpath because they rely on a context node, wich
> i don't have at the time.  

There is always a current node in XSLT, you can always use an axis in a
select expression.  so I don't understand this comment.

However

> I want to process all <xxx> nodes that
> are at the 1st level of deepness, plus the <xxx> at absolute position
> number n 

> So i translate this to
> 
> <xsl:apply-templates
> select="/menus/menu | (//menu)[$pos]" />

That does seem to be a direct translation of your English into Xpath, so
presumably this is what you want.

But this looks a bit strange:

> <xsl:for-each
> select="ancestor::menu/menu | self::menu | menu">

Given that you already slected all your top level menus and the $pos'th
menu in your first <xsl:apply-templates select="/menus/menu | (//menu)[$pos]" />
why do you need to start walking back up the tree here. That select
selects all ancestor menus that have a parent menu (but not ancestor
menus that don't have a parent menu), the current node and any menu
children of the current node.

If thats what you want, this is the right thing, but it looks strange to
me.


> The
> XML:
> http://gti.clientes.gtinformatica.pt/Site/Java/Menus.xml

sorry, as a matter of policy never check off-list examples (I waste
enough time just looking at small inlined examples on the list:-)

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


Current Thread
Keywords