XSLT not doing anything
| From: | David Feldman | Date: | Mon, 09 Jun 2003 04:25:05 +0000 |
| Subject: | XSLT not doing anything | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-150701@lists.php.net to get a copy of this message | ||
I'm trying to get the XSLT extension working, and all I can get it to do is echo the source XML back to me. I'm using sample markup from O'Reilly's XSLT book as my XML and XSL files, as follows:
hello.xml:
<?xml version="1.0"?>
<greeting>
Hello, world!
</greeting>
hello.xsl:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:apply-templates select="greeting"/>
</xsl:template>
<xsl:template match="greeting">
<html>
<body>
<h1>
<xsl:value-of select="."/>
</h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
My PHP code is in index.php:
<?php
$proc = xslt_create();
$result = xslt_process($proc, "hello.xsl", "hello.xml");
xslt_free($proc);
echo $result;
?>
All three files are in the same directory. I'm running on Mac OS X using Marc Liyanage's precompiled PHP binary, which includes the XSLT extension. It seems to be running, since if I intentionally introduce a typo I get Sablotron errors written to the browser window. But otherwise the output is simply the original hello.xml's markup, with a character encoding added. I'm new to XSLT so I may be overlooking something simple. What am I doing wrong?
Thanks,
--Dave