I am relatively new to XSL transforms so I apologize if my language or verbage is incorrect.
I am trying to invoke a JS function of a flash player which requires a URI. In order to do this I would like to take the RSS feed, the snippet below, and grab the uri from the <enclosure> tag. You will see that there is a &uri=channels/39174/186941 inside of the url="" i would like to grab this piece and insert it into my XSL <a href= as currently defined by $item_enclosure.
Here is my XML: -
<item>
-
<title>New Show: Mobile Show 434</title>
-
<link>http://www.kyte.tv/ch/39174-flocam/186941-mobile-show-434</link>
-
<guid>http://www.kyte.tv/ch/39174-flocam/186941-mobile-show-434</guid>
-
<description><a href='http://www.kyte.tv/ch/39174-flocam/186941-mobile-show-434'><img src='http://media06.kyte.tv/store/005/06/crr/0808/05/04/694822-37003-08042008077_120_90-tom-1000.jpg?aid=21808&h=c572dfe49ef7e0704a003559429b4605' title='Mobile Show 434' width='120' height='90' alt='Mobile Show 434' border='0'/></a><br>produced by coflo.</description>
-
-
<pubDate>Tue, 05 Aug 2008 04:10:00 +0000</pubDate>
-
<media:content url="http://www.kyte.tv/flash.swf?appKey=MarbachViewerEmbedded&uri=channels/39174/186941&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/186941&layoutMode=default" length="30" type="application/x-shockwave-flash"/>
-
</item>
-
-----------
As you can see in my XSL im able to pull the url and insert it but i have no idea how to extract the uri=channels/39174/186941
Here is my attempt XSL: -
<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"/>
-
<div class="subHead" style="width:300px;">
-
<a href="javascript:void(kyteplayer.setURI('{$item_enclosure}'))"><xsl:value-of select="title" disable-output-escaping="yes"/></a></div>
-
<div style="width:300px;">
-
<xsl:value-of select="description" disable-output-escaping="yes"/><br/></div>
-
-
(<xsl:value-of select="pubDate"/>)<br/> <hr/>
-
5 2926
Getting the url:
substring-after(//enclosure/@url/, 'uri=')
This gets everything after uri=
Now the problem is, is there another argument afterwards? If so, we can take everything before the &; if not we simply take the whole substring. -
<xsl:variable name="afterURI" select="substring-after(//enclosure/@url/, 'uri=')"/>
-
<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>
-
Then when you want to output this, -
<a href="javascript:void(kyteplayer.setURI('{$URIVal}'))"><xsl:value-of select="title" disable-output-escaping="yes"/></a>
-
I seem to be getting an error: SAXParseException: Unterminated entity reference
it is always pointing to the line that starts with - <xsl:variable name="afterURI" select="substring-after(//enclosure/@url/, '&uri=')"/>
Ahh!! I got it, took a bit of playing around but thank you so much for your help - here is my final result working! -
<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>
-
edit: humm the & isnt showing up correctly it should be & a m p
yeah, the code tags seem to automatically unescape & as &, sorry forgot about that quirk.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Newbie |
last post by:
How would I modify this form
to encode *all* the characters
in the 'source' textarea to the
'%xx' format & place result
code into the 'output' textarea?
(cross browser compatable)
Any help is...
|
by: Peter |
last post by:
Hi,
I try to make up a javascript string which contains numeric numbers in
any positions. For example, I want to make a string: secretcode, where
secretcode.charAt(0)==(-21),...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: Darrel |
last post by:
How does HTML.encode work?
I'm trying to save text in a hidden form field into a SQL DB. The tedt is
HTML (from a WYSIWYG editor...X-standard).
One problem I have is that stray apostrophe's in...
|
by: youngster94 |
last post by:
Hey all,
I've written a VB.Net app that creates picture badges complete with
barcodes. The problem is that the barcode quality is not good enough
to be read by scanners. I'm using the...
|
by: aurora |
last post by:
I have some unicode string with some characters encode using python
notation like '\n' for LF. I need to convert that to the actual LF
character. There is a 'unicode_escape' codec that seems to...
|
by: 7stud |
last post by:
s1 = "hello"
s2 = s1.encode("utf-8")
s1 = "an accented 'e': \xc3\xa9"
s2 = s1.encode("utf-8")
The last line produces the error:
---
Traceback (most recent call last):
|
by: tech |
last post by:
Hi, i have the following design issue. In our app we use different
codecs to encode/decode packets of data
I have defined a base codec class as follows
class CCodec
{
public:
CCodec() {};...
|
by: anonymous |
last post by:
1 Objective to write little programs to help me learn German. See code
after numbered comments. //Thanks in advance for any direction or
suggestions.
tk
2 Want keyboard answer input, for...
|
by: Mudcat |
last post by:
In short what I'm trying to do is read a document using an xml parser
and then upload that data back into a database. I've got the code more
or less completed using xml.etree.ElementTree for the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |