Transforming xml to rss via xsl - transformation isn't right?

I am trying to generate an RSS feed from XML data from a calendar (events, locations, dates, etc.). To do this, I've been trying to use an XSL to transform the raw XML into an RSS file. The XSL only uses the components of the XML that I want to display.

The problem I'm having is that I can only get text back. I don't get a feed. Browsers and readers don't recognize my transformed file as RSS.

 A simplified version of the XML I want to translate is below:

<?xml version="1.0" ?>
<?xml-stylesheet href="calendartransform.xsl" type="text/xsl"?>

       <eventtitle>The event title goes here</eventtitle>
       <qlink>http://www.linktoinfogoeshere.com/</qlink>

My XSL is attached as a code snippet. Any suggestions as to how to get the xml returned as a feed would be most appreciated.
<?xml version="1.0" ?>
 
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
<xsl:output method="xml" indent="yes"  />
 
 
  <xsl:template match="/">
<rss version="2.0">
      <channel>
        <title>Title goes here</title>
        <link>http://www.link.com</link>
        <description>Feed description goes here.</description>
        <language>en-us</language>
        <image>
          <title>Organization goes here</title>
          <url>http://link.com/images/image.jpg</url>
          <link>http://link.com</link>
        </image>
        <item>
          <title>
            <xsl:value-of select="eventtitle" />
          </title>
          <link>
            <xsl:value-of select="qlink" />
          </link>
          <description>
            Description goes here.
          </description>
        </item>
		</channel>
		</rss>
      </xsl:template>
</xsl:stylesheet>

Open in new window

theatreWACAsked:
Who is Participating?
 
Ray PaseurConnect With a Mentor Commented:
Any help available from here?
http://www.ektron.com/search_display.aspx?searchtext=rss

If not, I would definitely contact the vendor -- they are one of the most responsive tech support groups around!

Good luck, ~Ray
0
 
Tony McCreathTechnical SEO ConsultantCommented:
Your example xml is invalid as it doesn't have a root element. Maybe its the post hiding it!

I've assumed your xml has a root element called "rss". Then you will need to add that to your value-of elements....


<!-- XML -->
 
<?xml version="1.0" ?>
<?xml-stylesheet href="calendartransform.xsl" type="text/xsl"?>
<rss>
  <eventtitle>The event title goes here</eventtitle>
  <qlink>http://www.linktoinfogoeshere.com/</qlink>
</rss>
 
<!-- XSLT -->
 
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
  <xsl:output method="xml" indent="yes"  />
 
  <xsl:template match="/">
    <rss version="2.0">
      <channel>
        <title>Title goes here</title>
        <link>http://www.link.com</link>
        <description>Feed description goes here.</description>
        <language>en-us</language>
        <image>
          <title>Organization goes here</title>
          <url>http://link.com/images/image.jpg</url>
          <link>http://link.com</link>
        </image>
        <item>
          <title>
            <xsl:value-of select="rss/eventtitle" />
          </title>
          <link>
            <xsl:value-of select="rss/qlink" />
          </link>
          <description>
            Description goes here.
          </description>
        </item>
      </channel>
    </rss>
  </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
theatreWACAuthor Commented:
Thanks for the suggestion. I made sure the actual XML I'm transforming has a root element.

I'm still in the same boat, though - The XML is being transformed like I want, but isn't transforming into an RSS feed. My understanding is that this is possible with just XML data and an XSLT, but maybe I need something else? Right now all I'm getting is the text that I want, but it isn't recognized as a feed. So my output for the above would be:

Title goes here http://www.link.com Feed description goes here. en-us Organization goes here http://link.com/images/image.jpg http://link.com The event title goes here. http://www.linktoinfogoeshere.com Description goes here.

Granted, I can style this however I want with line breaks, etc., but I would like it to be a standard feed that RSS readers recognize.

Thanks again for any suggestions.
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
Tony McCreathTechnical SEO ConsultantCommented:
Not sure on that, and its late here!

It seems its not picking it up as the right content type. What you are seing is it interpreting the result as html. Check the source to see if its xml underneath.

My rss feeds specifically set the content-type to text/xml and then the browsers seem to pick up its rss compiant. I'm not sure how to do that with xml that is being transformed using the xml-stylesheet tag
0
 
Ray PaseurCommented:
@theatreWAC: Do you have a scripting language available to you, such as PHP?  I've generated plenty of Podcasts and RSS feeds using PHP with no need for any XSLT.  Here is an example of one in the code snippet.
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss">
<!-- -->
<!-- -->
<!--     IF YOU CAN SEE THIS, YOU NEED AN RSS READER!   -->
<!-- -->
<!-- -->
<channel>
<title>National Trust Community Investment Corporation News</title>
<link>http://www.NTCICFunds.com/</link>
<description>NTCIC makes equity investments in real estate projects that qualify for historic tax credits.</description>
<language>en-us</language>
<pubDate>Fri, 17 Aug 2007 09:25:38 CDT</pubDate>
<image>
<url>http://NTCICFunds.com/images/ntcic_rss_logo.png</url>
<title>NTCIC Web Site</title>
<link>http://www.NTCICFunds.com/</link>
</image>
<item>
<title>NTCIC News Updated on Fri, 17 Aug 2007 09:25:38 CDT!</title>
<link>http://www.NTCICFunds.com/news/</link>
<description>The RSS Feed from www.NTCICFunds.com has been updated.</description>
<pubDate>Fri, 17 Aug 2007 09:25:38 CDT</pubDate>
</item>
</channel>
</rss>

Open in new window

0
 
theatreWACAuthor Commented:
I have been trying out a .net solution. I'm not convinced that XML can be transformed into RSS without using a script of some sort. It would be convenient if it was possible, but I haven't found a way to do it.

Thanks for the suggestion, though.
0
 
Ray PaseurCommented:
If it helps to clarify any, RSS is a specialized subset of XML.  There is no need to "transform" XML into RSS.  Just generate the RSS like the example shown above.  The news readers can handle it.  Here is a good discussion:
http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html

HTH, ~Ray
0
 
theatreWACAuthor Commented:
I get that, but I'm relying on our CMS for the XML. I suppose I could try to customize the way that it generates the XML, but I thought there might be a way to make RSS compliant XML out of the CMS's default XML using XSL.
0
 
Ray PaseurCommented:
Wow, "CMS" is a pretty important part of the question here!  Any chance we can learn what CMS?
0
 
theatreWACAuthor Commented:
Sure - it's Ektron. I'm specifically working with its XML for the calendar.
0
 
Tony McCreathConnect With a Mentor Technical SEO ConsultantCommented:
You probably need to transform your xml server side so the rss page presents the correct xml directly.

rss readers most likely don't understand the concept of xml-stylesheet. As far as I understand, xml-stylesheet  is a way to convert xml to something else (e.g. html) and as rss is xml based it is not expecting that directive.

I don't know the CMS in question, it seems to be .Net based. So you probably need to create an rss.aspx page that gets the xml and writes out the transfomed version of it.
0
All Courses

From novice to tech pro — start learning today.