Solved

XML/RSS - How to pass Atom link href to xsl variable

Posted on 2012-04-06
3
275 Views
Last Modified: 2012-12-09
I have an XML...

<channel>
<atom:link href="http://www.mysite.com/rss/?m=look" rel="self" type="application/rss+xml"/>
<title></title>
<link>http://www.site.com/content/</link>
<pubDate>Fri, 06 Apr 2012 19:28:44 CDT</pubDate>
<lastBuildDate>Fri, 06 Apr 2012 19:28:44 CDT</lastBuildDate>
<ttl>5</ttl> 

Open in new window


How to I pass the Atom link href (http://www.mysite.com/rss/?m=look) to the xsl variable below?

<xsl:variable name="thisurl" select="ATOM_HREF_LINK_HERE"/>

Open in new window


is that possible?
0
Comment
Question by:dimsouple
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 37819109
<xsl:variable name="thisurl" select="/channel/atom:link/@href"/>

Open in new window


make sure you bind the atom namespace to the correct namespace uri
and that you have the variable in context

there is way too little context in this question to be more detailed
It is not whole of the XML source (the atom: namespace binding is missing)
and we don't know wheiter you need a global variable, wheither there is more than one channel in your atom and hat the context of the variable is.

But in general, the above should be it
0
 

Author Comment

by:dimsouple
ID: 37838281
A siample RSS feed is @
http://www.martellyhaiti.com/rss/?m=messages

The stylesheet is @
http://www.martellyhaiti.com/rss/rss.xsl

It works fine if I set:
<xsl:variable name="thisurl" select="'http://www.martellyhaiti.com/rss?m=messages'"/>

If I change it to:
<xsl:variable name="thisurl" select="/channel/atom:link/@href"/>

Open in new window

The rss page shows a blank page. What I am doing wrong?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37838496
as I said...
make sure you bind the atom namespace to the correct namespace uri

make this your stylesheet element and it will work

<xsl:stylesheet version="1.1" 
	xmlns:atom="http://www.w3.org/2005/Atom" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Open in new window


Note that in general it is not a good idea to use the stylesheet version 1.1
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Getting attribute Values using xslt 4 54
SharePoint 2013 Blog Template 2 54
XSLT Help 12 34
PHP Soap Server returning XML but < & > as &lt; / &gt; 9 49
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question