RE: [xsl] Something like eval()? and Thanks!

Subject: RE: [xsl] Something like eval()? and Thanks!
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 7 Nov 2001 19:04:16 -0000
This is essentially what the xx:evaluate() extension function in Saxon and
some other products does.

Mike Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of McKeever,
> Marty
> Sent: 07 November 2001 14:35
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Something like eval()? and Thanks!
>
>
> Thanks to all who offered solutions to my multile
> match-->single output
> problem.  I have much to ponder over the weekend and am sure
> i will learn
> alot.  Apparently it was more difficult than i'd hoped, so i dont feel
> "quite" as dumb for not finding the solution quickly.
>
> Now, for an even crazier idea.
> Is there any way to force a string of the format "$foo" to
> evaluate into the
> matching parameter named $foo.
> I've looked for an extension function that would do this with no luck.
> Surely something exists.
>
> The scenario:
> XML Input: <a href="foo.htm?custID=$custID">My Account</a>
> And passing an external parameter for $custID (23456)
>
> I can easily search & replace the custID=$custID with the value of the
> parameter, IF i already know that "custID" is what needs to
> be matched.
>
> What i'm hoping for is a more generic parameter matching
> system, where my
> XML might look like:
> <a href="foo.htm?custID={$custID}">My Account</a>
> and i could do the following:
>
> <xsl:variable name="flagged">
> <xsl:if test="contains(@href,'{$')">
>   <xsl:value-of select="substring-after(substring
> before(@href,'}'),'{$')"/>
>
> </xsl:if>
> </xsl:variable>
>
> to extract the name of my matching variable from the href,
> then call my
> replace template with this value evaluated into the matching
> parameter:
>
> <xsl:call-template name="replace">
> <xsl:with-param name="inputString" select="@href">
> <xsl:with-param name="changeFrom" select="concat('{$',$flagged,'}')">
> <xsl:with-param name="changeTo" select="EVAL(concat('$',$flagged))">
> </xsl:call-template>
>
> Am i crazy for thinking this might work?
> Or am i clueless and missing the point?
>
> Thanks again -- you guys rock!
>
> Marty
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread