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

Re: Same XPath expression with diferent results

Subject: Re: Same XPath expression with diferent results
From: xptm <xptm@xxxxxxx>
Date: Wed, 08 Dec 2004 12:42:33 +0000
get xpath expression root
I'm using this:

<xsl:template match="/">
   <xsl:apply-templates/>
</xsl:template>

<xsl:template match="menu">
  (do lot of things)
</xsl:template>

This is matching the three menus under the root. So if i understand you i have to have

<xsl:template match="menu">
  (do lot of things)
   <xsl:apply-templates/>
</xsl:template>

to process all the <menu> in the tree?

BTW the all script is in http://gti.clientes.gtinformatica.pt/Site/Java/dmenus.xsl

Thanks.

David Carlisle wrote:

Ok, i understand that the two expressions are equivalent, but still don't understand why in my xsl only the three <menu> directly under the root are matched by the template...


No, all menu items are matched, but that doesn't mean that you get any
output from that template. Note also that in Xpath the root (/) is not
teh top level element, it logically corresponds to the whole document, so you presumably only have one element directly under the root, and
three menu elements below that.


You get output from that template whenever you use <xsl:apply-templates>
that selects a menu node. So you can get any number of copies of the
output from 0 upwards depending on which nodes you select. You didn't
show any code so we have no idea, but here are some examples.

If you have

<xsl:template match="/" />

then the top level template just stops without applying any templates so
you get no output, no matter how many templates you have defined, they
are never used.

If you have

<xsl:template match="*">
<xsl:apply-templates/>
<xsl:apply-templates match="menu"/>
</xsl:template.

then for each element other than menu you first process all the children
(including anuy menus) then you process any menus again, so you will get
the output of your menu template duplicated (at least)

So if you have a menu element that you don't think is being processed,
look at the template matching its parent: does that template use
xsl:apply-template to process its children: if it doesn't its children
won't be processed.


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

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.