DotDragnet
May 24, 2012, 05:36:54 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: follow us on twitter @dotdragnet
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: help with xslt for wordpress feed  (Read 472 times)
SLEE
Hero Member
*****
Posts: 824



View Profile WWW Awards
« on: July 19, 2011, 04:34:40 PM »

I need to show a wordpress feed on another website and i am using an xslt to transform the xml into html.
It all works except the content.

I have set the namespace in the xsl declaration:

xmlns:content="http://purl.org/rss/1.0/modules/content/"

and to get the value I have:

 <xsl:value-of select="content:encoded" disable-output-escaping="yes"/>

but it does not work.

If i change it to:
 <xsl:value-of select="description" disable-output-escaping="yes"/>

it can get the summary text no problem at all.

I have read everythihg i can and they all say to have the namepsace set but i already have that so why on earth is it not getting the value?

I hope someone can point out my mistake smile
Logged

SLEE - still the most confusing ddner...

Follow me on Twitter
JasonD
Global Moderator
Hero Member
*****
Posts: 551



View Profile Awards
« Reply #1 on: July 19, 2011, 08:08:26 PM »

Wouldn't the namespace need to go in the xml, Not the xsl? I could be wrong, I haven't touched xsl for many years.
Logged
SLEE
Hero Member
*****
Posts: 824



View Profile WWW Awards
« Reply #2 on: July 20, 2011, 08:38:31 AM »

it is in the xml as well but as far as i know youi need to declare it so the page knows how to use it but i just can't get it to work
Logged

SLEE - still the most confusing ddner...

Follow me on Twitter
Dom
Hero Member
*****
Posts: 1681


Taster of pasities. Clanger of both pots AND pans.


DominicNeagle
View Profile Awards
« Reply #3 on: July 20, 2011, 01:28:40 PM »

It might be worth posting a sample of your XML and XSLT for us to take a gander at.
Logged

SLEE
Hero Member
*****
Posts: 824



View Profile WWW Awards
« Reply #4 on: July 21, 2011, 07:34:59 AM »

Here is my xsl and the xml is jsut a standard WordPress Rss feed.

Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">

<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="rss">
 <xsl:for-each select="channel/item[position()&lt;=$ItemsToShow or $ItemsToShow&lt;1]">
   <h4 class="link">
     <xsl:value-of select="title"/>
   </h4>
   <xsl:if test="$ShowItemDate='true'">
    <h6>
     <xsl:value-of select="pubDate"/>
    </h6>
   </xsl:if>
   <xsl:if test="$ShowItemDetails='true'">
    <div class="details">
     <xsl:value-of select="content:encoded" disable-output-escaping="yes"/>
    </div>
   </xsl:if>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>
Logged

SLEE - still the most confusing ddner...

Follow me on Twitter
sarahA
DDN Contribs
Hero Member
*****
Posts: 2184



View Profile WWW Awards
« Reply #5 on: July 21, 2011, 10:10:57 AM »

Daft question, but why not use a parser like simple pie or magpie?
Logged

SLEE
Hero Member
*****
Posts: 824



View Profile WWW Awards
« Reply #6 on: July 21, 2011, 10:31:51 AM »

Daft question, but why not use a parser like simple pie or magpie?

It is not on the same site and the site it needs to display on is using DotNetNuke (ergh!)
Logged

SLEE - still the most confusing ddner...

Follow me on Twitter
sarahA
DDN Contribs
Hero Member
*****
Posts: 2184



View Profile WWW Awards
« Reply #7 on: July 21, 2011, 10:53:46 AM »

That doesn't matter? You can add magpie to any site and it can read any feed off any website. I recently updated a script for someone that used file() to open a feed off an external site and instead set it to use magpie. Obviously don't know about DotNetNuke and whether the two would work together but I don't see why not.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!