如何在 xslt 输出的末尾添加换行符? [英] how to add line breaks at the end of an xslt output?

查看:57
本文介绍了如何在 xslt 输出的末尾添加换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
在 XSLT 中生成新行

如果有以下xslt文件:

if have the following xslt file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="text" />
    <xsl:template match="//teilnehmer">
        <xsl:value-of select="name"/>
        <xsl:value-of select="kind"/>
    </xsl:template>
</xsl:stylesheet>

转换后的输出是一个没有任何空格或换行符的字符串

the output after transformation is a string without any whitespaces or line breaks

如何添加一些格式(例如名称后的换行符)?

how can I add some formatting (e.g. a line break after a name)?

提前致谢!

推荐答案

最简单的方法是使用

<xsl:text>&#x0A;</xsl:text>

&#x0A; 是表示换行符的字符引用.或者你可以做

&#x0A; being a character reference that represents the newline character. Alternatively you can do

    <xsl:text>
</xsl:text>

(即 <xsl:text> 只包含一个换行符)但您需要确保换行符和结束 </xsl:text> 之间没有空格.(因为它们将包含在输出中),如果您曾经使用过自动缩进的 IDE,这很容易搞砸.使用字符引用更可靠.

(i.e. an <xsl:text> containing just a newline character) but you need to ensure there are no spaces between the newline and the closing </xsl:text> (as they would be included in the output), which is easy to mess up if you ever use an IDE that does automatic indentation. Using the character reference is more robust.

这篇关于如何在 xslt 输出的末尾添加换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆