Re: [xsl] global language parameter

Subject: Re: [xsl] global language parameter
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Sun, 14 Feb 2010 12:13:49 +0100
Charles,

Pardon me if I'm doing you wrong. I think that you are trying to
create and use a named template with a parameter, to be called from
elsewhere, where you have determined that an element has an @xml:lang
attribute. This is needlessly complicated.

A straightforward match of all elements with @xml:lang and insertion
of the <span> around the matching element would be sufficient.

If this is NOT what you intend, please follow the suggestions of
others, and POST MORE INFO!

<xsl:template match="element()[@xml:lang]">
  <xsl:choose>
    <xsl:when test="@xml:lang='de'">
    <span style="font-family: 'URW Gothic L'">
      <xsl:copy-of select="."/>
    </span>
    </xsl:when>
    <xsl:when test="@xml:lang='en'">
    <span style="font-family: serif">
      <xsl:copy-of select="."/>
    </span>
    </xsl:when>
    <xsl:when test="@xml:lang='ko'">
    <span style="font-family: Batang, BatangChe">
      <xsl:copy-of select="."/>
    </span>
    </xsl:when>
    <xsl:otherwise>
      <xsl:copy-of select="."/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="*|@*">
  <xsl:copy>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

-W


On Sun, Feb 14, 2010 at 2:18 AM, Charles Muller
<cmuller-lst@xxxxxxxxxxxxxxx> wrote:
>
> Martin Honnen 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.
>>>
>>> It tried writing this way:
>>>
>>> <xsl:template name="languageWrap">
>>> B  <xsl:param name="contents">
>>> B  B  <xsl:apply-templates/>
>>> B  </xsl:param>
>>
>> I am not sure I understand what you want to achieve without seeing the
input XML and the output you want to create but your text above says "making a
global" parameter while here you are defining a parameter that is local to
your template named "languageWrap".
>>
>> A global parameter is defined as a child of the xsl:stylesheet element, not
inside of a template, and is used to allow to pass in a value to the
transformation that can be changed each time the transformation is run.
>
> Ken's response, together with this, exposes the fact that I don't really
know what I am doing here.
>
> My understanding of the notion of "global parameter" was that of a style
that could be applied to any content element (in, for example, Chinese)
throughout my XML document, regardless of whether it was <p xml:lang="zh">,
<item xml:lang="zh">, <term xml:lang="zh">, <ref xml:lang="zh">, etc. In other
words, I could just write the style declaration for this once at the top of my
style sheet, and not have to write it separately at each element.
>
> Perhaps I am using the wrong terminology? Or attempting something that can't
be done?
>
> 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