The situation is I have two xslt files: one is called from my ASP.NET code, and there, the second xslt file is imported.
What I’d like to accomplish is to pass a parameter to the first one so the second xslt(the one that is imported at the first xslt) can read it.
My c# code looks like this:
var oArgs = new XsltArgumentList();
oArgs.AddParam("fbLikeFeatureName", "", "Facebook_Like_Button");
ltlContentBody.Text = xmlUtil.TransformXML(oXmlDoc, Server.MapPath(eSpaceId + "/styles/ExploringXSLT/ExploreContentObjects.xslt"), true);
And I’m catching the param at the first xslt this way:
<xsl:param name="fbLikeFeatureName" />
And then, passing it to the second xslt like this(previously, I import that file):
<xsl:call-template name="Articles">
<xsl:with-param name="fbLikeFeatureName"></xsl:with-param>
</xsl:call-template>
Finally, I’m catching the param on the second xslt file as following:
<xsl:value-of select="$fbLikeButtonName"/>
What Am I doing wrong? I’m kind of new at xslt.
You don’t need to “pass” the parameter from the first stylesheet to the imported stylesheet. When you declare the param at the top level on the first stylesheet, it is automatically visible to all imported stylesheets. Consider the following stylesheets:
template1.xsl:
Which imports template2.xsl:
I then transformed the following doc:
with the input parameter “input-param” set to “This is a test”. I get the following output (Saxon-B 9.1.0.7):