RE: [xsl] Converting embedded URLs int hot links via XSL

Subject: RE: [xsl] Converting embedded URLs int hot links via XSL
From: Ghulam Abbas <abbasg_99@xxxxxxxxx>
Date: Sat, 17 Apr 2004 13:42:06 -0700 (PDT)
Sorry about that. 
Here is what I"m doing

<xsl:template name="extract">
<xsl:param name="strEmbUrl"/>
<xsl:param name="delim1"/>
<xsl:param name="delim2"/>
<xsl:when test="contains($strEmbUrl, $delim1)">
<xsl:variable name="strB4"
select="substring-before($strEmbUrl, $delim1)"/>
<xsl:variable name="strAfter"
select="substring-after($strEmbUrl, $delim1)"/>
<xsl:variable name="lastCh"
<xsl:when test="$lastCh = $delim2">	
<xsl:when test="contains($strAfter, $delim2)">
<xsl:variable name="emURL"
select="substring-before($strAfter, $delim2)"/>
<!-- #1 Solution -->
<xsl:value-of select="$strB4"/>&lt;a
href="<xsl:value-of select="concat($delim1,$emURL)"/>"
select="concat($delim1, $emURL)"/>&lt;/a&gt;>
<!-- #2 Solution -->
<xsl:value-of select="$strB4"/><xsl:variable
name="link" select="concat($delim1,$emURL)"/>
<a target="_blank" href="{$link}">
<xsl:value-of select="$link"/></a>
<!-- #3 Solution -->
<xsl:value-of select="$strB4"/><xsl:element
name="A"><xsl:attribute name="href"><xsl:value-of
select="concat($delim1, $emURL)"/></xsl:element>
<!-- end problematic code -->

<xsl:call-template name="extract">
<xsl:with-param name="delim1" select="$delim1"/>
<xsl:with-param name="delim2" select="$delim2"/>
<xsl:with-param name="strEmbUrl"><xsl:value-of
<xsl:value-of select="$strEmbUrl"/>
<xsl:value-of select="$strEmbUrl"/>
<xsl:otherwise><xsl:value-of select="$strEmbUrl"/>

<xsl:template name="extractEmbeddedURLs">
<xsl:param name="str"/>
<xsl:call-template name="extract">
<xsl:with-param name="delim1" select="'http://'"/>
<xsl:with-param name="delim2">'</xsl:with-param>
<xsl:with-param name="strEmbUrl">
<xsl:call-template name="extract">
<xsl:with-param name="delim1" select="'http://'"/>
<xsl:with-param name="delim2">"</xsl:with-param>
<xsl:with-param name="strEmbUrl" select="$str"/>

Solution 1,2,3 are the problem area. I tried these 3
but first iteration works fine but when it goes into
the subsequent iteration string containing html is
lost somewhere. i.e. If I call extract only once then
it works fine and browser is able to render the html
but recursion seems to have some problem.

Ghulam Abbas

--- Michael Kay <mhk@xxxxxxxxx> wrote:
> > 
> > I've tried recursion but it doesn't work. Any
> ideas???
> > 
> There is a bug in your code. How do you expect
> anyone to tell you where
> you've gone wrong if you don't show us your code?
> It's necessary to show your code for two reasons:
> (a) so people can tell you where your mistakes are
> (b) so people can judge your level of experience and
> knowledge, and phrase
> their replies accordingly.
> Michael Kay

Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25"

Current Thread