[TxMt] Re: XSLT question (Context: Markdown)
Stefan Brantschen
sbr at acm.org
Mon May 22 20:13:24 UTC 2006
Thanks to Paul and Quentin. To summarize, here's the snippet:
This is the XSLT template to get the value of an XHTML meta tag's
"content" attribute:
<xsl:template name="get-meta-value">
<xsl:param name="tag-name" />
<xsl:value-of select="/html/head/meta[@name=$tag-name]/@content" />
</xsl:template>
...that is, to read from this XHTML example markup:
<html>
<head>
<meta name="author" content="SBR" />
<meta name="classoptions" content="wtzg, english, confidential" />
<meta name="copyrightyear" content="2006" />
<meta name="documentclass" content="wtdocument" />
</head>
<body
</body>
</html>
the values of "documentclass" ("wtdocument") and
"classoptions" ("wtzg, english, confidential") for a LaTeX doc as in
<xsl:template name="doc-class">
<xsl:text>\documentclass[</xsl:text>
<xsl:call-template name="get-meta-value">
<xsl:with-param name="tag-name">
<xsl:text>classoptions</xsl:text>
</xsl:with-param>
</xsl:call-template>
<xsl:text>]{</xsl:text>
<xsl:call-template name="get-meta-value">
<xsl:with-param name="tag-name">
<xsl:text>documentclass</xsl:text>
</xsl:with-param>
</xsl:call-template>
<xsl:text>}</xsl:text>
<xsl:value-of select="$newline" />
</xsl:template>
to get "\documentclass[wtzg, english, confidential]{wtdocument}"
I hope I have copied everything OK... :-)
Thanks and regards
- Stefan
On 22 May 2006, at 16:08, Quentin Stafford-Fraser wrote:
> Stefan Brantschen <sbr at ...> writes:
>
>>
>> <xsl:template name="get-version-date">
>> <xsl:param name="vers" />
>> <xsl:value-of select="//div[ <at> class='version'][ <at> v=
>> $vers]" />
>> </xsl:template>
>>
>> I can get easily the value of a specific "version div", such as the
>> string "Change description v1.0". But how do I write the select
>> statement to get "d" of a specific version instead?
>
> Stefan -
>
> I think
>
> <xsl:value-of select="//div[@class='version'][@v=$vers]/@d" />
>
> may do it?
>
> Quentin
>
More information about the textmate
mailing list