XML Glossary - 3 XSL

comment to include


<xsl:comment> any comment can go here </xsl:comment>

XML can contain ordinary <!-- HTML type --> comments but these are ignored by the XSL parser. Use XSL:COMMENT tags to generate a HTML type comment within the final document.


<xsl:constant name="name" value="value" />

Defines a particular constant that can be substituted in all documents linked to the XSL stlylesheet. Use the value using the "constant" function:

<xsl:template match="example">
<a href={constant(name)}>

XSL:FOR-EACH. Repeat XSL processing for each instance of identical XML elements. This can be used to create a summary list or table of contents. Only elements which exactly match the selection pattern of the template. e.g. if the template matches the element <book>, the for-each statement matches the <chapter> element and the contents of the <title> element are used for the table of contents. The XSL would follow the pattern:

<xsl:template match="book">
<ul> <xsl:for-each select="chapter">
<li> <xsl:process select="title"></li>
</xsl:for-each> </ul> </xsl:template>

XSL:IF. Select a specific element while inside a template. Use alongside the tests outlined in XSL:CHOOSE - first-of-type(), last-of-type(), first-of-any(), last-of-any() - to create, for example, a comma separated list:

<xsl:template match="CODEHELP/NAVIGATE">
<xsl:apply-templates />
<xsl:if test=".not([last-of-type()])">, </xsl:if>

XSL:IMPORT. Use as the first element in an XSL stylesheet to import rules from an external stylesheet. Imported rules will be overwritten by any subsequent matching rules within the importing stylesheet. If more than one stylesheet is imported, the stylesheets imported last will override each previous import where the rules match.

<xsl:import href="anotherxsl.xsl" />

XSL:INCLUDE. Include rules from an external stylesheet at a specific location within an XSL stylesheet. The xsl:include element will be directly replaced by rules from the included stylesheet. Unlike xsl:import, the included rules have equal priority to the rules in the rest of the stylesheet. For this reason, be careful that you know what is in the included file including changes, as results from matching rules can be unpredictable.

<xsl:include href="anotherxsl.xsl" />

This is part of www.codehelp.co.uk Copyright © 1998-2004 Neil Williams
See the file about.html for copying conditions.