Answered
MM_XSLTransform error every time in PHP page
When I apply an XSL Transformation to a PHP page, the page
displays with an MM_XSLTransform error saying the XML file is not a
valid XML document -- even though it absolutely
is valid XML. This is totally reproducable.
Here's a simple example:
library.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<library>
<owner>Mister Reader</owner>
<book>
<isbn>1-2345-6789-0</isbn>
<title>All About XML</title>
<author>John Doe</author>
<language>English</language>
<price currency="usd">24.95</price>
</book>
<book>
<isbn>9-8765-4321-0</isbn>
<title>CSS Made Simple</title>
<author>Jane Smith</author>
<language>English</language>
<price currency="usd">19.95</price>
</book>
</library>
library.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:template match="/">
<h1><xsl:value-of select="library/owner"/>'s Library</h1>
<xsl:for-each select="library/book">
<p><em><xsl:value-of select="title"/></em>
by <xsl:value-of select="author"/>
(ISBN <xsl:value-of select="isbn"/>)</p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
library.php:
<?php
//XMLXSL Transformation class
require_once('includes/MM_XSLTransform/MM_XSLTransform.class.php');
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
$mm_xsl = new MM_XSLTransform();
$mm_xsl->setXML("library.xml");
$mm_xsl->setXSL("library.xsl");
echo $mm_xsl->Transform();
?>
</body>
</html>
When viewing the file library.php, the following error is displayed in the browser, followed by the raw XML:
library.xml is not a valid XML document.
Non-static method DOMDocument::loadXML() should not be called statically, assuming $this from incompatible context in file library.xml.
I wonder whether there is a problem with the include file MM_XSLTransform, version 0.6.2. Since that include file begins with a "TODO" note from the programmer, I wonder whether it's not quite release-ready.
Anyone else having this problem?
Environment:
- Testing Server on localhost
- Windows XP Pro SP2
- Dreamweaver 8.0.2
- PHP 5.1.4
- MySQL 5.0.2.1
- PHP MyAdmin 2.8.1
Here's a simple example:
library.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<library>
<owner>Mister Reader</owner>
<book>
<isbn>1-2345-6789-0</isbn>
<title>All About XML</title>
<author>John Doe</author>
<language>English</language>
<price currency="usd">24.95</price>
</book>
<book>
<isbn>9-8765-4321-0</isbn>
<title>CSS Made Simple</title>
<author>Jane Smith</author>
<language>English</language>
<price currency="usd">19.95</price>
</book>
</library>
library.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:template match="/">
<h1><xsl:value-of select="library/owner"/>'s Library</h1>
<xsl:for-each select="library/book">
<p><em><xsl:value-of select="title"/></em>
by <xsl:value-of select="author"/>
(ISBN <xsl:value-of select="isbn"/>)</p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
library.php:
<?php
//XMLXSL Transformation class
require_once('includes/MM_XSLTransform/MM_XSLTransform.class.php');
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
$mm_xsl = new MM_XSLTransform();
$mm_xsl->setXML("library.xml");
$mm_xsl->setXSL("library.xsl");
echo $mm_xsl->Transform();
?>
</body>
</html>
When viewing the file library.php, the following error is displayed in the browser, followed by the raw XML:
library.xml is not a valid XML document.
Non-static method DOMDocument::loadXML() should not be called statically, assuming $this from incompatible context in file library.xml.
I wonder whether there is a problem with the include file MM_XSLTransform, version 0.6.2. Since that include file begins with a "TODO" note from the programmer, I wonder whether it's not quite release-ready.
Anyone else having this problem?
Environment:
- Testing Server on localhost
- Windows XP Pro SP2
- Dreamweaver 8.0.2
- PHP 5.1.4
- MySQL 5.0.2.1
- PHP MyAdmin 2.8.1
