Re: [xsl] global language parameter

Subject: Re: [xsl] global language parameter
From: Charles Muller <cmuller-lst@xxxxxxxxxxxxxxx>
Date: Mon, 15 Feb 2010 16:36:23 +0900
G. Ken Holman wrote:

And when you then find after distilling all of this out that you are always building your style attribute the same way based on added attributes, you can localize the entire processing along the lines of:

  <xsl:template match="p">
    <p>
      <xsl:call-template name="add-style"/>
    </p>
  </xsl:template>

  <xsl:template match="another">
    <another-result>
      <xsl:call-template name="add-style"/>
    </another-result>
  </xsl:template>

  <xsl:template name="add-style">
    <xsl:attribute name="style">
      <!--what is the margin component-->
      <xsl:choose>
        <xsl:when test="@render='this'">
          <xsl:text>text-indent:12mm; margin-top: 0;</xsl:text>
          <xsl:text>margin-bottom: 0; line-height:9mm;</xsl:text>
        </xsl:when>
        <xsl:when test="@render='that'">
          <xsl:text>text-indent:30mm; margin-top: 5mm;</xsl:text>
          <xsl:text>margin-bottom: 0; line-height:12mm;</xsl:text>
        </xsl:when>
      </xsl:choose>

<!--what is the language component-->
<xsl:choose>
<xsl:when test="lang('sa')">font-family: 'Times Ext Roman';</xsl:when>
<xsl:when test="lang('zh')"
>font-family: Mincho,MingLiU, Batang, Simsun;</xsl:when>
<xsl:when test="lang('ko')">font-family: Batang, BatangChe;</xsl:when>
</xsl:choose>
</xsl:attribute>
</xsl:template>

Excellent!


Thank you for taking the time to do this. My style sheets are now all going to be transformed to a new level.

Regards,

Chuck

-------------------

A. Charles Muller

University of Tokyo
Graduate School of Humanities and Sociology, Faculty of Letters
Center for Evolving Humanities
Akamon kenkyE+ tE
#722
7-3-1 HongE
, BunkyE
-ku
Tokyo 113-0033, Japan

Web Site: Resources for East Asian Language and Thought
http://www.acmuller.net

<acmuller[at]jj.em-net.ne.jp>

Mobile Phone: 090-9310-1787

Current Thread