Re: transform RDF to HTML via XSL and PHP

From: Date: Mon, 12 Jun 2006 15:20:28 +0000
Subject: Re: transform RDF to HTML via XSL and PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-237814@lists.php.net to get a copy of this message
Mario Pavlov wrote:
nope it doesn't work like this still the same result I think the problem is in the way that I'm accessing the elements how exactly this should be done ?...
Its due to default namespaces in the feed. The item elements and its child elements are in the default namespace: http://my.netscape.com/rdf/simple/0.9/ You need to declare this namespace with a prefix in order to access the elements within the stylesheet (same as using XPath). i.e. the following stylesheet uses the prefix rdf9 for that namespace. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf9="http://my.netscape.com/rdf/simple/0.9/"> <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/> <xsl:template match="/"> <html> <body>
    <table border="1">
      <xsl:for-each select="//rdf:RDF/rdf9:item">
      <tr>
        <td><xsl:value-of select="rdf9:title"/></td>
        <td><xsl:value-of select="rdf9:link"/></td>
      </tr>
      </xsl:for-each>
    </table>
</body> </html> </xsl:template> </xsl:stylesheet> Rob -- rrichards@ctindustries.net author of Pro PHP XML and Web Services from Apress

« previous php.general (#237814) next »