Xml XSLT 1.0不包含(每个
我想包括以下内容:Xml XSLT 1.0不包含(每个,xml,xslt,foreach,contains,Xml,Xslt,Foreach,Contains,我想包括以下内容: not(contains(country/product/@genericname, 'Color Purple')) 在此中,每个 <xsl:for-each select="country[@name = 'GB']/product[@category = 'inkjet' and contains(@classification, 'consumer') or contains(@classification, 'businessinkjet')]">
not(contains(country/product/@genericname, 'Color Purple'))
在此中,每个
<xsl:for-each select="country[@name = 'GB']/product[@category = 'inkjet' and contains(@classification, 'consumer') or contains(@classification, 'businessinkjet')]">
XML:
编辑
这里是正确的道路,谢谢,是错误的道路
<xsl:for-each select="country[@name = 'GB']/product[@category = 'inkjet' and contains(@classification, 'consumer') or contains(@classification, 'businessinkjet')] [not(contains(**@genericname**, 'Stylus Pro'))]">
非国家/产品/@genericname
谢谢not(contains())
需要在谓词中(在方括号内)。在谓词之外,您需要有一个指向节点的路径。发布一个XML代码示例以获得更具体的答案
我猜这可能是你想要的:
<xsl:for-each select="country[@name = 'GB']/product[@category = 'inkjet' and contains(@classification, 'consumer') or contains(@classification, 'businessinkjet')] [not(contains(@genericname, 'Color Purple'))]">
非常不同于:
[not(contains(country/product/@genericname, 'Stylus Pro'))]
第一个检查当前节点的genericname
属性
select="country[...]/product[...]"
当前节点是产品
第二个属性查看名为product
的节点的genericname
属性,该节点是当前节点的子节点country
的子节点。该属性不存在-因此它当然不包含搜索字符串。@Stefan那么,它是否选择了包含“紫色”的产品在他们的genericname
属性中?@Stefan请不要在评论中发布代码,而是编辑您的问题。--我不确定您是否看到我的评论:您使用的代码不是我发布的代码。我正在学习…我发布了带有我的改编的真实代码我的目标是:我想排除Stylus Pro
<xsl:for-each select="country[@name = 'GB']/product[@category = 'inkjet' and contains(@classification, 'consumer') or contains(@classification, 'businessinkjet')] [not(contains(@genericname, 'Color Purple'))]">
[not(contains(@genericname, 'Stylus Pro'))]
[not(contains(country/product/@genericname, 'Stylus Pro'))]
select="country[...]/product[...]"