An XSL Template (XSLT) contains XSL elements defines how the individual source node is generated. Many of these Elements generate output in the Task's target model.
| Element |
Syntax |
Description |
| apply-imports |
<xsl:apply-imports/> |
The <xsl:apply-imports> element applies a template rule from an imported style sheet.
Template rules in imported style sheets have lower precedence than template rules in main style sheets. The <xsl:apply-imports> is used when we want to use a template rule from the imported style sheet rather than an equivalent rule in the main style sheet.
|
| apply-templates |
<xsl:apply-templates select="expression" mode="name">
<!-- Content:(xsl:sort|xsl:with-param)* -->
</xsl:apply-templates>
|
The <xsl:apply-templates> element applies a template to the current element or to the current element's child nodes.
If we add a select attribute to the <xsl:apply-templates> element it will process only the child element that matches the value of the attribute. We can use the select attribute to specify in which order the child nodes are to be processed.
|
| attribute |
<xsl:attribute name="attributename" namespace="uri">
<!-- Content:template -->
</xsl:attribute> |
The <xsl:attribute> element is used to add attributes to elements.
Note: The <xsl:attribute> element replaces existing attributes with equivalent names.
|
| attribute-set |
<xsl:attribute-set name="name" use-attribute-sets="name-list">
<!-- Content:xsl:attribute* -->
</xsl:attribute-set> |
The <xsl:attribute-set> element creates a named set of attributes. The attribute-set can be applied as whole to the output document.
Note: Must be child of <xsl:stylesheet> or <xsl:transform>.
|
| call-template |
<xsl:call-template name="templatename">
<!-- Content:xsl:with-param* -->
</xsl:call-template> |
The <xsl:call-template> element calls a named template.
|
| choose |
<xsl:choose>
<!-- Content:(xsl:when+,xsl:otherwise?) -->
</xsl:choose> |
The <xsl:choose> element is used in conjunction with <xsl:when> and <xsl:otherwise> to express multiple conditional tests.
If no <xsl:when> is true, the content of <xsl:otherwise> is processed.
If no <xsl:when> is true, and no <xsl:otherwise> element is present, nothing is created.
Tip: For simple conditional testing, use the <xsl:if> element instead.
|
| comment |
<xsl:comment>
<!-- Content:template -->
</xsl:comment> |
The <xsl:comment> element is used to create a comment node in the result tree.
|
| copy |
<xsl:copy use-attribute-sets="name-list">
<!-- Content:template -->
</xsl:copy> |
The <xsl:copy> element creates a copy of the current node.
Note: Namespace nodes of the current node are automatically copied as well, but child nodes and attributes of the current node are not automatically copied ("shallow copy")
|
| copy-of |
<xsl:copy-of select="expression"/> |
The <xsl:copy-of> element creates a copy of the current node.
Note: Namespace nodes, child nodes, and attributes of the current node are automatically copied as well ("deep copy").
Tip: This element can be used to insert multiple copies of the same node into different places in the output.
|
| decimal-format |
<xsl:decimal-format name="name" decimal-separator="char" grouping-separator="char" infinity="string" minus-sign="char" NaN="string" percent="char" per-mille="char" zero-digit="char" digit="char" pattern-separator="char"/> |
The <xsl:decimal-format> element defines the characters and symbols to be used when converting numbers into strings, with the format-number() function.
All countries do not use the same characters for separating the decimal part from the integer part, and for grouping digits. With the <xsl:decimal-format> element you can change special characters to other symbols.
This element is a top level element.
The format-number() function can refer to the <xsl:decimal-format> element by name.
|
| element |
<xsl:element name="name" namespace="URI" use-attribute-sets="namelist">
<!-- Content:template -->
</xsl:element> |
The <xsl:element> element is used to create an element node in the output document.
|
| fallback |
<xsl:fallback>
<!-- Content: template -->
</xsl:fallback> |
The <xsl:fallback> element specifies an alternate code to run if the XSL processor does not support an XSL element.
|
| for-each |
<xsl:for-each select="expression">
<!-- Content:(xsl:sort*,template) -->
</xsl:for-each> |
The <xsl:for-each> element loops through each node in a specified node set.
|
| if |
<xsl:if test="expression">
<!-- Content: template -->
</xsl:if> |
The <xsl:if> element contains a template that will be applied only if a specified condition is true.
Tip: Use <xsl:choose> in conjunction with <xsl:when> and <xsl:otherwise> to express multiple conditional tests!
|
| import |
<xsl:import href="URI"/> |
The <xsl:import> element is a top-level element that is used to import the contents of one style sheet into another.
Note: An imported style sheet has lower precedence than the importing style sheet.
Note: This element must appear as the first child node of <xsl:stylesheet> or <xsl:transform>.
|
| include |
<xsl:include href="URI"/> |
The <xsl:include> element is a top-level element that includes the contents of one style sheet into another.
Note: An included style sheet has the same precedence as the including style sheet.
Note: This element must appear as a child node of <xsl:stylesheet> or <xsl:transform>.
|
| key |
<xsl:key name="name" match="pattern" use="expression"/> |
The <xsl:key> element is a top-level element which declares a named key that can be used in the style sheet with the key() function.
Note: A key does not have to be unique!
|
| message |
<xsl:message terminate="yes|no">
<!-- Content:template -->
</xsl:message> |
The <xsl:message> element writes a message to the output. This element is primarily used to report errors. This element can contain almost any other XSL element (<xsl:text>, <xsl:value-of>, etc.). The terminate attribute gives you the choice to either quit or continue the processing when an error occurs. |
| namespace-alias |
<xsl:namespace-alias stylesheet-prefix="prefix|#default" result-prefix="prefix|"#default"/> |
The <xsl:namespace-alias> element is used to replace a namespace in the style sheet to a different namespace in the output.
Note: <xsl:namespace-alias> is a top-level element, and must be a child node of <xsl:stylesheet> or <xsl:transform>.
|
| number |
<xsl:number count="expression" level="single|multiple|any" from="expression" value="expression" format="formatstring" lang="languagecode" letter-value="alphabetic|traditional" grouping-separator="character" grouping-size="number"/> |
The <xsl:number> element is used to determine the integer position of the current node in the source. It is also used to format a number. |
| otherwise |
<xsl:otherwise>
<!-- Content:template -->
</xsl:otherwise> |
The <xsl:otherwise> element specifies a default action for the <xsl:choose> element. This action will take place when none of the <xsl:when> conditions apply. |
| output |
<xsl:output method="xml|html|text|name" version="string" encoding="string" omit-xml-declaration="yes|no" standalone="yes|no" doctype-public="string" doctype-system="string" cdata-section-elements="namelist" indent="yes|no" media-type="string"/> |
The <xsl:output> element defines the format of the output document.
Note : <xsl:output> is a top-level element, and must appear as a child node of <xsl:stylesheet> or <xsl:transform>.
|
| param |
<xsl:param name="name" select="expression">
<!-- Content:template -->
</xsl:param>
|
The <xsl:param> element is used to declare a local or global parameter.
Note: The parameter is global if it's declared as a top-level element, and local if it's declared within a template.
|
| preserve-space |
<xsl:preserve-space elements="list-of-element-names"/> |
The <xsl:preserve-space> element is used to define the elements for which white space should be preserved.
Note: Preserving white space is the default setting, so using the <xsl:preserve-space> element is only necessary if the <xsl:strip-space> element is used.
Note: The <xsl:preserve-space> element and the <xsl:strip-space> element are top-level elements.
|
| processing-instruction |
<xsl:processing-instruction name="process-name">
<!-- Content:template -->
</xsl:processing-instruction> |
The <xsl:processing-instruction> element writes a processing instruction to the output. |
| sort |
<xsl:sort select="expression" lang="language-code" data-type="text|number|qname" order="ascending|descending" case-order="upper-first|lower-first"/> |
The <xsl:sort> element is used to sort the output.
Note: <xsl:sort> is always within <xsl:for-each> or <xsl:apply-templates>.
|
| strip-space |
<xsl:strip-space elements="list-of-element-names"/> |
The <xsl:strip-space> element is used to define the elements for which white space should be removed.
Note: The <xsl:preserve-space> element and the <xsl:strip-space> element are top-level elements.
|
| stylesheet |
<xsl:stylesheet id="name" version="version" extension-element-prefixes="list" exclude-result-prefixes="list">
<!-- Content:(<xsl:import>*,top-level-elements) -->
</xsl:stylesheet> |
The <xsl:stylesheet> and <xsl:transform> elements are completely synonymous elements. Both are used to define the root element of the style sheet. |
| template |
<xsl:template name="name" match="pattern" mode="mode" priority="number">
<!-- Content:(<xsl:param>*,template) -->
</xsl:template> |
The <xsl:template> element contains rules to apply when a specified node is matched.
The match attribute is used to associate the template with an XML element. The match attribute can also be used to define a template for a whole branch of the XML document (i.e. match="/" defines the whole document).
Note: <xsl:template> is a top-level element.
|
| text |
<xsl:text disable-output-escaping="yes|no">
<!-- Content:#PCDATA -->
</xsl:text> |
The <xsl:text> element is used to write literal text to the output.
Tip: This element may contain literal text, entity references, and #PCDATA.
|
| transform |
<xsl:transform id="name" version="version" extension-element-prefixes="list" exclude-result-prefixes="list">
<!-- Content:(<xsl:import>*,top-level-elements) -->
</xsl:transform>
|
The <xsl:stylesheet> and <xsl:transform> elements are completely synonymous elements. Both are used to define the root element of the style sheet. |
| value-of |
<xsl:value-of select="expression" disable-output-escaping="yes|no"/> |
The <xsl:value-of> element element extracts the value of a selected node.
The <xsl:value-of> element can be used to select the value of an XML element and add it to the output.
Note: The value of the required select attribute contains an XPath expression. It works like navigating a file system where a forward slash (/) selects subdirectories.
|
| variable |
<xsl:variable name="name" select="expression">
<!-- Content:template -->
</xsl:variable> |
The <xsl:variable> element is used to declare a local or global variable.
Note: The variable is global if it's declared as a top-level element, and local if it's declared within a template.
Note: Once you have set a variable's value, you cannot change or modify that value!
Tip: You can add a value to a variable by the content of the <xsl:variable> element OR by the select attribute!
|
| when |
<xsl:when test="boolean-expression">
<!-- Content: template -->
</xsl:when> |
The <xsl:when> element is used to specify an action for the <xsl:choose> element. The <xsl:when> element evaluates an expression, and if it returns true, an action is performed.
Note: The <xsl:when> element is used in conjunction with <xsl:choose> and <xsl:otherwise> to express multiple conditional tests.
|
| with-param |
<xsl:with-param name="name" select="expression">
<!-- Content:template -->
</xsl:with-param> |
The <xsl:with-param> element defines the value of a parameter to be passed into a template.
Note: The value of the name attribute of <xsl:with-param> must match a name in an <xsl:param> element (the <xsl:with-param> element is ignored if there is no match).
Note: The <xsl:with-param> element is allowed within <xsl:apply-templates> and <xsl:call-template>.
Tip: You can add a value to the parameter by the content of the <xsl:with-param> element OR by the select attribute!
|