【发布时间】:2019-12-22 13:31:53
【问题描述】:
我有一个这样的 XML:
<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>
我有 2 个(或更多)这样的 XPath 表达式:
<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')]" />
但由于某种原因,如果我将其中两个放在一起,则所有信息都将被剥离。如果我只使用 1 个 expressoin,我会得到我想要的输出。我不能像这样使用2个表达式吗?
我也尝试像这样组合它们:
<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>
【问题讨论】:
-
那么想要的输出是什么?
-
您可能希望将条件更改为
[not(@AttributeID='asset.mime-type') and not(@AttributeID='asset.size')]或[not(@AttributeID='asset.mime-type' or @AttributeID='asset.size')]。 -
@MartinHonnen 添加了所需的输出
-
@TimC 就像一个魅力。随意添加答案。
标签: logic set-theory