gpt4 book ai didi

xslt - 如何对 xsl :copy? 中的所有非选定属性执行应用模板

转载 作者:行者123 更新时间:2023-12-04 05:33:15 25 4
gpt4 key购买 nike

假设我有以下 XSLT:

<xsl:template match="property">
<xsl:copy>
<xsl:apply-templates select="@id"/>
<xsl:apply-templates select="@name"/>
<xsl:apply-templates select="@componentClassID"/>
</xsl:copy>
</xsl:template>

如何使用 apply-templates 语句来结束副本,该语句选择之前的 apply-templates 语句中未指定的所有属性?

以下是否正确?
<xsl:apply-templates select="@*[name()!='id' and name()!='name' and name()!='componentClassID']"/>

最佳答案

Would the following be correct?

<xsl:apply-templates select=
"@*[name()!='id' and name()!='name' and name()!='componentClassID']"/>


是的,但是好像太长了 .此外,建议永远不要使用 !=运算符,因为当它的参数之一是节点集时,它的语义(行为)不直观。

当要排除的属性名很多时,我宁愿写成这样:
<xsl:apply-templates select=
"@*[not(contains('+id+name+componentClassID+', concat('+', name(), '+')))]"/>

关于xslt - 如何对 xsl :copy? 中的所有非选定属性执行应用模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12311066/

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