PDA

View Full Version : Help! undefined function xslt_create()



Smart_boy
07-28-2008, 07:08 AM
Hi,

I create a simple php file and try to run it. But i get an error to it.

Below is my php source code:



<?php
// Create an XSLT processor
$xsltproc = xslt_create();

// Perform the transformation
$html = xslt_process($xsltproc, 'docbook.xml', 'docbook.xsl');

// Detect errors
if (!$html) die('XSLT processing error: '.xslt_error($xsltproc));

// Destroy the XSLT processor
xslt_free($xsltproc);

// Output the resulting HTML
echo $html;
?>


When i tried to run this script, i get an error as shown in below:

Fatal error: Call to undefined function xslt_create() in C:\Program Files\EasyPHP 2.0b1\www\xsl\docbook.php on line 3


I don't know how to solve this. Any else can help me?

Thank you very much!

techietim
07-28-2008, 12:19 PM
Since this has no longer been bundled with PHP as of PHP5, meaning you'll have to install it manually.

The PHP website recommends if you need xslt support, to use the xsl extension (http://php.net/manual/en/book.xsl.php).

Smart_boy
07-29-2008, 02:25 AM
Hi techietim,

Thanks for your reply. There are not any error occur again.

But, i didn't to see any output when i run it. It just shown a white blank. What's wrong i make?

Below is my xml and xsl code. Hope can help! Thank you very much!

docbook.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>



docbook.xsl


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>

<xsl:template match="article">
<html>
<head>
<title><xsl:value-of select="title"/></title>
</head>
<body>
<h1><xsl:value-of select="title"/></h1>
<xsl:apply-templates select="section"/>
</body>
</html>
</xsl:template>

<xsl:template match="section">
<xsl:apply-templates/>
<hr/>
</xsl:template>

<xsl:template match="section/title">
<h2><xsl:apply-templates/></h2>
</xsl:template>

<xsl:template match="para">
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="itemizedlist">
<ul><xsl:apply-templates/></ul>
</xsl:template>

<xsl:template match="listitem">
<li><xsl:apply-templates/></li>
</xsl:template>
</xsl:stylesheet>