[英]xslt: whats the easiest way to do a negated selection?
基本上我想要的是找到ID不能被查找的所有節點('斷開的鏈接'):
<xsl:variable name="failedIDLookups" select="//inventory/box[@boxtypeID != //boxtypes/@ID]"/>
但是這沒有按預期工作 - 我認為語法錯誤,這樣做的正確方法是什么?
我懷疑你想要
<xsl:variable name="failedIDLookups" select="//inventory/box[not(@boxtypeID = //boxtypes/@ID)]"/>
然后可以使用鍵聲明進行優化(作為xsl:stylesheet
的子代)
<xsl:key name="boxtypes-ref" match="boxtypes" use="@ID"/>
和
<xsl:variable name="failedIDLookups" select="//inventory/box[not(key('boxtypes-ref', @boxtypeID))]"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.