I'm trying out the example found at Zend.com's tutorials. But, can't make it work...
The error is:
XML Parsing Error: no element found
Location: file:///home/raul/public_html/test/simple.xsl
Line Number 32, Column 1:
Heres the code:
simple.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD Simplified DocBook XML V4.1.2.5//EN"
"http://www.oasis-open.org/docbook/xml/simple/4.1.2.5/sdocbook.dtd">
<article>
<title>A Short Example</title>
<section>
<title>Section #1</title>
<para>A short example of a Simplified DocBook file.</para>
</section>
</article>
simple.xsl
<xml version='1.0'>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head><title><xsl:value-of select="title"/></title></head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="article/title">
<h1><xsl:value-of select="."/></h1>
</xsl:template>
<xsl:template match="section">
<xsl:apply-templates/>
</xsl:template>
<!-- Formatting for JUST section -->
<xsl:template match="section/title">
<h2><xsl:value-of select="."/></h2>
</xsl:template>
<xsl:template match="para">
<P><xsl:apply-templates/></P>
</xsl:template>
</xsl:stylesheet>
simple.php
<?php
$xh = xslt_create();
if (xslt_process($xh, 'simple.xml','simple.xsl','/tmp/result.xml')) {
print "SUCCESS, simple.xml was tranformed by simple.xsl into result.xml";
print "<pre>\n";
readfile("/tmp/result.xml");
print "</pre>";
}
else {
print "Sorry, simple.xml could not be transformed by simple.xsl into result.xml";
print "Error: " . xslt_error($xh) . " Code: " . xslt_errno($xh);
}
xslt_free($xh);
?>
------- what is wrong with the XSL? I'm typically new to XML.. so please bear with me.. thank you
jun