[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] replaceing a href in RSS link with xsl regex?


Subject: [xsl] replaceing a href in RSS link with xsl regex?
From: Co <ineedsoul@xxxxxxxxx>
Date: Tue, 19 Aug 2008 13:34:16 -0700

Hello I would like to replace an a href link that is provided in the
RSS below with my own link.  The link that I am looking to replace is
defined in the <description> tag within the RSS.  Im guessing I need
to use some sort of function in combination with regex.

I am able to create a regex to find and replace the a href link very
easily; however, using regex in combination with a find and replace in
XSL i am extremly novice.

I am wanting to replace the <description> a href:
[code]
a href='http://www.kyte.tv/ch/39174-flocam/185592-live-mobile-show'
[/code]

With this a href:
[code]
a href='javascript:void(kyteplayer.setURI('{$URIVal}'))'
[/code]

XML snippet:
[code]
<item>
<title>New Show: Live Mobile Show</title>
<link>http://www.kyte.tv/ch/39174-flocam/185592-live-mobile-show</link>
<guid>http://www.kyte.tv/ch/39174-flocam/185592-live-mobile-show</guid>
<description>&lt;a
href='http://www.kyte.tv/ch/39174-flocam/185592-live-mobile-show'&gt;&lt;img
src='http://media08.kyte.tv/store/005/08/crr/0808/02/23/689407-0-47639mobile_689407_120_90-tom-5000.jpg?aid=21808&amp;h=44fade2ef70a4df7e890f5f77c87f5d9'
title='Live Mobile Show' width='120' height='90' alt='Live Mobile
Show' border='0'/&gt;&lt;/a&gt;&lt;br&gt;produced by
tenofquad.</description>

<pubDate>Sat, 02 Aug 2008 23:18:20 +0000</pubDate>
<media:content url="http://www.kyte.tv/flash.swf?appKey=MarbachViewerEmbedded&amp;uri=channels/39174/185592&amp;layoutMode=default"
fileSize="30" type="application/x-shockwave-flash" height="425"
width="425" duration="1"/>
<enclosure url="http://www.kyte.tv/flash.swf?appKey=MarbachViewerEmbedded&amp;uri=channels/39174/185592&amp;layoutMode=default"
length="30" type="application/x-shockwave-flash"/>
</item>
[/code]

My XSL snippet:
[code]
     <xsl:template match="item">

        <xsl:variable name="item_link" select="link"/>

        <xsl:variable name="item_enclosure" select="enclosure/@url"/>

        <xsl:variable name="item_title" select="description"/>

        <xsl:variable name="item_media" select="media"/>


      <xsl:variable name="afterURI">

      <xsl:value-of select = "substring-after($item_enclosure, '&amp;uri=')" />

      </xsl:variable>

             <xsl:variable name="URIVal">

              <xsl:choose>

                  <xsl:when test="contains($afterURI, '&amp;')">

                     <xsl:value-of select="substring-before($afterURI,
'&amp;')"/>

                  </xsl:when>

                  <xsl:otherwise>

                    <xsl:value-of select="$afterURI"/>

                  </xsl:otherwise>

               </xsl:choose>

            </xsl:variable>

        <div class="subHead" style="width:500px;">
          <a href="javascript:void(kyteplayer.setURI('{$URIVal}'))"><xsl:value-of
select="title" disable-output-escaping="yes"/></a></div>

          <div style="width:500px;">

       <xsl:value-of select="description"
disable-output-escaping="yes"/><br/></div>


       (<xsl:value-of select="pubDate"/>)<br/> <hr/>

       </xsl:template>
[/code]

This was one of my attempts but I feel I am going in the wrong direction:

[code]
<xsl:variable name="image_change" select="description" />
  <xsl:variable name="links">
     <xsl:for-each select="$image_change">
        <changeplease><a
href="javascript:void(kyteplayer.setURI('{$URIVal}'))"><xsl:value-of
select="." /></a></changeplease>
     </xsl:for-each>
  </xsl:variable>
  <xsl:copy-of select="str:replace($image_change,
'exsl:node-set($links)/changeplease')" />
[/code]

Please any help would be great! THANKS!


Current Thread
Keywords