Applying Style

Applying Style One model for applying style is to allow the process to run recursively, driven primarily by the document. A series of templates is created, such that there is a template to match each context, then these templates are recursively applied starting at the root of the document. • <xsl:template> <xsl:template match=”section/title”> <h2><xsl:apply-templates/></h2> </xsl:template> …

Applying Style Read More »

Conflict Resolution

Conflict Resolution The problem of multiple patterns that match is handled by conflict resolution: • Matching templates from imported modules are not considered if there is a matching template in the current module • Matching templates with a lower priority are not considered. The default priority is determined as follows: • Unqualified child or attribute …

Conflict Resolution Read More »

Applying Style Procedurally

Applying Style Procedurally The other model for applying style is to select each action procedurally. A series of templates is created, such that each template explicitly selects and processes the necessary elements. • <xsl:for-each> <xsl:for-each select=”row”> <tr><xsl:apply-templates/></tr> </xsl:for-each> • Named Templates • <xsl:param> <xsl:param name=”type”>warning</xsl:param> • <xsl:call-template> <xsl:call-template name=”admonition”/> • <xsl:with-param> <xsl:call-template name=”admonition”> <xsl:with-param name=”type”>caution</xsl:with-param> …

Applying Style Procedurally Read More »

Named Template Example

Named Template Example namedtemplate.xml <?xml version=”1.0″ encoding=”iso-8859-1″?> <?xml-stylesheet type=”text/xsl” href=”named_temp_example.xsl”?> <chapter> <warning> <para>Using a damaged extension cord may cause a fire.</para> </warning> <caution> <para>Freshly brewed coffee is hot.</para> </caution> </chapter> namedtemplate.xsl <xsl:stylesheet version=”1.0″ xmlns:xsl=””> <xsl:output method=”html” encoding=”iso-8859-1″ /> <xsl:template name=”admonition”> <xsl:param name=”type”>Warning</xsl:param> <table border=”1″> <tr><th><xsl:value-of select=”$type”/>:</th></tr> <tr><td><xsl:apply-templates/></td></tr> </table> </xsl:template> <xsl:template match=”warning”> <xsl:call-template name=”admonition”/> </xsl:template> <xsl:template …

Named Template Example Read More »

Creating the Result Tree

Creating the Result Tree Literal Result Elements Any element in a template rule that is not in the XSL (or other extension) namespace is copied literally to the result tree <xsl:text> The content of <xsl:text> elements is copied directly to the result tree; whitespace is preserved by default <xsl:text>Literal result text</xsl:text> <xsl:value-of> Inserts the value …

Creating the Result Tree Read More »

Conditional Processing

Conditional Processing The xsl:if element evaluates an expression which returns a Boolean result to determine if a template should be instantiated. The evaluation is a simple True or False test on a defined condition or a set of conditions. If the test returns True, the template is applied and the results are displayed in the output. If False, the template is not applied (i.e., …

Conditional Processing Read More »

Scroll to Top