I ran in to a problem, with making XSL and making it print.
It's supposed to print <title>(with a href) and then text in html.
The PHP-code:
<?
$dom_xml = new DOMDocument();
$dom_xsl = new DOMDocument();
$xslt = new XSLTProcessor();
$dom_xml->load('dump.xml');
$dom_xsl->load('index-rss.xsl');
$xslt->importStylesheet($dom_xsl);
echo $xslt->transformToXML($dom_xml);
?>
The XML file looks lite this:
<rdf:RDF xmlns:rdf=" xmlns=" xmlns:dc=" xmlns:syn="htt$
<channel rdf:about=" <title>Test</title>
<link> <description>Some desc.</description>
<dc:language>sv</dc:language>
<dc:rights>Copyright </dc:rights>
<dc:date>2007-09-10T09:41:35+01:00</dc:date>
<dc
ublisher>Unknown</dc
ublisher>
<dc:creator>abuse@domain.tld</dc:creator>
<syn:updatePeriod>daily</syn:updatePeriod>
<syn:updateFrequency>1</syn:updateFrequency>
<syn:updateBase>1970-01-01T00:00+00:00</syn:updateBase>
<items>
<rdf:Seq>
<rdf:li rdf:resource=" /></rdf:Seq>
</items>
<image rdf:resource=" />
</channel>
<item rdf:about="<title>Some title</title>
<link><description>Desc about the item</description>
<dc:creator>XXX YYYY</dc:creator>
<dc:date>2006-10-14T12:00:00+02:00</dc:date>
</item>
<item rdf:about="<title>Some title</title>
<link><description>Desc about the item</description>
<dc:creator>XXX YYYY</dc:creator>
<dc:date>2006-10-14T12:00:00+02:00</dc:date>
</item>
<item rdf:about="<title>Some title</title>
<link><description>Desc about the item</description>
<dc:creator>XXX YYYY</dc:creator>
<dc:date>2006-10-14T12:00:00+02:00</dc:date>
</item>
<item rdf:about="<title>Some title</title>
<link><description>Desc about the item</description>
<dc:creator>XXX YYYY</dc:creator>
<dc:date>2006-10-14T12:00:00+02:00</dc:date>
</item>
</rdf:RDF>
XSL is like:
<xsl:stylesheet xmlns:xsl=" xmlns:rdf=" xmlns:rss=" xmlns:dc=" xmlns:syn=" xmlns=" version="1.0">
<xsl
utput indent="yes"/>
<xsl:template match="rdf:RDF">
<html>
<head>
<title>Output of XSL</title>
</head>
<body>
<h2>
<a href="link"><xsl:apply-templates /></a>
</h2>
Desc here?
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I tried to change rdf:RDF to diffrent, and apply-templates to diffrint, but I really dont get it. Tried to search on the web for how XSL is supposed to grab the diffrent <items> but I never really found/understod how it's supposted to grep the items and loop them and then print <title><link><desc> from my XML output file.
Tried with
<xsl:apply-templates select="/rdf:RDF/rss:item" />
Didnt go so well.
Any help? Would nice if you show where the error is and so on. Thanks.
It's supposed to print <title>(with a href) and then text in html.
The PHP-code:
<?
$dom_xml = new DOMDocument();
$dom_xsl = new DOMDocument();
$xslt = new XSLTProcessor();
$dom_xml->load('dump.xml');
$dom_xsl->load('index-rss.xsl');
$xslt->importStylesheet($dom_xsl);
echo $xslt->transformToXML($dom_xml);
?>
The XML file looks lite this:
<rdf:RDF xmlns:rdf=" xmlns=" xmlns:dc=" xmlns:syn="htt$
<channel rdf:about=" <title>Test</title>
<link> <description>Some desc.</description>
<dc:language>sv</dc:language>
<dc:rights>Copyright </dc:rights>
<dc:date>2007-09-10T09:41:35+01:00</dc:date>
<dc
<dc:creator>abuse@domain.tld</dc:creator>
<syn:updatePeriod>daily</syn:updatePeriod>
<syn:updateFrequency>1</syn:updateFrequency>
<syn:updateBase>1970-01-01T00:00+00:00</syn:updateBase>
<items>
<rdf:Seq>
<rdf:li rdf:resource=" /></rdf:Seq>
</items>
<image rdf:resource=" />
</channel>
<item rdf:about="<title>Some title</title>
<link><description>Desc about the item</description>
<dc:creator>XXX YYYY</dc:creator>
<dc:date>2006-10-14T12:00:00+02:00</dc:date>
</item>
<item rdf:about="<title>Some title</title>
<link><description>Desc about the item</description>
<dc:creator>XXX YYYY</dc:creator>
<dc:date>2006-10-14T12:00:00+02:00</dc:date>
</item>
<item rdf:about="<title>Some title</title>
<link><description>Desc about the item</description>
<dc:creator>XXX YYYY</dc:creator>
<dc:date>2006-10-14T12:00:00+02:00</dc:date>
</item>
<item rdf:about="<title>Some title</title>
<link><description>Desc about the item</description>
<dc:creator>XXX YYYY</dc:creator>
<dc:date>2006-10-14T12:00:00+02:00</dc:date>
</item>
</rdf:RDF>
XSL is like:
<xsl:stylesheet xmlns:xsl=" xmlns:rdf=" xmlns:rss=" xmlns:dc=" xmlns:syn=" xmlns=" version="1.0">
<xsl
<xsl:template match="rdf:RDF">
<html>
<head>
<title>Output of XSL</title>
</head>
<body>
<h2>
<a href="link"><xsl:apply-templates /></a>
</h2>
Desc here?
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I tried to change rdf:RDF to diffrent, and apply-templates to diffrint, but I really dont get it. Tried to search on the web for how XSL is supposed to grab the diffrent <items> but I never really found/understod how it's supposted to grep the items and loop them and then print <title><link><desc> from my XML output file.
Tried with
<xsl:apply-templates select="/rdf:RDF/rss:item" />
Didnt go so well.
Any help? Would nice if you show where the error is and so on. Thanks.