gpt4 book ai didi

XSLT 多条件

转载 作者:行者123 更新时间:2023-12-01 13:56:39 24 4
gpt4 key购买 nike

我有这个 XSLT 2.0 模板:

<xsl:template match="para[
not(ancestor::p)
and not(ancestor::div)
and not(ancestor::paragraph)
]">
<p class="para">
<xsl:apply-templates/>
</p>
</xsl:template>

它做了我需要它做的事:它阻止了 HTML <p><p> .但它很冗长,我想有一种更简洁的方式来编写它。

有没有更好的方法来编写多祖先测试?我尝试了一个工会..当然没有用。

最佳答案

<xsl:template match="para[not(ancestor::p|ancestor::div|ancestor::paragraph)]">
<p class="para">
<xsl:apply-templates/>
</p>
</xsl:template>

或者

<xsl:template match="para">
<p class="para">
<xsl:apply-templates/>
</p>
</xsl:template>

<xsl:template match="para[ancestor::p|ancestor::div|ancestor::paragraph]" />
<!-- or whatever you want to do in that case, <xsl:apply-templates/> maybe -->

关于XSLT 多条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19587565/

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