Re: [xslt] crappy formatting with <xsl:text>



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 <liam holoweb net> 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

Attachment: xsltproc-example.tar.bz2
Description: BZip2 compressed data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]