Re: crappy formatting with <xsl:text>

Jan Kotuc <[email protected]>
Newsgroups gmane.comp.gnome.lib.xslt
Message-ID <CACiQud6cWDPntym-7r6qOqY72s_7LtgT4LbiCBcJk8v=BReCxQ@mail.gmail.com>
Hello, this is the desired test case (attached).

Use case: create a DocBook chapter out of an XML test report.

Files used:

* example-input.xml -- input XML file

* example-with-text.xsl -- an example stylesheet with an <xsl:text>
element containing arbitrary text

* example-without-test.xsl -- an example stylesheet with no <xsl:text>
element (it is commented out)

* exampleoutput-with-text.xml / exampleoutput-without-text.xml --
respective output files.

Commands used:

xsltproc -o exampleoutput-with-text.xml example-with-text.xsl example-input.xml
xsltproc -o exampleoutput-without-text.xml example-without-text.xsl
example-input.xml

Version:

both libxslt and xsltproc: 1.1.26-6 (Ubuntu 10.10 standard version
from package repository)

RESULT:

One can clearly see that one file is pretty-printed and the other one
is not, even though both are well-formed and machine-readable. Why is
that so???

You might perhaps ask why I need to put some stupid text in the first
place. Well, the sentence "long live the queen" is clearly useless,
but in real life I need to put a DocBook "include link" such as this:

&some-link-name;

See the problem now? XSL parser reports an unidentified entity. :( I
found no way around this except for enclosing it in an <xsl:text>
element:

<xsl:text disable-output-escaping="yes">
&#38;some-link-name;
</xsl:text>

Such approach outputs the entity name correctly, at the cost of
"prettiness". Is there a better way? I'd like to have an output file
which is (A) well-formed, (B) contains a correct and not corrupt
DocBook link such as shown before, (C) pretty-printed. Can I achieve
that with libxslt? Right now I'm afraid I'll have to introduce the
problematic link by sed :(

Please help if you can. TIA.

Jan

On 7/26/11, Liam R E Quin <[email protected]> wrote:
> You need to make a small test-case with
> * a short XSLT stylesheet
> * a short input document
> * the output you get
> * the output you expected to get
>
> You need to say exactly which version of xsltproc you are using.
>
> Note also that whitespace in a template will generally get copied to the
> output unless you surround all non-whitespace text in the template with
> xsl:text elements; the indent="yes" parameter obviously also makes a
> difference.
>
> Liam

_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
[email protected]
http://mail.gnome.org/mailman/listinfo/xslt
xsltproc-example.tar.bz2 (application/x-bzip2, 2.6 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.