我遇到了麻烦,我相信,无法过滤变量节点集。
我有一个变量,其中填充了来自文档集合的节点集,如果输入中不存在这些节点,我想回显输入并添加变量节点。
<xsl:variable name="views" select="collection('file:/C:/temp/?select=*.xml;recurse=yes')"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="@* | *"/>
<!-- having trouble with the filter here never works -->
<xsl:for-each select="$views/someElement[not(@name=(//someInputElement/@name))]">
<!-- copy stuff in -->
</xsl:for-each>
</xsl:copy>
</xsl:template>
请注意,输入中会有许多带有 name 属性的 someInputElement 实例。
当我针对目标运行 xpath //someInputElement/@name 时,我得到了预期的列表。
任何建议最受赞赏。