By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,570 Members | 970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,570 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Oct 30 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a


Martin Plantec wrote:
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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 30 '05 #2

P: n/a
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

Oct 30 '05 #3

P: n/a


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>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 30 '05 #4

P: n/a
Martin Plantec wrote:
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.
Oct 30 '05 #5

P: n/a
Tjerk Wolterink wrote:
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.

--
Nick Kew
Oct 30 '05 #6

P: n/a
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

Oct 30 '05 #7

P: n/a
Martin Plantec wrote:
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

Oct 31 '05 #8

P: n/a
<< 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.

Oct 31 '05 #9

P: n/a
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...

Oct 31 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.