·  XSLT – Elements – <xsl:call-template> <xsl:with-param> <xsl:param>

 

- Info :

  - <xsl:call-template>:

    - calls named template.

  - <xsl:with-param>:

    - defines name and value of a parameter to be passed into a template.

    - value of the name attribute of <xsl:with-param> must match a name attribute in an <xsl:param>.

      If this is not so then e <xsl:with-param> element is ignored.

    - parameter's value can be defined either by content or select attribute.

  - <xsl:param>:

    - element used to declare a local or global parameter.

    - defines global parameter if it's declared as a top-level element, and local parameter if it's declared within a template.

    - select attribute defines parameter's default value as an XPath expression.

 

- Example:

 

    test.xml

    <?xml version="1.0"?>

    <?xml-stylesheet type="text/xsl" href="test.xsl"?>

    

    <people>

    </people>

    

    test.xsl

    <?xml version="1.0" ?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

     

      <xsl:template match="/">

        <xsl:call-template name="blob">

          <xsl:with-param  name="param" select="'some-value'"/>

        </xsl:call-template>

      </xsl:template>

    

      <xsl:template   name  ="blob">

        <xsl:param    name  ="param"    select="'default-value'"/>

        <xsl:value-of select="$param"/>

      </xsl:template>

    

    </xsl:stylesheet>

    

    result

    This is Jack

    This is Anton