xsl + php = help?

This is a discussion on "xsl + php = help?" within the Other Programming Languages section. This forum, and the thread "xsl + php = help? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Other Programming Languages

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 1st, 2006, 13:42
New Member
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
xsl + php = help?

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 xmlnssl=\"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...
Reply With Quote

Reply

Tags
xsl, php, help

« Rss | shopping site »
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:20.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43