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

Re: a href problem with XSLT

Subject: Re: a href problem with XSLT
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 27 Jul 2006 13:25:24 +0100
a href problem
 {generate-id(.) generate id generates a new unique id for the node,
you don't want that, you just want its value, so use {.}

<xsl:template match="dir:directory|dir:file">
<li>
<xsl:value-of select="@name"/>
<xsl:if test="name(.)='dir:directory'">

tests with name() arenot usually a good idea as they are not namespace
aware, also in this case it would be simpler and probably quicker just
to have two templates, since the two cases do different things.

<xsl:for-each select="@name">

there can only be one such attribute so you don't need for-each here
(unless the attribute can be missing)

so...

<xsl:template match="dir:directory">
<li>
<xsl:value-of select="@name"/>
<ul><xsl:apply-templates/></ul>
<a href="{@name}"><xsl:value-of select="@name"/></a>
</li>
</xsl:template>

<xsl:template match="dir:file">
<li>
<xsl:value-of select="@name"/>
<a href="{@name}"><xsl:value-of select="@name"/></a>
</li>
</xsl:template>

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.