0
在下面的XSL中,每當xsl:when得到滿足時,我都想要追加儘可能多的標籤和>和</a
>標籤。但是需要在標籤內部填充的數據應該只有一次。我已經展示了最終的預期產出。 我該如何修改XSL以更改xml格式
<xsl:param name="insert-file" as="document-node()" />
<xsl:template match="*">
<xsl:variable name="input">My text</xsl:variable>
<xsl:variable name="Myxml" as="element()*">
<xsl:call-template name="populateTag">
<xsl:with-param name="nodeValue" select="$input"/>
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="$Myxml"></xsl:copy-of>
</xsl:template>
<xsl:template name="populateTag">
<xsl:param name="nodeValue"/>
<xsl:for-each select="$insert-file/insert-data/data">
<xsl:choose>
<xsl:when test="@index = 1">
<a><xsl:value-of select="$nodeValue"></xsl:value-of></a>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
電流輸出:
<?xml version="1.0" encoding="UTF-8"?
> <a
>我的文字</a
> <a
>我的文字</a
> <a
>我的文字</a
> <a
>我的文字</a
>
一世 希望模板「populateTag」以下面的格式返回我的xml。我如何修改模板「populateTag」以達到相同效果。
從模板預期輸出 「populateTag」: <?xml version="1.0" encoding="UTF-8"?
> <a
><a
><a
><a
>我的文字</a
></a
></a
></a
>
請給你的想法。
感謝您的答覆。有用。 – user323719 2010-04-23 18:22:00