xsl-list
[Top] [All Lists]

Re: Same XPath expression with diferent results

2004-12-08 05:29:42


  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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--