3. Template Usage
<xsl:template name="proc"> <xsl:param name="txt" select="''"/> <value> <xsl:choose> <xsl:when test="contains($txt, '|')" > <xsl:value-of select="substring-before($txt, '|')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$txt"/> </xsl:otherwise> </xsl:choose> </value> <xsl:variable name="left" select="substring-after($txt, '|')"/> <xsl:if test="string-length($left)>1" > <xsl:call-template name="proc" > <xsl:with-param name="txt" select="$left"/> </xsl:call-template> </xsl:if> </xsl:template>
3.1 In the template above name the computing technique being used?
Recursion
1 points
3.2 Please give one benefit and one disadvantage of this technique
Benefit Generates new variables on each iteration Disadvantage Resource hungry2 points
<xsl:template match="h:parameter[@name='order']/h:value"> <xsl:variable name="values"> <xsl:call-template name="proc" > <xsl:with-param name="txt" select="text()"/> </xsl:call-template> </xsl:variable> <xsl:for-each select="xalan:nodeset($values)/value"> <SetGroupTitleJournalOrder group="1" title="{.}" sort="{position()}"/> </xsl:for-each> </xsl:template>
3.2 In the XSL 1.0 template above describe the purpose of xalan:nodeset?
It's a XalanJ extension function that allows processing of result tree fragments in XSLT 1.0
3.3 Why is the following stylesheet often used by XSL developers?
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
______________________________________________________________________________________ ______________________________________________________________________________________ ______________________________________________________________________________________ ______________________________________________________________________________________ ______________________________________________________________________________________