Re: [xsl] Using unparsed-text() to test prolog

Subject: Re: [xsl] Using unparsed-text() to test prolog
From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx>
Date: 17 Feb 2006 07:06:02 +0000
>>>>> "Jesper" == Jesper Tverskov <jesper@xxxxxxxxxxx> writes:

    Jesper> Hi list

    Jesper> A week ago Colin Adams reminded us: "in XSLT 2.0 you can
    Jesper> call unparsed-text on the document and read the DOCTYPE".

    Jesper> It has inspired me to make a sort of
    Jesper> "prolog-identity-template".  I have just published an
    Jesper> article about it: "Using unparsed-text() in XSLT 2.0 to
    Jesper> test prolog".

A few comments:

The four variables input-file etc. is not exactly robust. They assume
people are sticking to semi-conventional usages for file names.
Probably the O/S name should be obtained via system-property (not
available as standard, but can probably be obtained by my proposed
exslt extension)

Perhaps an xsl:function library for parsing filenames and URIs would
be a useful project.

What is this nonsense in footnote [3] about / being wrong? It is the
correct separator. \ is invalid in URIs so cannot occur in a
conformant system, unless you first decode the URI.

Your assumption that the encoding must be UTF-8 if not present is not
justified. It might be UTF-16 <horror/>.
Unparsed-text() won't give you the value of the BOM, if present, so
this had better be a configuration parameter (which still isn't
perfect - there might be a mixed set).

I'll also take the opportunity to mention that my gexslt/gestalt
processor also allows writing a DTD internal subset, although not in
such a sophisticated way as Saxon (you just provide it with a single
text string for the whole internal subset).
Colin Adams
Preston Lancashire

Current Thread