<xsl:template name="secTemplate"> <xsl:param name="parmA" /> <xsl:text>Parm A:</xsl:text> <xsl:value-of select="$parmA" /> <!-- this is not being displayed --> </xsl:template>
<xsl:template name="secTemplate"> <xsl:param name="parmA" /> <xsl:text>Parm A:</xsl:text> <xsl:value-of select="$parmA" /> <!-- this is not being displayed --> </xsl:template>
</xsl:stylesheet>
Also try changing the with-param statement to this:
Once again you have resolved my issue - and so promptly!
Obviously, my use for this is more complex. I intend to place my
frequently used logic in generic in xslt files. Any customization
needed will be in other xslt files and I'll reference the generic ones passing parameters as needed.
I learned I can reference external xslt files by adding this to the calling one:
XSLT parameter not being displayed
Hello Umbraco colleagues:
I can't figure out why this simple xslt will not display the value of the parameter being passed to it.
I'd like to use the technique to improve code reuse.
The template "secTemplate" will display the text, "Parm A:" but not the value of parmA.
I'm sure it must be simple but I'm not seeing it.
Thanks!
David Hill
Here's the xslt:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:call-template name="secTemplate">
<xsl:with-param name="parmA" select="abcdef" />
</xsl:call-template>
</xsl:template>
<xsl:template name="secTemplate">
<xsl:param name="parmA" />
<xsl:text>Parm A:</xsl:text>
<xsl:value-of select="$parmA" /> <!-- this is not being displayed -->
</xsl:template>
</xsl:stylesheet>
Hi David,
Your string needs to be in single quotes for it to be recognised as a string.
I.e. Change this line:
To this:
And you will see it works :)
And the complete copy of your XSLT with the change:
Also try changing the with-param statement to this:
And then you will see the node name output in your secTemplate.
Cheers,
Chris
Chris,
Thank you. That was precisely the issue.
Once again you have resolved my issue - and so promptly!
Obviously, my use for this is more complex. I intend to place my frequently used logic in generic in xslt files. Any customization needed will be in other xslt files and I'll reference the generic ones passing parameters as needed.
I learned I can reference external xslt files by adding this to the calling one:
Thanks again!
David
is working on a reply...