Jump to content

Passing A Parameter To A Function


Krishn60
 Share

Recommended Posts

Hi Forgive me, if I am posting too many questions. I don't know anyting about XSLT and I am asked to do certain task. Thanks for your help in advance.I am trying to pass parameter from within an XSLT code to a function within it. I could see the value of @Comment in the "AAA" line. <xsl:template match="CartoonComment"> <xsl:for-each select="."> <xsl:variable name="wrkComment"> <--------------------------(AAA)------------------------------------> <xsl:call-template name="MODIFYVALUE"> <xsl:with-param name="text" select="@Comment"/> </xsl:call-template> </xsl:variable> NTE||<xsl:value-of select="$wrkComment"/>| </xsl:for-each> </xsl:template>But the value is not going in to the function. When I check the function it is blank at the (BBB) line. Can anyone please tell me what is wrong in me passing on the parameter.<xsl:template name="MODIFYVALUE"> <xsl:param name="tmpwrkField"/> <xsl:value-of select="$tmpwrkField"/> <------------------------(BBB)------------------------- <xsl:variable name="wrkField1"> <xsl:call-template name="SEARCH-AND-REPLACE"> <xsl:with-param name="text" select="$tmpwrkField"/> <xsl:with-param name="replace" select="'&'"/> <xsl:with-param name="by" select="'\T\'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="tmpwrkField1" select="$wrkField1"/> <xsl:variable name="wrkField2"> <xsl:call-template name="SEARCH-AND-REPLACE"> <xsl:with-param name="text" select="$tmpwrkField1"/> <xsl:with-param name="replace" select="'|'"/> <xsl:with-param name="by" select="'\F\'"/> </xsl:call-template> </xsl:variable>.................ThanksKrishnan

Link to comment
Share on other sites

It depends on your XML really, as you're setting your "tmpwrkField" with the value of the "Comment" attribute, on a "CartoonComment" element, like so:

<CartoonComment Comment="Some text" />

BTW, remove the for-each, will you? It's redunant, or wose - it may be the reason for the problem.

Link to comment
Share on other sites

No, it didn't work either. My XML code is <AnnimateConversion Catch-up="N"> <Cartoonist> <Cartoon> <Cartoon Data Organization="IH" MRN="01-01-79" DeptNum="" CARNumEXT="5" CARDate="10/03/2002" EnteredBy="ZZ0006" Procedure="" Technique="" BelongClassification="BENIGN" OutsideInstitution="" OutsideDesignID="" Side="L"/> <CartoonComments> <CartoonComment Comment="MASS DISAPPEARED ^ WHEN ~ PUNCTURED | BY NEEDLE."/> </CartoonComments> </Cartoon> </Cartoonist></AnnimateConversion>My intention is to remove the special characters (there may be more than one) in the CartoonComment Comment. It is exactly how you stated. The reason why I used each is because Comment can be of multiple lines under multiple CartoonComment element.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...