在XSLT输出中放置断行

问题描述 投票:0回答:2

XML文档:

<?xml version="1.0" encoding="UTF-8"?>
<ProcessData>
    <SOAPAction>urn:echo</SOAPAction>
    <Content_Type>text/xml;charset=UTF-8</Content_Type>
    <uname>sarah_brcm</uname>
    <pwd>BRCM_UVLwNhjrA5fbgqkUNdxQXMfcCDJ</pwd>
</ProcessData>

XSLT:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
    <xsl:copy-of select="ProcessData/SOAPAction/text()"/>
    <br/>
    <xsl:copy-of select="ProcessData/Content_Type/text()"/>
</xsl:template>
</xsl:stylesheet>

但输出不包含前两行之间的断裂线。

xml xslt
2个回答
1
投票

我在xslttest.appspot.com上检查了你的代码,它确实有效。你如何进行转型?在浏览器中?的libxslt? ...撒克逊?你也可能需要“html”输出方法,而不是“xml”


1
投票

<br/>用于输出HTML。如果你想在数据节点中插入换行符,我建议你使用&#13;

HTML:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
    <xsl:copy-of select="ProcessData/SOAPAction/text()"/>
    <br/>
    <xsl:copy-of select="ProcessData/Content_Type/text()"/>
</xsl:template>
</xsl:stylesheet>

XML:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
    <xsl:copy-of select="ProcessData/SOAPAction/text()"/>
       <xsl:text>&#13;</xsl:text>
       <xsl:text>&#13;</xsl:text>
    <xsl:copy-of select="ProcessData/Content_Type/text()"/>
</xsl:template>
</xsl:stylesheet>
© www.soinside.com 2019 - 2024. All rights reserved.