xsl:param

only for RuBoard

xsl:param

xsl:param provides a variable parameter for an xsl:stylesheet or an xsl:tem plate element.

The xsl:param element is identical to the xsl:variable element, except that the xsl:param element can specify a default value.

Attributes

Attribute Name

Enforced

Description

Values

method

Optional

Specifies the overall method that should be used for outputting the result tree.

xml , html , text , or any QName that is not an NCName .

version

Optional

Specifies the version of the output method

NMToken

encoding

Optional

Specifies the preferred character encoding that the XSLT processor should use to encode sequences of characters as sequences of bytes; the value of the attribute should be treated case insensitively.

The value must contain only charac ters in the range #x21 to #x7E (for example, printable ASCII characters); the value should either be a charset registered with the Internet Assigned Numbers Authority, RFC2278, or start with X .

omit-xml- declaration

Optional

Specifies whether the XSLT processor should emit an XML declaration.

yes or no .

standalone

Optional

Indicates if the XSLT processor should output a standalone document declaration. The default is no .

yes or no .

doctype-public

Optional

Specifies the public identifier to be used in the document type declaration.

String

doctype-system

Optional

Specifies the system identifier to be used in the document type declaration.

String

cdata-section- elements

Optional

Specifies a list of element names whose text node children should be output as CDATA sections.

QNames

indent

Optional

Indicates if the XSLT processor might add additional white space when outputting the result tree.

yes or no .

media-type

Optional

Specifies the MIME content type of the data that results from outputting the result tree.

String

Example

Suppose that you want to display an HTML table with alternating rows colored differently. One way to do this is to set up a template rule that accepts the color to use. Here, you can see that even-numbered rows use the default value of the template rule named output-row , while odd-numbered rows specify the color parameter as silver :

 <?xml version="1.0" encoding="UTF-8" ?>  <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">       <xsl:output method="html" version="4.0" omit-xml-declaration="yes" />       <xsl:template match="/">            <html>                 <head></head>                 <body></body>                 <table>                      <xsl:for-each select="links/link">                          <xsl:choose>                                <xsl:when test="position() mod 2 = 0">                                   <xsl:call-template name="output-row" />                                </xsl:when>                                <xsl:otherwise>                                   <xsl:call-template name="output-row">                                           <xsl:with-param name="bgcolor" select="'silver'" graphics/ccc.gif />                                   </xsl:call-template>                                 </xsl:otherwise>                            </xsl:choose>                      </xsl:for-each>                 </table>            </html>       </xsl:template>       <xsl:template name="output-row">            <xsl:param name="bgcolor" select="'blue'" />            <tr>                 <xsl:attribute name="bgcolor">                      <xsl:value-of select="$bgcolor" />                 </xsl:attribute>                 <td>                     <xsl:value-of select="@name" />                 </td>            </tr>       </xsl:template>  </xsl:stylesheet> 

This stylesheet emits the following results. Notice that the odd-numbered rows have the specified color of silver , while the even-numbered rows have the default color of blue .

 <html>  <head>  <META http-equiv="Content-Type" content="text/html; charset=UTF-16">  </head>  <body></body>  <table>  <tr bgcolor="silver">  <td>NewRiders.com</td>  </tr>  <tr bgcolor="blue">  <td>Xmlandasp.net</td>  </tr>  <tr bgcolor="silver">  <td>MSDN Online Library</td>  </tr>  </table>  </html> 

Parent Elements

 xsl:stylesheet, xsl:template, xsl:transform 

Child Elements

 xsl:apply-templates, xsl:attribute, xsl:call-template, xsl:choose,  xsl:comment, xsl:copy, xsl:copy-of, xsl:element, xsl:for-each, xsl:if,  xsl:processing-instruction, xsl:text, xsl:value-of, xsl:variable, output  elements 
only for RuBoard


XML and ASP. NET
XML and ASP.NET
ISBN: B000H2MXOM
EAN: N/A
Year: 2005
Pages: 184

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