Solved

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

Posted on 2012-04-06
3
270 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now