[TxMt] XSLT question (Context: Markdown)

Paul McCann paul.mccann at adelaide.edu.au
Mon May 22 14:04:44 UTC 2006


OK, you're stretching my ancient XSLT recollections, but what you've
written just makes me scratch my head!

Try something like the following stylesheet (output is below): with
any luck it illustrates a way to achieve what you're after. [[The
stuff inside the square brackets where "dvalue" is found should be
read as "given"; hence the XPath expression reads "the value of the @d
attribute of the div element which has a "class" attribute of
"version" and a "v" attribute found below as $vers.]] The other thing
worth mentioning is that the "get-version-date" template is being
called with the version number, but you still need to declare "vers"
as a parameter in the declaration of the template.

I hope this is of some use!

Cheers,
Paul

=======================================================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template name="get-version-date">
        <xsl:param name="vers"></xsl:param>
        <xsl:param name="dvalue"><xsl:value-of
select="//div[@class='version' and @v=$vers]/@d"/></xsl:param>
        Date string is <xsl:value-of select="$dvalue"/> to be sure.
</xsl:template>

<xsl:template match="//div[@class='version']">
<xsl:call-template name="get-version-date">
    <xsl:with-param name="vers">
        <xsl:value-of select="./@v"/>
    </xsl:with-param>
</xsl:call-template>
</xsl:template>

</xsl:stylesheet>

=======================================================================
 Output is...

<?xml version="1.0" encoding="utf-8"?>

        Date string is 2006-05-04 to be sure.


        Date string is 2006-05-05 to be sure.


        Date string is 2006-05-06 to be sure.



More information about the textmate mailing list