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>

Standard XML declaration.
xsl:stylesheet is an XSLT instruction. It must be the root element in a stylesheet to be used with Stylus Studio.
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.
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.
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: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.

XPath Generator

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

Learn XQuery in 10 Minutes, by Dr. Michael Kay - An XQuery Tutorial

Learn XQuery in 10 Minutes By Dr. Michael Kay is for all those people who really want to know what XQuery is, but don't have the time to find out. It's the fastest XQuery tutorial on the planet - read it now!

XML Project

Stylus Studio's Project Window is an intuitive, visual feature for organizing files belonging to a project. It supports different file-type icons and nested folders; many helpful options are available from the context menu.

Sybase

Sybase Adaptive Server Enterprise (ASE) is a powerful high-performance database for recording and retrieving business records. Learn how to develop XML applications for Sybase using Stylus Studio.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.