Solved

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

Posted on 2012-04-06
3
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

734 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