Given XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<c cid="c0" v="100">
<d did="c00" v="0" dt="2016-01-01" />
<d did="c01" v="0" dt="2016-02-03" />
<d did="c02" v="0" dt="2016-01-15" />
</c>
<c cid="c1" v="100">
<d did="c10" v="1" dt="2016-01-01" />
<d did="c11" v="0" dt="2015-03-03" />
<d did="c12" v="0" dt="2015-04-15" />
</c>
</root>
I need to find XPath 2.0 or 3.0, which will return me a list of nodes cby expression: find the maximum dnode of this cchild attribute dt(parse it as date), and if the attribute value vis "0", return cnode.
I expect to get one cnode (with @cid = "c0") as a result, because it is /root/c[cid="c1"]/d[@dt="2016-01-01"]/@vnot equal to 0 (equal to 1).
I am stuck in this XPath sofar:
/root/c[d[max(xs:date(@dt))]/@v="0"]
This gives me an error (I am using the Oxygen XML editor, XPath 3.0):
XPath error due to: Effective boolean value not defined for sequence starting with atomic value other than boolean, number, string or URI
, max, .
:
( ).