如何解决FOP XSL 1.0 替换文本并保留换行符
我正在尝试使用 xsl + xml 生成 pdf,但是我在文档的一部分上遇到了问题,其中有一些带有换行符的文本行。 生成文档时,它没有保留这些换行符。
我什么都试过了,我完全卡住了。
我的代码是:
const material = new THREE.MeshStandardMaterial({
color: 0xff0000,transparent: false,opacity: 0.5
});
const object = new THREE.Mesh(gltf,material)
return <primitive object={object.scene} position={[0,0]} />
}
使用模板函数:
<fo:table-row>
<fo:table-cell margin-right="0mm" margin-left="0mm"
margin-bottom="0mm" margin-top="0mm"
xsl:use-attribute-sets="bordergris" number-columns-spanned="5">
<fo:block xsl:use-attribute-sets="titoldades"
space-before.optimum="0pt" space-after.optimum="0pt"
keep-together="always" >
More info:
</fo:block>
<fo:block xsl:use-attribute-sets="dades"
space-before.optimum="0pt" space-after.optimum="0pt"
keep-together="always" linefeed-treatment="preserve">
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="/Response/DataList/Data/MoreInfo"/>
<xsl:with-param name="replace" select="' '" />
<xsl:with-param name="with" select="'<fo:block/>'"/>
</xsl:call-template>
</fo:block>
</fo:table-cell>
</fo:table-row>
结果文本显示为硬编码文本“
我做错了什么?
谢谢!!!
解决方法
重要的是将以下属性放入 fo:block 中:
inefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve"
然后使用以下内容进行替换:
<fo:block xsl:use-attribute-sets="dades"
linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve">
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="/Response/DataList/Data/MoreInfo"/>
<xsl:with-param name="replace" select="' '" />
<xsl:with-param name="with" select="'
'"/>
</xsl:call-template>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。