Forum Moderators: coopster
Can anyone please tell me what am I doing wrong?
I'm trying to parse an xml/xsl file using Sablotron in PHP 4.3. I get the same error message and can't figure out what is the problem.
The error message:
Warning: Sablotron error on line 1: XML parser error 4: not well-formed (invalid token)
Any help would be greatly appreciated. (see source below)
Jean-Francois
The PHP source:
$xml = 'test.xml';
$xsl = 'test.xsl';
$xh = xslt_create();
xslt_set_base ($xh, $root);
$result = xslt_process($xh, $xml, $xsl);
if ($result) { echo $result; }
else { echo 'Operation failed'; }
The xml file:
The xsl file:
I had the same message (Warning: Sablotron error on line 1: XML parser error 4: not well-formed (invalid token) when I tried to work with php / sablotron / expat. I use php 4.3.3 like a module of apache 2.0.47
and sablotron 0.97 expat 1.95.6.
If you use PHP
4.1.x or above, please see the more recent instructions and examples at --
sniptools.com/php_xslt_on_windows
It seem that is necessary to initialise the directory base where sabloton works. Like this
<?php
// Xml and XSL files
$xml_file = "testxml.xml";
$xsl_file = "_xslt/testxsl.xsl";
$xh = xslt_create();
//here you set the directory base
$fileBase = 'file://' . getcwd () . '/';
//and here a non comment instruction
//specila for php version > 4.1.x
xslt_set_base ( $xh, $fileBase );
$res = xslt_process($xh,$xml_file,$xsl_file);
echo xslt_error($xh);
xslt_free($xh);
echo "<pre>";
echo $res;
echo "</pre>";
?>
Like this, with the same XML and XSL files, this script run correctly.
You can download a simple example (with php, xml and xsl file) to test your installation (php, sablotron, expat)for php version > 4.1.x at :
sniptools.com/xsltest.zip
Good job with sablotron /xml and xsl
Excuse my english but i am a frogs "eater"!
[edited by: jatar_k at 5:16 pm (utc) on Feb. 22, 2004]
[edit reason] delinked [/edit]