[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: <xsl:number> in XPath

Subject: Re: <xsl:number> in XPath
From: António Mota <xptm@xxxxxxx>
Date: Thu, 9 Dec 2004 19:43:42 +0000
xpath pos
My webmail is not very reliable, sorry for that.

> 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.

Yes, there is a current node, but it's the root one, not the one i want the
ancestors at the moment of the select.

<xsl:template match="/">
        <xsl:apply-templates select="/menus/menu | (//menu)[$pos]" />
</xsl:template>

I want both the /menus/menu, the (//menu)[$pos] and their ancestors and first
children, but i can't do something like

<xsl:apply-templates select="/menus/menu | (//menu)[$pos]" |
(//menu)[$pos]/menu
 | ancestor:menu[(//menu)[$pos]]/>

or is there something similar?

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

There was no XSL expressions after that, maybe you forget it?

> 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.

All this taking as reference the current node, correct? If yes, i think it's
that what i want.

<menu>
<menu>
    <menu>  *
        <menu>  --> this is the (//menu)[$pos]
<menu>

So in the first select i didn't select the one i marked (*), so i need the
ancesters of the (//menu)[$pos]

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

Puting in words, i have that nested <menu> nodes that i want to expand when i
click then. So at first i want to show all the first-level menus, and when i
click one of then i want to expand to it's first chidrens and so on.

Once agains, thank for your insights.


Citando David Carlisle <davidc@xxxxxxxxx>:


Citando David Carlisle <davidc@xxxxxxxxx>:

>
> (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
> ________________________________________________________________________
>
>





O SAPO ja esta livre de vmrus com a Panda Software, fique vocj tambim!
Clique em: http://antivirus.sapo.pt

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.