xsl:param

Declares a parameter for a stylesheet or template, and specifies a default value for the parameter.

Format

<xsl:param name="parameter_name" 
               
  [select = "expression1"]
               
  [expr = "expression2"]>
               
  [template_body]
               
</xsl:param>
               

            

Description

The xsl:param instruction declares a parameter and specifies its default value. Another value can be passed to this parameter when the template or stylesheet that contains this xsl:param instruction is invoked.

The xsl:param element must be a child of either an xsl:stylesheet or xsl:template element.

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 bind to a parameter 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 default value of the parameter. If you specify the select attribute, the XSLT processor ignores any value you might specify for the expr attribute, and also ignores any contents of xsl:param.
  • Specify the expr attribute. The expr attribute allows computation of an expression. For example:
    <xsl:param name="query" expr="//VEHICLE[MAKE='{$make}']"/>
                           
    
                        

The XSLT processor interprets the value of the expr attribute as an attribute value template and uses the resulting string as if it were the value of the select attribute. If you specify the expr attribute, the XSLT processor ignores any contents of xsl:param.

The use of the expr attribute is an extension to the XSLT specification.

  • Specify template_body. The XSLT processor instantiates this template to obtain the default value of the parameter.
  • If you do not specify the select attribute, the expr attribute, or template_body, the default value of the parameter is an empty string.

For any use of the xsl:param element, there is a region of the stylesheet tree within which the binding is visible. This region includes the siblings that follow the xsl:param instruction together with their descendants. Within this region, any binding of the parameter that was visible on the xsl:param element itself is hidden. Thus, only the innermost binding of a parameter is visible. The set of parameter bindings in scope for an expression consists of those bindings that are visible at the point in the stylesheet where the expression occurs.

The xsl:param instruction can be a top-level element. If it is, it declares a global parameter that is visible to the entire stylesheet. When the XSLT processor evaluates the select or expr attribute in a top-level xsl:param instruction, the current node is the root node of the document.

Passing parameters to templates

Use the xsl:with-param instruction to pass a value for a parameter to a template.

Report Generation - Visually Defining Relationships in XML Publisher

Develop report generation applications with a powerful relationship manager in XML Publisher which provides a powerful and easy way to group and join data from one or more data sources.

FLWOR - An Introduction to the XQuery FLWOR Expression

An XQuery FLWOR Tutorial, covering an introduction to the main constructs of the XQuery FLWOR expression, including: For, Let, Where, Order By, and Return. Written by the W3C's Dr. Michael Kay.

DTD Editor

The Stylus Studio DTD Editor lets you visually develop Document Type Definitions (DTD) to structure XML documents. The DTD Editor also includes tools and utilites for validating XML against DTD's, converting DTD's, and generating DTD's.

Support for US National Library of Medicine (NLM) Document Type Definitions

Stylus Studio provides support for editing and validating XML documents using US National Library of Medicine data models. In this tutorial, we'll provide a step-by-step overview of how to use the NLM DTD's in Stylus Studio!

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member