[Home] [By Thread] [By Date] [Recent Entries]
At 2010-02-14 01:41 +0900, Charles Muller wrote:
I'm taking my first stab at making a global parameter, through which I'd like to set font attributes for character sets of different languages. I'm using TEI-P5 with XSL 2, and I want my parameter to work with xml:lang. In XSLT-speak a "global parameter" is a parameterized global variable. In your example code I see no references to any parameterized global variables. It tried writing this way: You don't give us your input stream with an example ... you just have a named template, so there isn't even a match= attribute to determine where you are testing this. And I'm unclear why you are using a local variable for the processed contents ... though a smart XSLT processor would probably optimize it away. Note, however, that the direct addressing of the xml:lang= attribute is not good form because of the language scope. This is expressly handled in XPath 1 and XPath 2 using the lang() function. In your code above I would have considered something along the lines of: <xsl:choose>
<xsl:when test="lang('sa')">
<span style="font-family: 'Times Ext Roman'">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:when test="lang('zh')">
<span style="font-family: Mincho,MingLiU, Batang, Simsun">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:when test="lang('ko')">
<span style="font-family: Batang, BatangChe">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>The lang() function is particularly useful, because it will return true for lang('fr') when the closest ancestral xml:lang= declaration is xml:lang="fr" or xml:lang="fr-ca" or xml:lang="fr-anything at all here". I hope this helps. . . . . . . . . . . . . Ken
|

Cart



