Locally working XSLT fails on host with message "Sablotron error on line 1: XML parser error 4: not

M

Martin Plantec

Hello,

I have managed (with your help!) to make a working XSLT stylesheet; it
works fine locally (Windows Apache + PHP with Sablotron 1.0), but it
fails on the remote host (FreeBSD Apache + PHP with Sablotron 1.0) with
the following:

Warning: Sablotron error on line 1: XML parser error 4: not well-formed
(invalid token) in /...host...path.../page.php on line 28
FAILURE : XML parser error 4: not well-formed (invalid token) ; error
code is 2

Line 28 (of page.php) is the line with the call to xslt_process, while
line 1 (of the stylesheet) reads:

<?xml version="1.0" encoding="iso-8859-1"?>

What can possibly be wrong?

Note: I have of course some PHP code which sets the correct directory
depending on the machine we are on (local or remote).

Thanks!

Martin
 
M

Martin Honnen

Martin said:
Warning: Sablotron error on line 1: XML parser error 4: not well-formed
(invalid token) in /...host...path.../page.php on line 28
FAILURE : XML parser error 4: not well-formed (invalid token) ; error
code is 2

Line 28 (of page.php) is the line with the call to xslt_process, while
line 1 (of the stylesheet) reads:

<?xml version="1.0" encoding="iso-8859-1"?>

What can possibly be wrong?

I would guess that some path is wrong and somehow you don't pass in the
XML and/or the stylesheet you want.
 
M

Martin Plantec

Martin,

Encouraged by your help, I tried to localize the problem. There was no
path problem (a bad path produced another error). But I realized that
removing the 2nd line of my XML (not the 1st as mentionned in the error
message), which was a DOCTYPE declaration (external DTD with SYSTEM
id), it worked fine on the remote host, too.

I got curious and I tried to keep the doctype line, but to empty the
external DTD (keep the file, remove the declarations). I know Sablotron
doesn't use it anyway... It worked. So I tried to restore parts of the
DTD, to see what was a problem to Sablotron.

It turns out that it was 8 bit characters in the comments. Sigh.

The "line 1" in the error actually referred to line 1 of the external
DTD, where there was the first comment with one 8 bit char...

Thanks!

Martin
 
M

Martin Honnen

Martin Plantec wrote:

It turns out that it was 8 bit characters in the comments. Sigh.

The "line 1" in the error actually referred to line 1 of the external
DTD, where there was the first comment with one 8 bit char...

An external DTD is allowed to declare its encoding with
<?xml version="1.0" encoding="encodingHere"?>
see
<http://www.w3.org/TR/REC-xml/#sec-TextDecl>
 
T

Tjerk Wolterink

Martin said:
Hello,

I have managed (with your help!) to make a working XSLT stylesheet; it
works fine locally (Windows Apache + PHP with Sablotron 1.0), but it
fails on the remote host (FreeBSD Apache + PHP with Sablotron 1.0) with
the following:

Warning: Sablotron error on line 1: XML parser error 4: not well-formed
(invalid token) in /...host...path.../page.php on line 28
FAILURE : XML parser error 4: not well-formed (invalid token) ; error
code is 2


Just a side-note:

I used to build webapplications in php,
and i used sablotron as xslt processor...
What i learned: Sablotron is a lousy xmlt processor,
bad error reporting etc etc.

Okay it is fast.. but not very productive.
 
N

Nick Kew

Tjerk said:
I used to build webapplications in php,

but now you know better:)
and i used sablotron as xslt processor...
What i learned: Sablotron is a lousy xmlt processor,
bad error reporting etc etc.

Haven't used it since 0.6 or thereabouts, but wasn't sorry
to switch away from it.
Okay it is fast.. but not very productive.

Fast???? Quite the opposite, according to xmlbench.

In the context of Apache, you should use one of the XSLT
filter modules - such as mod_transform - for XSLT apps.
That uses libxslt, which xmlbench finds up to 10 times
faster than sablotron, as well as being nice to use.

I still consider *any* XSLT slower than I want to run on
a webserver if I can help it (OK I do use it:). Sax-based
filters are what you really want to process XML on the fly.
 
M

Martin Plantec

Martin : Thanks, and yes, I confirm that adding <?xml version="1.0"
encoding="iso-8859-1"?> (in my case) at the beginning of the DTD solves
the problem.

Tjerk and Nick: Thanks for your comments about Sablotron. I am posting
another topic about this to follow up on them...

Martin
 
P

Peter Flynn

Martin said:
Hello,

I have managed (with your help!) to make a working XSLT stylesheet; it
works fine locally (Windows Apache + PHP with Sablotron 1.0), but it
fails on the remote host (FreeBSD Apache + PHP with Sablotron 1.0)
with the following:

Warning: Sablotron error on line 1: XML parser error 4: not
well-formed (invalid token) in /...host...path.../page.php on line 28
FAILURE : XML parser error 4: not well-formed (invalid token) ; error
code is 2

Line 28 (of page.php) is the line with the call to xslt_process, while
line 1 (of the stylesheet) reads:

a) How do you know it's the stylesheet that the error is referring to,
and not the XML document?
<?xml version="1.0" encoding="iso-8859-1"?>

b) the error message may not be counting the XML Declaration as a line
of the document: look further at both stylesheet and document
instance.
What can possibly be wrong?

In these cases, ALWAYS run a standalone command-line parse or validation
using one of the known, stable processors, independently of your own
application code. See http://xml.silmaril.ie/authors/parsers/ for
details.

///Peter
 
M

Martin Plantec

<< a) How do you know it's the stylesheet that the error is referring
to,
and not the XML document? >>

Typo: I meant the XML document. As it turned out later (see my later
post), the problem was in the external DTD for the XML document
(comments with 8 bits chars).

<< b) the error message may not be counting the XML Declaration as a
line
of the document: look further at both stylesheet and document
instance. >>

Apparently, the error messages refer to line number in files (in the
usual sense, all lines count); but it may be different files (here, the
external DTD for the XML).

<< In these cases, ALWAYS run a standalone command-line parse or
validation >>

I validate all my documents with SP (onsgmls). That may not be the last
fad in XML parser, I don't know (my whole system was developped years
ago, and I am no professional computer scientist), but it works well.
The problem here was that my documents validate fine, and that the 8
bit characters in DTD comments are not a problem to onsgmls.

Thanks for your comments.
 
M

Martin Plantec

Sorry for clumsy quoting, but I am using groups.google.com and I have
not yet figured how to quote the message I reply to...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top