[Top] [All Lists]

[xsl] How to write (existential) predicates with maps/Why is there no effective boolean value for a map?

2019-02-11 06:09:30
When using XPath 3.1 (e.g. in XSLT 3) on maps I have found that I have to change my coding habit a bit when writing predicates that want to check the existence of some nested map, while I hoped to be able to write e.g.

  ?locations?*[?types?*[?name = 'foo']]

to select all (map) members of the "locations" array that have a "types" array with at least one (map) member having a property "name" with value "foo" I get an error

Effective boolean value is not defined for sequence starting with an atomic value other than a boolean, number, or string

So in contrast to my experience with writing predicates on XML it seems for maps I have to explicitly use the "exists" function e.g.

  ?locations?*[exists(?types?*[?name = 'foo'])]

or a "some .. in" expression

  ?locations?*[some $m in ?types?* satisfies $m?name = 'foo']

Is there any more compact way to write such a check?

What is the reason that the effective boolean value was not extended to give true for a sequence with a map?
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com

<Prev in Thread] Current Thread [Next in Thread>