webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Is it possible to pass a parameter to a stylesheet

  • 1.  Is it possible to pass a parameter to a stylesheet

    Posted Fri March 17, 2006 07:32 PM

    I have a xslt stylesheet ready at design time. At runtime, I may want a little different stylesheet based on a runtime parameter. I could write the original stylesheet so that the output is determined by a xsl:variable. But how could I set the variable value at runtime? Is it possible? Any other way to do so?

    thanks,


    #webMethods
    #Tamino
    #API-Management


  • 2.  RE: Is it possible to pass a parameter to a stylesheet

    Posted Sat March 18, 2006 04:02 PM

    XSLT processors do enable parameters setting at runtime. Syntax depends on code language (Java ? .net ? php ?).

    In your xsl :

    <?xml version="1.0" encoding="UTF-8"?>

    <xsl:stylesheet version=“1.0” xmlns:xsl=“XSLT Namespace”>

    <xsl:param name="myParam" select="'default value if no parameter is set" />
    
    <xsl:template match="/">
    <xsl:value-of select="$myParam" />
    </xsl:template>
    

    </xsl:stylesheet>

    Java :

    javax.xml.transform.Transformer.setParameter(String name, Object value)
    (JDK 19 Documentation - Home)

    PHP :

    XSLTProcessor->setParameter()
    (http://www.php.net/xsl)

    Hope this helps


    #Tamino
    #API-Management
    #webMethods