XSLT magick

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:

Advertisements

One Response to XSLT magick

  1. Alice says:

    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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: