help replacing link in description tab

Here should go questions about transforming XML with XSLT and FOP.
coflo
Posts: 4
Joined: Tue Aug 12, 2008 3:48 pm

help replacing link in description tab

Post by coflo »

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: Select all


a href='http://www.kyte.tv/ch/39174-flocam/185592-live-mobile-show'
With this a href:

Code: Select all


a href='javascript:void(kyteplayer.setURI('{$URIVal}'))'
XML snippet:

Code: Select all


<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><a href='http://www.kyte.tv/ch/39174-flocam/185592-live-mobile-show'><img src='http://media08.kyte.tv/store/005/08/crr/0808/02/23/689407-0-47639mobile_689407_120_90-tom-5000.jpg?aid=21808&h=44fade2ef70a4df7e890f5f77c87f5d9' title='Live Mobile Show' width='120' height='90' alt='Live Mobile Show' border='0'/></a><br>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&uri=channels/39174/185592&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&uri=channels/39174/185592&layoutMode=default" length="30" type="application/x-shockwave-flash"/>
</item>
My XSL snippet:

Code: Select all


     <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, '&uri=')" />

</xsl:variable>

<xsl:variable name="URIVal">

<xsl:choose>

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

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

</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>
This was one of my attempts but I feel I am going in the wrong direction:

Code: Select all


<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')" />
Please any help would be great! THANKS!
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: help replacing link in description tab

Post by sorin_ristache »

Hello,

You should post this question to the XSL-List mailing list where you can find many experienced XSLT developers.


Regards,
Sorin
coflo
Posts: 4
Joined: Tue Aug 12, 2008 3:48 pm

Re: help replacing link in description tab

Post by coflo »

I have signed up for the email list and tried multiple times to email the address to post my questions but i just keep getting a bounce back error. Wow, i never thought joining an email list would be this hard. Any ideas on how to post my question. I have read through all of their instructions, FAQ's and pre-post requirements and cannot seem to find the answer.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: help replacing link in description tab

Post by sorin_ristache »

Hello,

If you filled the subscription form but you were not subscribed you should contact the administrator at xsl-list-owner@lists.mulberrytech.com.


Regards,
Sorin
coflo
Posts: 4
Joined: Tue Aug 12, 2008 3:48 pm

Re: help replacing link in description tab

Post by coflo »

I was subscribed but there isn't a way for me to post to the list. The email address provided to post to the list
To post to the list, e-mail:
<xsl-list@lists.mulberrytech.com>

bounces back an error.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: help replacing link in description tab

Post by sorin_ristache »

If you were subscribed you should receive messages from the list. For example there were two messages in the last two hours. If you receive messages from the list the list server should allow you to send messages to xsl-list@lists.mulberrytech.com. If you receive messages from the list but your messages sent to the list bounce back then probably there is a problem with your domain name (it is blacklisted for example). In this case you should contact the human administrator of the list at xsl-list-owner@lists.mulberrytech.com with a message sent from other domain name so that your message can be received there.


Regards,
Sorin
coflo
Posts: 4
Joined: Tue Aug 12, 2008 3:48 pm

Re: help replacing link in description tab

Post by coflo »

Yes I am getting the emails from the list; however, I am still getting my email bounced back, i will contact the admin. Thanks
Post Reply