Section 18.8.  Parameters

Prev don't be afraid of buying books Next

18.8. Parameters

An XSLT parameter is just like a variable except that the value can be overridden. How it would be overridden depends on your XSLT implementation. Command-line XSLT transformation engines typically use command-line options. Graphical environments might use options in a graphical user interface. In other words, parameters are user options that change the stylesheet's behavior. They are declared and referenced just as variables are. Example 18-26 demonstrates.

Example 18-26. Defining a parameter
 <xsl:param name="company-name" select="/doc/creator/company"/> 

The select attribute of a parameter is used as a default value. If the user fails to supply a parameter, the default value is used when the stylesheet is processed.

It is also possible to define template rules that have parameters. In that case, the parameters are only available within that template. Template rule parameters are passed not from the user, but from other templates. For instance a template for a chapter might use a parameter to pass the chapter number to a template rule for a section. That way the section number could be derived from the chapter number (e.g. section number 5.4 within Chapter 5).

Amazon


XML in Office 2003. Information Sharing with Desktop XML
XML in Office 2003: Information Sharing with Desktop XML
ISBN: 013142193X
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net