How to set a parameter value dynamically?

vihar123
vihar123 used Ask the Experts™
on
How to set a parameter value dynamically?


I have a parameter called language

<xsl:param name="language">EN</xsl:param>

the value of parameter i will pass the value  from outside.

in my xml file i am trying to get is:

if the outside parameter value is EN,
then i want to set the parameter value to EN

if the outside parameter value is ''(empty)
i want to set the parameter value to EN

if the outside parameter value is FR
i want to set the parameter value to FR?

Thanks for your reply

vihar123
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Depends what you are using.

msxsl.exe takes command line parameters param=value.

If you are using Java, you use something like this....

        Source xsltSrc = new StreamSource(file);
        Transformer transformer = transformerFactory.newTransformer(xsltSrc);
        transformer.setParameter("param","value");

Author

Commented:
Hi,
I am using XSL.

I got the answer.
Here is my solution:

                <xsl:param name="lang">EN</xsl:param>

            <xsl:variable name="language">
            
                  <xsl:choose>
                        <xsl:when test="$lang = 'EN'">
                              <xsl:text>EN</xsl:text>
                        </xsl:when>
                                                                <xsl:when test="$lang = ' ' ">
                              <xsl:text>EN</xsl:text>
                        </xsl:when>
                                                                <xsl:when test="$lang = 'FR'">
                              <xsl:text>FR</xsl:text>
                        </xsl:when>
                        <xsl:otherwise>
                              <xsl:value-of select="$lang"/>
                        </xsl:otherwise>
                  </xsl:choose>
            </xsl:variable>


vihar123
PAQed, with points refunded (100)

Computer101
E-E Admin

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial