#16193 [Com]: XML parser error 3: no element found

From: Date: Sat, 24 May 2003 13:23:48 +0000
Subject: #16193 [Com]: XML parser error 3: no element found
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40344@lists.php.net to get a copy of this message
ID: 16193 Comment by: drm-nospam- at -nospam-melp-dot-nl dot nospam Reported By: kdesormeaux at atre dot net Status: Closed Bug Type: XSLT related Operating System: windows2000/linux... PHP Version: 4.3.0-dev New Comment: [PHP 4.2.2, Windows XP] Here are my findings with the same bugs: The documentation on xslt_set_base () states that you must provide an file:// prefix with setting the base. It seems that you should provide the same prefix when passing files to xslt_process (). The following works fine with me, using the "Very important" example from above with local xml and xslt files, named 'sample.xml' and 'sample.xsl' respectively: <?php # create XSLT processor $xsltProcessor = xslt_create (); # generate filebase from working directory $fileBase = 'file://' . getcwd () . '/'; # process the 'sample.xml' and 'sample.xsl' files $result = xslt_process ( $xsltProcessor, $fileBase . 'sample.xml', $fileBase . 'sample.xsl' ); # print the result if ( $result ) { echo 'Success ...'; echo '<pre>', "\n"; echo htmlentities ( $result ); echo '</pre>'; } else { echo 'Fail due to error: ' . xslt_error($xh); } # free the processor resource xslt_free ( $xsltProcessor ); ?> Alternatively, you can use the xslt_set_base function to provide the processor with an explicit working directory: <?php # create XSLT processor $xsltProcessor = xslt_create (); # generate filebase from working directory $fileBase = 'file://' . getcwd () . '/'; # point xslt process base to working directory xslt_set_base ( $xsltProcessor, $fileBase ); # process the 'sample.xml' and 'sample.xsl' files $result = xslt_process ( $xsltProcessor, 'sample.xml', 'sample.xsl' ); # print the result if ( $result ) { echo 'Success ...'; echo '<pre>', "\n"; echo htmlentities ( $result ); echo '</pre>'; } else { echo 'Fail due to error: ' . xslt_error($xh); } # free the processor resource xslt_free ( $xsltProcessor ); ?> --- Hope some people will profit from this, at least i found a working solution :) Previous Comments: ------------------------------------------------------------------------ [2002-06-28 22:15:34] sniper@php.net This should be fixed now as the related files were reverted back to the 4.2.1 level. ------------------------------------------------------------------------ [2002-06-28 21:47:18] imajes@php.net this isn't critical. ------------------------------------------------------------------------ [2002-06-24 13:04:34] chregu@php.net Changed title Somehow two different bugs got into here... Let's name it after the real bug... (or should i open a new one) ------------------------------------------------------------------------ [2002-06-13 05:48:26] chregu@php.net The same problem here. Code which works very fine under 4.2 just spits out: Warning: Sablotron error on line 1: XML parser error 3: no element found in xslt.php on line 62 BC-break? or a real bug? chregu ------------------------------------------------------------------------ [2002-05-30 09:05:41] urs at circle dot ch System: - Windows 2000 - Apache 1.3.24, Apache Release 10324100 - PHP as apache module - PHP 4.3.0-dev - Xslt Support enabled Discussed earlier on bugs.php.net i found the code below, which is said to work. Running the script in command line mode I get - always - the same error: C:\www\www-xml>php -f test.php Warning: Sablotron error on line 1: XML parser error 3: no element found in test.php on line 23 Line 23 is the line with $xh = xslt_create();. -urs -- <?php // http://bugs.php.net/bug.php?id=16993 $xml = <<< END <?xml version="1.0" encoding="ISO-8859-2"?> <ROOT> <IMPORTANT>Very important ö ü é </IMPORTANT> </ROOT> END; $xsl = <<<END <?xml version="1.0" encoding="ISO-8859-2"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="ROOT"> <B><xsl:value-of select="IMPORTANT"/></B> </xsl:template> </xsl:stylesheet> END; $arguments = array('/_xml' => $xml,'/_xsl' => $xsl); $xh = xslt_create(); $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments ); echo $result; ?> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/16193 -- Edit this bug report at http://bugs.php.net/?id=16193&edit=1

« previous php.bugs (#40344) next »