I have this xslt:
<xsl:template name="dumpDebugData">
<xsl:param name="elementToDump" />
<xsl:for-each select="$elementToDump/@*">
<xsl:text> </xsl:text> <!-- newline char -->
<xsl:value-of select="name()" /> : <xsl:value-of select="." />
</xsl:for-each>
</xsl:template>
i want to display every element (as in name/value), how do i call this template?
By invoke, we mean that the named template is called and applied to the source document. If a template does not have a name, it cannot be called by this element. The xsl:template element is used to create a template. You can name a template by using the name attribute of the xsl:template element.
To use an XSLT parameterCreate an XsltArgumentList object and add the parameter using the AddParam method. Call the parameter from the style sheet. Pass the XsltArgumentList object to the Transform method.
You are applying templates selecting folders , but have a template matching on folder . Either change it to folder , or if you have a folders template make sure that it passes the var1 parameter value down to the folder template. Your with-param @select uses '{var}' , which selects that literal string {var} .
Answer. In order to pass multiple parameters to XSLT from BP you'll need to pass '=' as a separator.
Since the template expects a node set, you must do:
<xsl:call-template name="dumpDebugData">
<xsl:with-param name="elementToDump" select="some/xpath" />
</xsl:call-template>
Try something like this:
<xsl:call-template name="dumpDebugData">
<xsl:with-param name="elementToDump">foo</xsl:with-param>
</xsl:call-template>
The original answer does not use the parameter. It only works if the paramater = the current element. This takes the parameter into account.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="element()">
<xsl:call-template name="dumpDebugData">
<xsl:with-param name="elementToDump" select="." />
</xsl:call-template>
<xsl:apply-templates />
</xsl:template>
<xsl:template name="dumpDebugData">
<xsl:param name="elementToDump" />
Node:
<xsl:value-of select="name($elementToDump)" />
:
<xsl:value-of select="text($elementToDump)" />
<xsl:for-each select="$elementToDump/@*">
Attribute:
<xsl:value-of select="name()" />
:
<xsl:value-of select="." />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With