xsl-list
[Top] [All Lists]

Re: fallback parameter

2004-09-23 00:50:06
On Wed, 22 Sep 2004, Jan Limpens wrote:

) In my xml I have areas marked with lang='somelanguage'. In my xslt I
) defined a parameter selectedLanguage (can be changed by user input)
) and a parameter defaultLanguage, that is used, when no content in the
) selected Language is available.

Can't you just work with the one variable $somelanguage (capital l?)
throughout? If you define somelanguage at the top of the stylesheet:

        <xsl:stylesheet ... >
           <xsl:param name="somelanguage" select="'en'"/>

           <xsl:template match="/">
             Foo: <xsl:value-of select="$somelanguage"/>
           </xsl:template>
        </xsl:stylesheet>

NOTE: double quotes around "'en'", otherwise it will take the value of the
ELEMENT en, which doesn't exist. Then specifying it on the command line to
e.g. saxon should cause it to be overridden e.g:

        > saxon test.xsl test.xsl
        Foo: en

        > saxon test.xsl test.xsl somelanguage=Spanish
        Foo: Spanish

Cheers,
J-P
-- 
It is redundant to punish a girl who dyes her hair multiple colors.
But if you feel it's absolutely necessary, I recommend a tattoo.


<Prev in Thread] Current Thread [Next in Thread>