xsl-list
[Top] [All Lists]

Re: [xsl] global language parameter

2010-02-13 11:07:10
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.

It tried writing this way:

<xsl:template name="languageWrap">
   <xsl:param name="contents">
     <xsl:apply-templates/>
   </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.

   <xsl:choose>
     <xsl:when test="@xml:lang='sa'">

You might want to use the 'lang' function http://www.w3.org/TR/xpath/#function-lang e.g.
       <xsl:when test="lang('sa')">
as that way you could check for the language defined on the context node or an ancestor while your check with @xml:lang only checks the context node.

       <span style="font-family: 'Times Ext Roman'">
         <xsl:copy-of select="$contents"/>
       </span>
     </xsl:when>
    <xsl:when test="@xml:lang='zh'">
       <span style="font-family: Mincho,MingLiU, Batang, Simsun">
         <xsl:copy-of select="$contents"/>
       </span>
     </xsl:when>
    <xsl:when test="@xml:lang='ko'">
       <span style="font-family: Batang, BatangChe">
         <xsl:copy-of select="$contents"/>
       </span>
     </xsl:when>
     <xsl:otherwise>
       <xsl:copy-of select="$contents"/>
     </xsl:otherwise>
   </xsl:choose>
</xsl:template>


But nothing happens in the generated HTML--there are no <span> tags generated at all in the document. Any suggestions as to what I should be looking for here?

Show us some context where you call the above template and where we can see what the context node is and which xml:lang value it has.



--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--