xsl issue

Problems with the Windows version of XAMPP, questions, comments, and anything related.

xsl issue

Postby EnglishRocker » 18. September 2008 12:01

Hi all.
I got some xml working, but when I try to style it using xsl I'm getting this error:
Fatal error: Call to undefined function xslt_create() in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 2

Here's the code:

xslt.php:
Code: Select all
<?php
   $xsltproc=xslt_create();
   $xslt_result = xslt_process($xsltproc,'xml\\news.xml','xml\\input.xsl');
   xslt_free($xsltproc);
?>

<p>Processing XML and XSLT</p>

<?php
   print $xslt_result;
?>

xml\input.xsl:
Code: Select all
<?xmlversion="1.0"encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://my.netscape.com/rdf/simple/0.9/">
   <xsl:output method="html" indent="no" encoding="utf-8"/>

   <xsl:template match="/">
      <html>
      <head>
      <title>XSLT</title>
      </head>
      <body>
   
      <xsl:for-each select="/channel/item">
         News Item: <xsl:value-of select="title"/><BR/>
      </xsl:for-each>
      </body>
      </html>
   </xsl:template>
</xsl:stylesheet>


xml\news.xml
Code: Select all
<?xml version="1.0"?>
<newsitems>
   <news type="programming">
   PHP 6.0 has been released!
   </news>

   <news type="programming">
   Larry Wall switches to PHP!
   </news>

   <news type="sci-tech">
   Woman lands on Mars!
   </news>

   <news type="programming">
   XML takes over world!
   </news>
</newsitems>


I've noticed the following section in php.ini:

Code: Select all
;extension=php_win32std.dll
;extension=php_xdebug.dll
;extension=php_xmlreader.dll
extension=php_xmlrpc.dll
;extension=php_xmlwriter.dll
extension=php_xsl.dll
;extension=php_yaz.dll ; Module make problems
extension=php_zip.dll
;extension=php_zlib_filter.dll


Thanks in advance
EnglishRocker
 
Posts: 25
Joined: 12. September 2008 11:07

Postby Wiedmann » 18. September 2008 12:16

Fatal error: Call to undefined function xslt_create() in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 2

xslt_create() is part of the xslt-extension, which is a PHP4 extension.

extension=php_xsl.dll

The xsl-extension is a different extension (for the same purpose, see the PHP manual).
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

OK, so there's a class for that...

Postby EnglishRocker » 18. September 2008 12:58

So I found http://uk2.php.net/manual/en/class.domdocument.php and tried to follow the instructions, but I'm not doing well. I borrowed a code sample:
Code: Select all
<?php

$doc = new DOMDocument();
$xsl = new XSLTProcessor();

$doc->load('xml\\input.xsl');
$xsl->importStyleSheet($doc);

$doc->load('xml\\news.xml');
echo $xsl->transformToXML($doc);

?>


At first I had no arguments in the new DOMDocument() function, but php said it expected at least one parameter. However, it doesn't seem to matter what I put in there; I keep getting errors:

$doc = new DOMDocument("1.0");
Warning: domdocument::domdocument() [domdocument.domdocument]: Entity: line 1: parser error : Start tag expected, '<' not found in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 3

Warning: domdocument::domdocument() [domdocument.domdocument]: 1.0 in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 3

Warning: domdocument::domdocument() [domdocument.domdocument]: ^ in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 3

Fatal error: Call to undefined method domdocument::load() in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 6


$doc = new DOMDocument(<?xmlversion="1.0"encoding="utf-8"?>);
Parse error: syntax error, unexpected '<', expecting ')' in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 3


Hoping someone can give me a clue.
Thanks.
EnglishRocker
 
Posts: 25
Joined: 12. September 2008 11:07

Postby Wiedmann » 18. September 2008 13:21


You must disable the dom_xml extension in XAMPP, if enabled.

Code: Select all
$doc = new DOMDocument(<?xmlversion="1.0"encoding="utf-8"?>);

Parse error: syntax error, unexpected '<', expecting ')' in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 3

1. In PHP, you must enclose a string in quotes.
2. after reading the manual (sorry, no knowledge about this extension), IMHO this line should be:
Code: Select all
$dom = new DOMDocument('1.0', 'utf-8');

(but AFAIK these params are the default for XML)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Thanks Wiedmann, but....

Postby EnglishRocker » 18. September 2008 13:31

I followed your instructions and got this:

Warning: domdocument::domdocument() expects parameter 2 to be long, string given in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 3

Fatal error: Call to undefined method domdocument::load() in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 6


:?
EnglishRocker
 
Posts: 25
Joined: 12. September 2008 11:07

Postby Wiedmann » 18. September 2008 13:49

Warning: domdocument::domdocument() expects parameter 2 to be long, string given in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 3

Wiedmann wrote:You must disable the dom_xml extension in XAMPP, if enabled.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby EnglishRocker » 18. September 2008 13:56

I have commented out the dom_xml extension:
;extension=php_dio.dll
;extension=php_docblock.dll
;extension=php_domxml.dll
;extension=php_event.dll


and restarted xampp.
Thanks.
EnglishRocker
 
Posts: 25
Joined: 12. September 2008 11:07

Postby Wiedmann » 18. September 2008 14:06

I have commented out the dom_xml extension:

You have verified this with phpinfo()?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby EnglishRocker » 18. September 2008 14:15

My bad.
phpinfo says domxml is enabled. I commented out the extension and I've saved it and restarted xampp twice since then.
EnglishRocker
 
Posts: 25
Joined: 12. September 2008 11:07

Postby Wiedmann » 18. September 2008 14:18

Are you using the correct "php.ini"?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby EnglishRocker » 18. September 2008 14:32

I pasted this from phpinfo:
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" "--with-extra-includes=C:\Program Files (x86)\Microsoft SDK\Include;C:\PROGRA~2\MICROS~2\VC98\ATL\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\MFC\INCLUDE" "--with-extra-libs=C:\Program Files (x86)\Microsoft SDK\Lib;C:\PROGRA~2\MICROS~2\VC98\LIB;C:\PROGRA~2\MICROS~2\VC98\MFC\LIB"
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File K:\xampp\apache\bin\php.ini


I run xampp from a usb drive which is K:\.
PHP is not installed anywhere else.
Thanks.
EnglishRocker
 
Posts: 25
Joined: 12. September 2008 11:07

Postby glitzi85 » 18. September 2008 15:49

The question was:

Wiedmann wrote:Are you using the correct "php.ini"?


You posted the place of the correct php.ini, but you forgot to tell which file you edited. It MUST be this file:

Code: Select all
K:\xampp\apache\bin\php.ini


All other php.ini's are not used by PHP in XAMPP

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Postby EnglishRocker » 18. September 2008 15:57

I changed that one and restarted xampp, now I get:

Warning: DOMDocument::load() [domdocument.load]: ParsePI: PI xmlversion space expected in file:///K:/xampp/htdocs/hudzilla/xml/xml/input.xsl, line: 1 in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 6

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: compilation error in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 7

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: xsltParseStylesheetProcess : empty stylesheet in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 7

Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "file:///K:/xampp/htdocs/hudzilla/xml/xml/news.xml" in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 9

Warning: XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: No stylesheet associated to this object in K:\xampp\htdocs\hudzilla\xml\xslt.php on line 10

Thanks
EnglishRocker
 
Posts: 25
Joined: 12. September 2008 11:07


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 81 guests