new problem please help (xslt)

wxdqz

New Member
i have created a php file that sends xsl information to a xslt tranformation..

the xsl seems fine... its just when it gets to the transformation, things go wrong..

here is the xsl..

<?php
header ("Content-Type: text/xml; charset=\"UTF-8\"");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n";
echo "\n";
echo " <xsl:output\n";
echo " method=\"xml\"\n";
echo " doctype-system=\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"\n";
echo " doctype-public=\"-//W3C//DTD XHTML 1.1//EN\"/>\n";
echo "\n";
echo " <xsl:template match=\"article\">\n";
echo "<html>\n";
echo "<head>\n";
echo "<title><xsl:value-of select=\"title\"/></title>\n";
echo "</head>\n";
echo "<body>\n";
echo "<h1><xsl:value-of select=\"title\"/></h1>\n";
echo "<xsl:apply-templates select=\"section\"/>\n";
echo "</body>\n";
echo "</html>\n";
echo "</xsl:template>\n";
echo "\n";
echo "<xsl:template match=\"section\">\n";
echo "<xsl:apply-templates/>\n";
echo "<hr/>\n";
echo "</xsl:template>\n";
echo "<xsl:template match=\"section/title\">\n";
echo "<h2><xsl:apply-templates/></h2>\n";
echo "</xsl:template>\n";
echo "\n";
echo "<xsl:template match=\"para\">\n";
echo "<p><xsl:apply-templates/></p>\n";
echo "</xsl:template>\n";
echo "\n";
echo "<xsl:template match=\"itemizedlist\">\n";
echo "<ul><xsl:apply-templates/></ul>\n";
echo "</xsl:template>\n";
echo "\n";
echo "<xsl:template match=\"listitem\">\n";
echo "<li><xsl:apply-templates/></li>\n";
echo "</xsl:template>\n";
echo "</xsl:stylesheet>\n";
?>

and here is the code for the transformation.....

<?php

/* load the xml file and stylesheet as domdocuments */
$xsl = new DomDocument();
$xsl->load("xsl3.php");
$inputdom = new DomDocument();
$inputdom->load("docbook.xml");

/* create the processor and import the stylesheet */
$proc = new XsltProcessor();
$xsl = $proc->importStylesheet($xsl);
$proc->setParameter(null, "titles", "Titles");

/* transform and output the xml document */
$newdom = $proc->transformToDoc($inputdom);
print $newdom->saveXML();

?>

and the xml....

<?xml version="1.0" encoding="UTF-8"?>
<article>
<title>A Sample Article</title>
<section>
<title>Article Section 1</title>
<para>
This is the first section of the article. Nothing terribly
interesting here, though.
</para>
</section>
<section>
<title>Another Section</title>
<para>
Just so you can see how these things work, here's an
itemized list:
</para>
<itemizedlist>
<listitem>
<para>The first item in the list</para>
</listitem>
<listitem>
<para>The second item in the list</para>
</listitem>
<listitem>
<para>The third item in the list</para>
</listitem>
</itemizedlist>
</section>
</article>

if anybody can make this work i would be delighted and you would become my internet hero instantly...
 
Back
Top