xsl-list
[Top] [All Lists]

Re: [xsl] a href problem with XSLT

2006-07-27 05:25:47

 {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="{(_at_)name}"><xsl:value-of select="@name"/></a>
</li>
</xsl:template>

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

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

<Prev in Thread] Current Thread [Next in Thread>