gpt4 book ai didi

xml - 我们可以有多个 xsl :templates with match ="/"?

转载 作者:数据小太阳 更新时间:2023-10-29 02:27:04 26 4
gpt4 key购买 nike

我们可以有多个带有 match="/"和不同名称的 xsl:templates 吗?基本上我想迭代一个 xml 直到某些级别,然后如果满足某些条件则从“/”再次开始迭代。所以我想做一个 <xsl:call-template name="option-1"><xsl:call-template name="option-1">基于某些条件,option-1 和 option-2 都类似于 <xsl:template match="/" name="option-1"><xsl:template match="/" name="option-2">分别。

如果有更好的方法,我是开放的。我想要的只是再次从根节点开始迭代。

最佳答案

您正在寻找的概念是模板模式。你可以定义

<xsl:template match="/" mode="option1">

同样,选项 2,以及您的无模式初始起始模板

<xsl:template match="/">
<xsl:choose>
<xsl:when test="some-condition">
<xsl:apply-templates select="/" mode="option1" />
</xsl:when>
<xsl:otherwise test="some-condition">
<xsl:apply-templates select="/" mode="option2" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

XSLT 1.0 spec , XSLT 2.0 spec

关于xml - 我们可以有多个 xsl :templates with match ="/"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13821572/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com