gpt4 book ai didi

xml - 按 ID 列表过滤 XSLT 模板

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

我正在挑选一个需要更新的遗留 xslt 文件,而我以前从未用 xsl 编码过。我已经尝试了多种方法来实现这一点,但无法获得正确的结果。我有一个生成 csv 文件的 xslt。在保存 csv 文件之前,如果 ID != 3 或 7,我将尝试过滤掉分配模板。

我已经尝试过这个和所有可能的迭代: <xsl:apply-templates select="Allocations/Allocation[ID != 3 and 7]" mode="FieldMap"/>

这是我目前拥有的:

<xsl:param name="filterType" select="'3,7'"/>
<xsl:variable name="filter" select="concat(',', $filterType, ',')"/>
<xsl:template match="/Trade">

<xsl:variable name="Allocations">
<xsl:apply-templates select="Allocations[contains($filter, concat(',', Allocations/Allocation/ID, ','))]" mode="FieldMap"/>
</xsl:variable>```


Any guidance would be greatly appreciated

最佳答案

XSLT 1.0

select="Allocations/Allocation[ID != '3' and ID != '7']" mode="FieldMap"/>

XSLT 2.0 及更高版本

select="Allocations/Allocation[not(ID=('3','7'))]" mode="FieldMap"/>

关于xml - 按 ID 列表过滤 XSLT 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73197138/

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