|
[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:27:22 +0000
|
Well, the xsl i was talking it's not exactly the one indicated, it's
similar but with some changes, like using //menu in the match pattern (i
know now it's irrelevant), using for-each as your second example, and
various conbinations of using ancestor axis on the second
apply-templates. I've also changed the strucuture to work with
call-templates instead of a single template match="menu".
Nothing works, however...
xptm wrote:
My xsl is in http://gti.clientes.gtinformatica.pt/Site/Java/dmenus.xsl
.. You can also see the transformation in
http://gti.clientes.gtinformatica.pt/Site/Java/tap.html . It seems
mine xsl it's a "combination" oh the two you show. I don't understand
the firts one, toughth, specially the line
<xsl:template match="node() | attribte::*"/>
but i'll check that out.
Thanks for your input.
david_n_bertoni@xxxxxxxxxx wrote:
I don't understand this. Giving the xml in
http://gti.clientes.gtinformatica.pt/Site/Java/Menus.xml if
i inspect the xpath expression //menu (using the jEdit XPath
Tool) it gives a count 0f 8. That's what i expected.
But in
<xsl:template match="//menu">
blabla
</xsl:template>
blabla only appears 3 times, corresponding to the /menus/menu.
Why this isn't giving the same 8 results?
Because the menu elements are nested, and your template does not
continue the recursive processing of the source tree, you never reach
the menu elements that are descendants of another menu element.
You don't show a full stylesheet, so I'm just guessing, but try these
two stylesheets produce the same output, and contrast the typical
"push" vs. "pull" styles:
<?xml version="1.0"?> <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | attribte::*"/>
<xsl:template match="menu">
<xsl:text>blabla</xsl:text>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0"?> <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:for-each select="//menu">
<xsl:text>blabla</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Note that "//" is not necessary in a match pattern.
Dave

|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
| RSS 2.0 |
|
| Atom 0.3 |
|
|