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

Discussion in 'XML' started by Martin Plantec, Oct 30, 2005.

  1. 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
    Martin Plantec, Oct 30, 2005
    #1
    1. Advertising

  2. Re: Locally working XSLT fails on host with message "Sablotron error

    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/
    Martin Honnen, Oct 30, 2005
    #2
    1. Advertising

  3. 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
    Martin Plantec, Oct 30, 2005
    #3
  4. Re: Locally working XSLT fails on host with message "Sablotron error

    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/
    Martin Honnen, Oct 30, 2005
    #4
  5. Re: Locally working XSLT fails on host with message "Sablotron error

    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.
    Tjerk Wolterink, Oct 30, 2005
    #5
  6. Martin Plantec

    Nick Kew Guest

    Re: Locally working XSLT fails on host with message "Sablotron error

    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
    Nick Kew, Oct 30, 2005
    #6
  7. 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
    Martin Plantec, Oct 30, 2005
    #7
  8. Martin Plantec

    Peter Flynn Guest

    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
    Peter Flynn, Oct 31, 2005
    #8
  9. << 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.
    Martin Plantec, Oct 31, 2005
    #9
  10. 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...
    Martin Plantec, Oct 31, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lobo Bravo
    Replies:
    1
    Views:
    564
    Lobo Bravo
    Feb 23, 2004
  2. Sebastian Langer

    Sablotron C++

    Sebastian Langer, Nov 4, 2003, in forum: XML
    Replies:
    0
    Views:
    461
    Sebastian Langer
    Nov 4, 2003
  3. gouranga
    Replies:
    4
    Views:
    474
    Joe Kesselman
    Aug 3, 2006
  4. Replies:
    7
    Views:
    836
    Martin Gregorie
    Dec 6, 2006
  5. cwig
    Replies:
    0
    Views:
    427
Loading...

Share This Page