Can't get libxslt support with php5 and apache2 on win XP
Posted: Mon May 21, 2007 2:21 pm
feyd | Please use
order.xsl:
order.php:[/syntax]
If anyone can tell me what I need to do to get php to work with xslt it would be greatly appreciated.
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]
I've uncommented extension=php_xsl.dll and extension=php_xslt.dll in php.ini (located in c:\windows). In the same file I set extension_dir to "C:\Program Files\PHP\ext". In the directory C:\Program Files\PHP\ext I have libexslt.dll, libexslt.exp, libexslt.lib,libexslt_a.lib, libxml2.dll, libxml2.exp, libxml2.lib, libxml2_a.lib, libxslt.dll, libxslt.exp, libxslt.lib, libxslt_a.lib, php_xsl.dll, and php_xslt.dll. This "should" be my extensions directory.
Now that should be my extensions directory. Yet for some reason when I do phpinfo() in a test php page xsl or libxslt doesn't even show up in the output. However libxml does. I just can't seem to figure out how to get libxslt support with php and apache. I'm pretty sure my code is correct; when I run it I just get a blank white screen. I'll show you my xml, xsl, and php file just in case anyways:
order.xml:
[syntax="xml"]
<?xml version="1.0" ?>
<Order>
<Account>9900234</Account>
<Item id="1">
<SKU>1234</SKU>
<PricePer>5.95</PricePer>
<Quantity>100</Quantity>
<Subtotal>595.00</Subtotal>
<Description>Super Widget Clamp</Description>
</Item>
<Item id="2">
<SKU>6234</SKU>
<PricePer>22.00</PricePer>
<Quantity>10</Quantity>
<Subtotal>220.00</Subtotal>
<Description>Mighty Foobar Flange</Description>
</Item>
<Item id="3">
<SKU>9982</SKU>
<PricePer>2.50</PricePer>
<Quantity>1000</Quantity>
<Subtotal>2500.00</Subtotal>
<Description>Deluxe Doohickie</Description>
</Item>
<Item id="4">
<SKU>3256</SKU>
<PricePer>389.00</PricePer>
<Quantity>1</Quantity>
<Subtotal>389.00</Subtotal>
<Description>Muckalucket Bucket</Description>
</Item>
<NumberItems>1111</NumberItems>
<Total>3704.00</Total>
<OrderDate>07/07/2002</OrderDate>
<OrderNumber>8876</OrderNumber>
</Order>
Code: Select all
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="column" select="'SKU'"/>
<xsl:param name="order" select="'ascending'"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="Order">
<xsl:with-param name="sortcolumn" select="$column" />
<xsl:with-param name="sortorder" select="$order" />
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="Order">
<xsl:param name="sortcolumn" />
<xsl:param name="sortorder" />
<table border="1">
<tr>
<th>Account</th>
<th>SKU</th>
<th>Description</th>
<th>Price</th>
<th>Quantity</th>
<th>Subtotal</th>
</tr>
<xsl:apply-templates select="Item">
<xsl:sort select="*[name()=$sortcolumn]" order="{$sortorder}" />
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="Item">
<tr>
<td><xsl:value-of select="../Account" /></td>
<td><xsl:value-of select="SKU" /></td>
<td><xsl:value-of select="Description" /></td>
<td><xsl:value-of select="PricePer" /></td>
<td><xsl:value-of select="Quantity" /></td>
<td><xsl:value-of select="Subtotal" /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="column" select="'SKU'"/>
<xsl:param name="order" select="'ascending'"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="Order">
<xsl:with-param name="sortcolumn" select="$column" />
<xsl:with-param name="sortorder" select="$order" />
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="Order">
<xsl:param name="sortcolumn" />
<xsl:param name="sortorder" />
<table border="1">
<tr>
<th>Account</th>
<th>SKU</th>
<th>Description</th>
<th>Price</th>
<th>Quantity</th>
<th>Subtotal</th>
</tr>
<xsl:apply-templates select="Item">
<xsl:sort select="*[name()=$sortcolumn]" order="{$sortorder}" />
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="Item">
<tr>
<td><xsl:value-of select="../Account" /></td>
<td><xsl:value-of select="SKU" /></td>
<td><xsl:value-of select="Description" /></td>
<td><xsl:value-of select="PricePer" /></td>
<td><xsl:value-of select="Quantity" /></td>
<td><xsl:value-of select="Subtotal" /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
Code: Select all
<?php
$xmlfile = "order.xml";
$xslfile = "order.xsl";
$args = array("column"=>"Quantity", "order"=>"descending");
$engine = xslt_create();
$output = xslt_process($engine, $xmlfile, $xslfile, NULL, NULL, $args);
print $output;
xslt_free($engine);
?>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]