我的xslt中有以下结构 -
<Identification>
<xsl:for-each select="DataPartner">
<xsl:variable name="var:v30" select="userCSharp:LogicalEq(string(../../Demo/@name) , "Description")" />
<xsl:if test="string($var:v30)='true'">
<Identifier>
<xsl:value-of select="Demo/demo/text()" />
<xsl:text>,</xsl:text>
</Identifier>
</xsl:if>
</xsl:for-each>
</Identification>
输入xml -
<DataPartner>
<Demo name="Description">
<demo>demo11</demo>
</Demo>
<Demo name="Description">
<demo>demo12</demo>
</Demo>
<DataPartner>
预期产出 -
demo11 , demo12
答案 0 :(得分:2)
如果打算连接所有demo
元素文本,其中Demo
名称是&#34;描述&#34;,那么这就是你如何做到的....
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" />
<xsl:template match="DataPartner">
<Identifier>
<xsl:for-each select="Demo[@name='Description']">
<xsl:if test="position() > 1">, </xsl:if>
<xsl:value-of select="demo" />
</xsl:for-each>
</Identifier>
</xsl:template>
</xsl:stylesheet>