给定 XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<c cid="0">
<d did="c0d0" d1="2015-02-11" d2="2015-06-15" />
<d did="c0d1" d1="2015-04-01" d2="2015-04-14" />
</c>
<c cid="1">
<d did="c1d0" d1="2014-11-15" d2="2015-07-21" />
<d did="c1d1" d1="2016-02-10" d2="2016-02-25" />
</c>
</root>
使用 XPath 3.0 我必须找到所有c
节点,其中至少有一个d
子节点,其d2-d1
属性值差异小于或等于 30 天。d1
和d2
值是YYYY-MM-DD
格式的日期。我试过 XPath:
/root/c[d/xs:date(@d2)-d/xs:date(@d1)<=30]
但我有错误:
Cannot compare xs:dayTimeDuration to xs:integer
我XPath Builder
在XPath 3.0
模式中使用Oxygen XML Editor v18
. 我想这个错误是由于不正确的持续时间设置造成的。请建议如何在 XPath 3.0 中将持续时间指定为文字。谢谢!