This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: creating links to resource files listed in XML file
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: Brian Hickey <brian_hickey1 at yahoo dot com>
- Cc: XSL-List at lists dot mulberrytech dot com
- Date: Thu, 18 Jul 2002 10:13:06 +0100
- Subject: Re: [xsl] creating links to resource files listed in XML file
- Organization: Jeni Tennison Consulting Ltd
- References: <20020718085125.40966.qmail@web20804.mail.yahoo.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Brian,
> I want to create some links to resource files which are referenced
> in my .xml file. In my .xsl file I have added the following code:
Use an attribute value template. In an attribute, you can put {}s
around an expression in order to have it evaluated and the result
inserted into the attribute value:
<xsl:template match="/">
<xsl:for-each select="//file/@href">
<xsl:variable name="myVar" select="." />
<a href="{$myVar}">
<xsl:value-of select="$myVar"/>
</a>
</xsl:for-each>
</xsl:template>
You can also use xsl:attribute to create the attribute; it's longer,
but it's more flexible at times:
<xsl:template match="/">
<xsl:for-each select="//file/@href">
<xsl:variable name="myVar" select="." />
<a>
<xsl:attribute name="href">
<xsl:value-of select="$myVar"/>
</xsl:attribute>
<xsl:value-of select="$myVar"/>
</a>
</xsl:for-each>
</xsl:template>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list