xsl syntax problem
Posted: Wed Jan 17, 2007 9:16 am
feyd | Please use
the xml file
the xsl file
then i got fed up with browser transformation as even IE could not tell me in which line the error is so I thought server transformation is the best way to do it. So I wrote the following script.
but i ended up with this.
fyi, i have already have this in php.ini
thanks for any help guys.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
when tried to use a xsl file with a xml file, firefox gives me this explanatory error messageCode: Select all
Error during XSLT transformation: XSLT transformation failed.Code: Select all
<?xml version="1.0"?>
<?xml-stylesheet href="breakfast.xsl" type="text/xsl"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
</food>
</breakfast_menu>
the xsl file
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match='/'>
<xsl:template match='/breakfast_menu' >
<h3>Break Fast Menu</h3>
</xsl:template>
<h4>The food items are listed below: </h4>
<xsl:for-each select='/breakfast_menu/food'>
<xsl:template match='food'>
<table>
<tr>
<th>Name</th><th>Description</th><th>Price</th><th>Calories</th>
</tr>
<tr>
<td><xsl:value-of select='name' /></td>
<td><xsl:value-of select='description' /></td>
<td><xsl:value-of select='price' /></td>
<td><xsl:value-of select='calories' /></td>
</tr>
</table>
</xsl:template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
then i got fed up with browser transformation as even IE could not tell me in which line the error is so I thought server transformation is the best way to do it. So I wrote the following script.
Code: Select all
<?php
// Load the XML source
$xml = new DOMDocument;
$xml->load('breakfast.xml');
$xsl = new DOMDocument;
$xsl->load('breakfast.xsl');
// Configure the transformer
$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToXML($xml);
?>Code: Select all
Fatal error: Class 'XSLTProcessor' not found in C:\Program Files\Apache Group\Apache2\htdocs\xmlxsl1.php on line 12Code: Select all
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
extension=php_xsl.dllfeyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]