【发布时间】:2014-08-28 13:13:56
【问题描述】:
我想包括这个:
not(contains(country/product/@genericname, 'Color Purple'))
在这个for-each
<xsl:for-each select="country[@name = 'GB']/product[@category = 'inkjet' and contains(@classification, 'consumer') or contains(@classification, 'businessinkjet')]">
我试过了:
<xsl:for-each select="not(contains(country/product/@genericname, 'Stylus Pro')) and country[@name = $country]/product[@category = 'inkjet' and contains(@classification, 'consumer') or contains(@classification, 'businessinkjet')]">
但是,我收到此错误:The value is not a node-set。我没有看到语法错误。
处理器:Saxon6.5.5
@michael.hor257k
我调整了你的 sn-p,用我的参数看起来更合适。
<xsl:param name="country">GB</xsl:param>
<xsl:for-each select="country[@name = $country]/product[@category = 'inkjet' and contains(@classification, 'consumer') or contains(@classification, 'businessinkjet')] [not(contains(country/product/@genericname, 'Stylus Pro'))]">
XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<countries>
<country name="GB">
<product genericname="Yellow line" id="12345" />
<product genericname="Red line" id="6789" type="device" />
<product genericname="This is Stylus Pro" id="256464" />
</country>
</countries>
编辑
这是正确的方法,谢谢,是错误的路径。
<xsl:for-each select="country[@name = 'GB']/product[@category = 'inkjet' and contains(@classification, 'consumer') or contains(@classification, 'businessinkjet')] [not(contains(**@genericname**, 'Stylus Pro'))]">
不是国家/产品/@genericname
谢谢
【问题讨论】: