Windows: Sablotron error on line 1: XML parser error 4
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4127
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
This will fix on Windows installations this error:
:: Code ::
windows "Sablotron error on line 1: XML parser error 4: not well-formed (invalid token)"


bugs.php.net

I ran across this when I was first testing my Windows 2000 Apache/PHP/Sablotron XML/XSLT processor.

Hope this helps someone, TechAdmin.

In case that link ever goes bad, here's the full code [thanks a lot drm, that helped]:

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

$xsltProcessor = xslt_create ();


$fileBase      = 'file://' . getcwd () . '/';


$result        = xslt_process (
   $xsltProcessor,
   $fileBase . 'sample.xml',
   $fileBase . 'sample.xsl'
);


if ( $result ) {
   echo 'Success ...';
   echo '<pre>', "\n";
   echo htmlentities ( $result );
   echo '</pre>';
} else {
   echo 'Fail due to error: ' . xslt_error($xh);
}


xslt_free ( $xsltProcessor );
?>

Alternatively, you can use the xslt_set_base function to provide the
processor with an explicit working directory:
<?php

$xsltProcessor = xslt_create ();


$fileBase      = 'file://' . getcwd () . '/';


xslt_set_base ( $xsltProcessor, $fileBase );


$result        = xslt_process (
   $xsltProcessor,
   'sample.xml',
   'sample.xsl'
);


if ( $result ) {
   echo 'Success ...';
   echo '<pre>', "\n";
   echo htmlentities ( $result );
   echo '</pre>';
} else {
   echo 'Fail due to error: ' . xslt_error($xh);
}


xslt_free ( $xsltProcessor );
?>

Back to top
Display posts from previous:   

All times are GMT - 8 Hours