Xml 更换';新线';在XSLT中

Xml 更换';新线';在XSLT中,xml,xslt,Xml,Xslt,有一个如下所示的XML标记 <inputT>This is line one This is line two. This is line three.</inputT> "output": "This is line one###This is line two.###This is line three." 我尝试使用下面的XSLT命令来实现这一点 <xsl:text>"output":"</xsl:text> <xs

有一个如下所示的XML标记

<inputT>This is line one
  This is line two.
  This is line three.</inputT>
"output": "This is line one###This is line two.###This is line three."
我尝试使用下面的XSLT命令来实现这一点

<xsl:text>"output":"</xsl:text>
    <xsl:variable name="inputText" select="inputT"/>
    <xsl:value-of select="replace($inputText, '&#10;', '###')" />
<xsl:text>"</xsl:text>
“输出”:
"
但它没有给出预期的结果。如何改进xslt代码以实现目标?


<xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="inputT">
        <xsl:text>"output":"</xsl:text> <xsl:if test="matches(.,'\n')">
            <xsl:value-of select="replace(.,'\n    ',' ')"/>
        </xsl:if><xsl:text>"</xsl:text>
    </xsl:template>
You may try like this
“输出”: " 你可以这样试试
那么你得到了哪一个结果呢?在你的代码片段合并到一个最小但完整的示例中时,给出了输出
“输出”:“这是第一行,这是第二行,这是第三行。”
所以换行确实发生了。你没有告诉我们你以什么方式没有得到“预期的结果”。有错误吗?我更改了转换工具并再次检查。问题在于转换工具
replace
仅在XSLT 2.0及以上版本中受支持,所以您使用的第一个转换工具可能只是XSLT 1.0?