我查看了多个示例,并尝试了每个示例。不知道我错过了什么。我发现与其他示例的唯一区别是我<Line>
在<RecordSet>
.
XML:
<?xml version="1.0" encoding="utf-8"?>
<urn:FlatStructure">
<Recordset>
<Line> 12345678</Line>
<Line> abcdefgh</Line>
</Recordset>
</urn:FlatStructure>
XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<!-- First Trial -->
<xsl:variable name="newline"><xsl:text>
</xsl:text></xsl:variable>
<xsl:template match="/urn:FlatStructure/RecordSet">
<xsl:value-of select="concat(Line,$newline)" />
</xsl:template>
<!-- Second Trial -->
<xsl:template match="/urn:FlatStructure">
<xsl:apply-templates select="RecordSet/Line" />
</xsl:template>
<!-- Third Trial -->
<xsl:template match="/urn:FlatStructure">
<xsl:value-of select="concat(Line,' ')" />
</xsl:template>
</xsl:stylesheet>
当前文本输出:
12345678 abcdefgh
所需的文本输出:
12345678
abcdefgh
我在 XSLT 中缺少什么?请让我知道我该如何纠正它。
谢谢
我查看了以下示例(有些可能是重复的),但没有一个对我有用: