Re: transform RDF to HTML via XSL and PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
author of Pro PHP XML and Web Services from Apress

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux