473,589 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pulling and using an uri from an rss encode tag

9 New Member
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=channel s/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:
Expand|Select|Wrap|Line Numbers
  1. <item>
  2. <title>New Show: Mobile Show 434</title>
  3. <link>http://www.kyte.tv/ch/39174-flocam/186941-mobile-show-434</link>
  4. <guid>http://www.kyte.tv/ch/39174-flocam/186941-mobile-show-434</guid>
  5. <description>&lt;a href='http://www.kyte.tv/ch/39174-flocam/186941-mobile-show-434'&gt;&lt;img src='http://media06.kyte.tv/store/005/06/crr/0808/05/04/694822-37003-08042008077_120_90-tom-1000.jpg?aid=21808&amp;h=c572dfe49ef7e0704a003559429b4605' title='Mobile Show 434' width='120' height='90' alt='Mobile Show 434' border='0'/&gt;&lt;/a&gt;&lt;br&gt;produced by coflo.</description>
  7. <pubDate>Tue, 05 Aug 2008 04:10:00 +0000</pubDate>
  8. <media:content url="http://www.kyte.tv/flash.swf?appKey=MarbachViewerEmbedded&amp;uri=channels/39174/186941&amp;layoutMode=default" fileSize="30" type="application/x-shockwave-flash" height="425" width="425" duration="1"/>
  9. <enclosure url="http://www.kyte.tv/flash.swf?appKey=MarbachViewerEmbedded&amp;uri=channels/39174/186941&amp;layoutMode=default" length="30" type="application/x-shockwave-flash"/>
  10. </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:

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="item">
  2. <xsl:variable name="item_link" select="link"/>
  3. <xsl:variable name="item_enclosure" select="enclosure/@url"/>
  4. <xsl:variable name="item_title" select="description"/>
  5. <xsl:variable name="item_media" select="media"/>
  6. <div class="subHead" style="width:300px;">
  7. <a href="javascript:void(kyteplayer.setURI('{$item_enclosure}'))"><xsl:value-of select="title" disable-output-escaping="yes"/></a></div>
  8. <div style="width:300px;">
  9. <xsl:value-of select="description" disable-output-escaping="yes"/><br/></div>
  11. (<xsl:value-of select="pubDate"/>)<br/> <hr/>
Aug 5 '08 #1
5 2947
2,057 Recognized Expert Top Contributor
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.
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name="afterURI" select="substring-after(//enclosure/@url/, 'uri=')"/>
  2. <xsl:variable name="URIVal">
  3.   <xsl:choose> 
  4.       <xsl:when test="contains($afterURI, '&amp;amp;')">
  5.          <xsl:value-of select="substring-before($afterURI, '&amp;amp;')"/>
  6.       </xsl:when>
  7.       <xsl:otherwise>
  8.         <xsl:value-of select="$afterURI"/>
  9.       </xsl:otherwise>
  10.    </xsl:choose>
  11. </xsl:variable>
Then when you want to output this,
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(kyteplayer.setURI('{$URIVal}'))"><xsl:value-of select="title" disable-output-escaping="yes"/></a>
Aug 7 '08 #2
9 New Member
I seem to be getting an error: SAXParseExcepti on: Unterminated entity reference

it is always pointing to the line that starts with
Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name="afterURI" select="substring-after(//enclosure/@url/, '&uri=')"/>
Aug 7 '08 #3
9 New Member
Ahh!! I got it, took a bit of playing around but thank you so much for your help - here is my final result working!

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="item">
  5.   <xsl:variable name="item_link" select="link"/>
  6.   <xsl:variable name="item_enclosure" select="enclosure/@url"/>
  7.   <xsl:variable name="item_title" select="description"/>
  8.   <xsl:variable name="item_media" select="media"/> 
  10. <xsl:variable name="afterURI">
  11. <xsl:value-of select = "substring-after($item_enclosure, '&amp;uri=')" />
  12. </xsl:variable>
  15.        <xsl:variable name="URIVal">
  16.         <xsl:choose>
  17.             <xsl:when test="contains($afterURI, '&amp;')">
  18.                <xsl:value-of select="substring-before($afterURI, '&amp;')"/>
  19.             </xsl:when>
  20.             <xsl:otherwise>
  21.               <xsl:value-of select="$afterURI"/>
  22.             </xsl:otherwise>
  23.          </xsl:choose>
  24.       </xsl:variable>
  26.   <div class="subHead" style="width:500px;">
  27.     <a href="javascript:void(kyteplayer.setURI('{$URIVal}'))"><xsl:value-of select="title" disable-output-escaping="yes"/></a></div>
  28.     <div style="width:500px;">
  29.  <xsl:value-of select="description" disable-output-escaping="yes"/><br/></div>
  31.  (<xsl:value-of select="pubDate"/>)<br/> <hr/>
  32.  </xsl:template>
edit: humm the & isnt showing up correctly it should be & a m p
Aug 7 '08 #4
2,057 Recognized Expert Top Contributor
yeah, the code tags seem to automatically unescape &amp; as &, sorry forgot about that quirk.
Aug 8 '08 #5
9 New Member
please take a look at the next step of this project on which I am getting hung up on here: http://bytes.com/forum/thread829025.html
Aug 11 '08 #6

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 appreciated. Regards.
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), secretcode.charAt(5)==(-14). Is there any way to accomplish this task? Thanks in advance, Peter
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. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
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 the HTML text are throwing a SQL error. Html.encode doesn't seem to do anything with these, eh? Secondly, does HTMLencode also encode already encoded items?
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 DRAWSTRING function to place the barcode on the image, but no matter what graphics settings (.InterpolationMode/.CompositingQuality etc.) I manipulate, the barcode image remains poor quality. For exaple I'm using a solidbrush that is black, but some of...
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 suit my purpose. >>> encoded = u'A\\nA' >>> decoded = encoded.decode('unicode_escape') >>> print len(decoded) 3 Note that both encoded and decoded are unicode string. I'm trying to use
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() {}; virtual ~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 example: answer_str = raw_input(' Enter answer ') Herr
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 parser and dbi/ odbc for my db connection. To fix problems with unicode I built a work-around by mapping unicode characters to equivalent ascii characters and then encoding everything to ascii. That allowed me to build the application and debug...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.