简体   繁体   English

xslt:什么是做出否定选择的最简单方法?

[英]xslt: whats the easiest way to do a negated selection?

Basically what I would like is something like this that finds all nodes where the ID cannot be lookup'ed up ('broken links') : 基本上我想要的是找到ID不能被查找的所有节点('断开的链接'):

<xsl:variable name="failedIDLookups" select="//inventory/box[@boxtypeID != //boxtypes/@ID]"/>

But this is not working as expected - I suppose the syntax is wrong, what should be the correct way of doing this ? 但是这没有按预期工作 - 我认为语法错误,这样做的正确方法是什么?

I suspect you want 我怀疑你想要

<xsl:variable name="failedIDLookups" select="//inventory/box[not(@boxtypeID = //boxtypes/@ID)]"/>

which then could be optimized with a key declaration (as a child of xsl:stylesheet ) 然后可以使用键声明进行优化(作为xsl:stylesheet的子代)

<xsl:key name="boxtypes-ref" match="boxtypes" use="@ID"/>

and

<xsl:variable name="failedIDLookups" select="//inventory/box[not(key('boxtypes-ref', @boxtypeID))]"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM