XSLT magick
March 4, 2009 1 Comment
I never stop wondering about about the strange things in XSLT.. here is one i stumbled upon jesterday. I wanted to pass a variable containing a string(item name) to a template.
this template was written by another developer,.. it didn’t have any parameter defined so using with-param was out of the question. And because it was used elsewhere i couldn’t alter it ,.so after i spend couple hours on searching the web and some trail and error.. i was stunned to find out how it can be done.
the template…
<xsl:template name=“giveMeItemname”>
…<xsl:iftest=“sc:fld(‘itemname.fieldname‘,.)!=”“>
……<pclass=“text“>
………<xsl:value-ofselect=“sc:fld(‘itemname.fieldname‘,.)“disable-output-escaping=“yes“/>
……</p>
…</xsl:if>
</xsl:template>
set the paramater in yout c# code.
call template and pass the itemaname
<xsl:templatematch=“*“mode=“main“>
…<xsl:for-eachselect=“sc:item($itemname,.)“>
……<xsl:call-templatename=“giveMeItemname“/>
…</xsl:for-each>
</xsl:template>
and that’s how it is done (c:
Aw, this was an extremely good post. Taking the time and actual
effort to generate a superb article… but what can
I say… I hesitate a whole lot and don’t manage to get anything done.