Forum Moderators: coopster

Message Too Old, No Replies

need help with Sablotron parser error

What's does this mean: "XML parser error 4: not well-formed invalid token"

         

jf_lavigne

3:43 am on Jan 9, 2004 (gmt 0)



Hello All,

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:



$root = getcwd();

$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:



<?xml version="1.0" encoding="utf-8"?>
<message>
<title>This is the title</title>
</message>

The xsl file:



<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
<head>
<title>XSLT test</title>
</head>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="title">
<p>
<xsl:value-of select="."/>
</p>
</xsl:template>
</xsl:stylesheet>

jatar_k

7:10 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld jf_lavigne,

I don't use Sablotron myself. Anyone else have any thoughts?

durandopoulos

9:13 pm on Feb 21, 2004 (gmt 0)



Hello jf

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]