【发布时间】:2017-02-16 17:53:50
【问题描述】:
我有一个用于导入 XML 文件的 xslt 样式表。有一个循环连接一个名为“Note”的子节点。我试图让每个音符节点用新行分隔,但我不知道要输入的字符。在此先感谢您的帮助。这是我的代码:
xslt
<xsl:if test="Note">
<xsl:call-template name="join">
<xsl:with-param name="list" select="Note" />
<xsl:with-param name="separator" select="';'" />
</xsl:call-template>
</xsl:if>
<xsl:template name="join">
<xsl:param name="list" />
<xsl:param name="separator"/>
<xsl:for-each select="$list">
<xsl:value-of select="." />
<xsl:if test="position() != last()">
<xsl:value-of select="$separator" />
</xsl:if>
</xsl:for-each>
</xsl:template>
XML 节点:
<App action="A" id="65806">
<BaseVehicle id="6664"/>
<BodyType id="5"/>
<Note>Upgrade</Note>
<Note>replacement unit comes with a new dustcover / bumper assembly.</Note>
<Qty>2</Qty>
<PartType id="7584"/>
<Position id="30"/>
</App>
预期输出
目前...
Upgrade;replacement unit comes with a new dustcover / bumper assembly.
试图让它看起来像......
Upgrade
replacement unit comes with a new dustcover / bumper assembly.
【问题讨论】:
-
请发布一个可重现示例,包括 XML 输入和预期输出 - 请参阅:minimal reproducible example。
-
@SaggingRufus - 试过了,没用。
-
向我们展示您的示例,其中包含该示例但不起作用
-
这是一个按期分组:见这里stackoverflow.com/questions/35817059/…