xsl:with-param

Passes a parameter value to a template.

Format

<xsl:with-param 
               

              
name = "parameter_name" 
                   
[select = "expression1]"
                   
[expr = "expression2"]>
                   
[parameter_value]
                   

                
</xsl:with-param>

Description

The xsl:with-param instruction passes a parameter value to a template. If the template has no matching xsl:param declaration, the XSLT processor ignores the parameter. The value of parameter_name is a qualified name.

The name attribute is required, and it must be a string. The value of the name attribute is a qualified name.

The value that you pass to a template can be an object of any of the types that are returned by expressions. You can specify the value of the parameter in several ways:

  • Specify the select attribute. The value of the select attribute must be an expression. The XSLT processor evaluates the expression, and the result is the value of the parameter. If you specify the select attribute, you must not specify any contents for the xsl:with-param instruction. In other words, do not specify parameter_value.
  • Specify the expr attribute. It is interpreted as an attribute value template. It allows computation of the value expression.
  • Specify parameter_value. If you specify parameter_value, you must not specify the select or expr attribute.
  • Specify none of the above. In this case, the value of the parameter is an empty string.

The xsl:with-param element must be a child of xsl:apply-templates or xsl:call-template.

You can specify the xsl:with-param instruction in xsl:call-template and xsl:apply-template instructions.

Example

Suppose you specify the following parameter for a template:

<xsl:template name="Appendix">
               

              
<xsl:param name = "heading"> 1. </xsl-param>
                   

                
... </xsl:template>

You can pass another value for this variable as follows:

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

              
<xsl:with-param name = "heading"> A. </xsl:with-param>
                   

                
</xsl:call-template>

Namespace declaration for W3C XSLT namespace.

xsl:output is an XSLT instruction. In this stylesheet, it specifies that the result document will be in HTML format.

xsl:apply-templates is an XSLT instruction. For each node identified by this instruction's select attribute, the XSLT processor goes to another template in this stylesheet, and performs the actions defined in that template. When done, the processor returns here, and moves to the next line in this template. In this template, the select attribute identifies all book elements in the source document.

xsl:sort is an XSLT instruction. The XSLT processor processes the book nodes in alphabetical order by author.

xsl:value-of is an XSLT instruction. The XSLT processor extracts the contents of the source node specified in the select attribute and copies it into the result document.
This template matches book elements in the source document. That is, the template's match attribute identifies book elements. In this stylesheet, the XSLT processor performs the actions in this template three times, once for each book element in the source document.

xsl:template is an XSLT instruction. It contains literal data to be copied to the result document and XSLT instructions to be followed by the XSLT processor. The processor performs these steps for the source nodes identified by the match attribute value. In this template, the match attribute identifies the root node of the source document.

xsl:stylesheet is an XSLT instruction. It must be the root element in a stylesheet in Stylus Studio.

HTML Tidy

HTML Tidy is a program for turning HTML into something that can be parsed as XML, unlocking their data for use in XSLT and XQuery programs. Learn how to use HTML Tidy in Stylus Studio now.

XPath Generator

Stylus Studio includes an XPath generator that helps you easily create XPath expressions. This page illustrates how you can accomplish this.

Banks That Bank on Stylus Studio for Enhanced XML Productivity

Guess what! You can pass go and collect 200 dollars because with Stylus Studio 2006 you can save your banking company time and labor in every day work activities. Come see which banking companies are already taking advantage of Stylus Studio today!

XML Code Folding

Stylus Studio's XML Editor features XML code folding, a powerful and intuitive way to maximize limited screen real-estate and help make sense of large XML files.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member