Logic XPath 2表达式相互干扰
我有这样一个XML:Logic XPath 2表达式相互干扰,logic,set-theory,Logic,Set Theory,我有这样一个XML: <Values> <Value AttributeID="asset.extension">pdf</Value> <Value AttributeID="asset.size">10326</Value> <Value AttributeID="ATTR_AssetPush_Webshop">1</Value> <Value AttributeID
<Values>
<Value AttributeID="asset.extension">pdf</Value>
<Value AttributeID="asset.size">10326</Value>
<Value AttributeID="ATTR_AssetPush_Webshop">1</Value>
<Value AttributeID="asset.format">PDF (Portable Document Format application)</Value>
<Value AttributeID="asset.mime-type">application/pdf</Value>
<Value AttributeID="asset.filename">filename.pdf</Value>
<Value AttributeID="asset.uploaded">2018-01-10 17:05:39</Value>
<Value AttributeID="ATTR_Verwendungsort" Derived="true">WebShop,</Value>
</Values>
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.mime-type')]" />
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.size')]" />
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.mime-type') and (@AttributeID='asset.size')]" />
<Values>
<Value AttributeID="asset.size">10326</Value>
<Value AttributeID="asset.mime-type">application/pdf</Value>
</Values>
pdf
10326
1.
PDF(便携式文档格式应用程序)
申请表格/pdf
filename.pdf
2018-01-10 17:05:39
网店,
我有两个(或更多)XPath表达式,如下所示:
<Values>
<Value AttributeID="asset.extension">pdf</Value>
<Value AttributeID="asset.size">10326</Value>
<Value AttributeID="ATTR_AssetPush_Webshop">1</Value>
<Value AttributeID="asset.format">PDF (Portable Document Format application)</Value>
<Value AttributeID="asset.mime-type">application/pdf</Value>
<Value AttributeID="asset.filename">filename.pdf</Value>
<Value AttributeID="asset.uploaded">2018-01-10 17:05:39</Value>
<Value AttributeID="ATTR_Verwendungsort" Derived="true">WebShop,</Value>
</Values>
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.mime-type')]" />
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.size')]" />
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.mime-type') and (@AttributeID='asset.size')]" />
<Values>
<Value AttributeID="asset.size">10326</Value>
<Value AttributeID="asset.mime-type">application/pdf</Value>
</Values>
但出于某种原因,如果我把其中两个放在一起,所有信息都会被剥夺。如果我只使用1个expressoin,我将获得所需的输出。我不能用两个这样的表达吗
我还试着这样组合它们:
<Values>
<Value AttributeID="asset.extension">pdf</Value>
<Value AttributeID="asset.size">10326</Value>
<Value AttributeID="ATTR_AssetPush_Webshop">1</Value>
<Value AttributeID="asset.format">PDF (Portable Document Format application)</Value>
<Value AttributeID="asset.mime-type">application/pdf</Value>
<Value AttributeID="asset.filename">filename.pdf</Value>
<Value AttributeID="asset.uploaded">2018-01-10 17:05:39</Value>
<Value AttributeID="ATTR_Verwendungsort" Derived="true">WebShop,</Value>
</Values>
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.mime-type')]" />
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.size')]" />
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.mime-type') and (@AttributeID='asset.size')]" />
<Values>
<Value AttributeID="asset.size">10326</Value>
<Value AttributeID="asset.mime-type">application/pdf</Value>
</Values>
但这也没起作用
所需的输出如下所示:
<Values>
<Value AttributeID="asset.extension">pdf</Value>
<Value AttributeID="asset.size">10326</Value>
<Value AttributeID="ATTR_AssetPush_Webshop">1</Value>
<Value AttributeID="asset.format">PDF (Portable Document Format application)</Value>
<Value AttributeID="asset.mime-type">application/pdf</Value>
<Value AttributeID="asset.filename">filename.pdf</Value>
<Value AttributeID="asset.uploaded">2018-01-10 17:05:39</Value>
<Value AttributeID="ATTR_Verwendungsort" Derived="true">WebShop,</Value>
</Values>
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.mime-type')]" />
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.size')]" />
<xsl:template match="/STEP-ProductInformation/Assets/Asset/Values/Value[not(@AttributeID='asset.mime-type') and (@AttributeID='asset.size')]" />
<Values>
<Value AttributeID="asset.size">10326</Value>
<Value AttributeID="asset.mime-type">application/pdf</Value>
</Values>
10326
申请表格/pdf
我认为在XSLT2/3中,可以将其表示为
<xsl:template match="Values/Value[not(@AttributeID = ('asset.mime-type', 'asset.size'))]"/>
在XSLT/XPath 1.0中,您需要值/Value[而不是(@AttributeID='asset.mime type'或@AttributeID='asset.size')]
这是一个逻辑错误——与XPath无关
这就像是在说:
从一周中的所有日子开始,我将只在周一或周二工作,因此期望的输出是什么?您可能希望将条件更改为
[不是(@AttributeID='asset.mime type'),而不是(@AttributeID='asset.size')]
或者[不是(@AttributeID='asset.mime type'或@AttributeID='asset.size')]
@MartinHonnen添加了所需的output@TimC工作起来很有魅力。请随意添加答案。