[thelist] XML XSLT and url outputting
Ray Hill
lists at prydain.com
Thu Jan 17 11:02:26 CST 2002
I beleieve what you're looking for is the <xsl:attribute> tag. It's
been a while and I don't have a book to check the syntax, but it
should look something like this:
<xsl:template match="event">
<a>
<xsl:attribute name="href">
<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:value-of select="."/>
</a>
</xsl:template>
Basically, you make the <xsl:attribute> tag a child of the tag you
want the attribute applied to, and name the attribute in the opening
tag. Then, anything you put betweeen the opening and closing
<xsl:attribute> tags will show up as the value of the attribute. So
you could also do it as follows, if you wanted to print a mailto link:
<xsl:template match="event">
<a>
<xsl:attribute name="href">
<xsl:text>mailto:</xsl:text>
<xsl:value-of select="@email"/>
</xsl:attribute>
<xsl:value-of select="@email"/>
</a>
</xsl:template>
And that would produce <a
href="mailto:buh at example.com">buh at example.com</a>.
--ray
More information about the thelist
mailing list