开发者

How to keep formating with XSL-FO (keeping CR-LF characters)?

I'm trying to embed some text into a PDF I generate using XSL-FO/xslt. My text is embedded correctly but the LineFeed and Carriage Returns are removed, so my text file is just a huge block of text.

I'm using unparsed-text() to get the content of the text file. I used the white-space-collapse="false" to try to get the unformatted text.

<fo:block font-family="monospace" white-space-collapse="false" wrap-开发者_StackOverflow社区option="no-wrap">
    <xsl:value-of select="unparsed-text($EXTERNAL_DOCUMENT_FILENAME)" disable-output-escaping="yes"/>
</fo:block>

Thank you!

===========

EDIT

I just tried this and I noticed that the output is not formated...

<fo:block font-family="monospace" white-space-collapse="false" wrap-option="wrap">
    <!--<xsl:value-of select="unparsed-text($EXTERNAL_DOCUMENT_FILENAME)" />-->
Hi this is me,
Then this is him,

Then I have set the value.

    OK?
</fo:block>

I was expecting the exact same text with LF and CR, why?


Here is the answer I found:

<fo:block font-family="monospace" wrap-option="wrap" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve">
    <!--<xsl:apply-templates select="*|text()"/>-->
    <xsl:value-of select='n1:text/text()'/>
</fo:block>

This works fine, xsl-fo was removing the CR-LF.


Do not use <xsl:strip-space="yes"/>.

Also, DOE is not a mandatory feature and in XSLT 2.0 may be supported only for backwards-compatibility features. Try to avoid it.

Try a small text file and see if NL characters are obtained as result of unparsed-text() (without XSL-FO at all). If the NL characters are present, then your question is most probably only XSL-FO - related and not XSLT one. If NL characters are not present, then this indicates a bug in your XSLT processor's implementation of unparsed-text() -- so contact the vendor and file a bug.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜