- From: Dimitre Novatchev <dnovatchev@gmail.com>
- Date: Tue, 7 Feb 2023 09:06:26 -0800
- To: public-xslt-40@w3.org
- Message-ID: <CAK4KnZcD529Mt9SeORRaMZrr9+=myOKiBE0f_X7SQ24ek+ik+A@mail.gmail.com>
At today's meeting Michael Kay asked for a detailed use-case for map
returning a map with no keys as a result of a failed lookup.
Here is this described in https://github.com/qt4cg/qtspecs/issues/105 "[XPath]
Proposal: Maps with Infinite Number of Keys: Total Maps and Decorated maps
#105"
Using this representation of the empty sequence, we can provide a solution
for the *"Forgiveness problem"
<https://xmlcom.slack.com/archives/C011NLXE4DU/p1616167871037100>* raised
by Jarno Jelovirta in the XML.Com #general channel in *March 2021*:
This expression will raise an error:
[map {"k0": 1}, map{"k0": [1, 2, 3]}]?*?("k0")?*
*[XPTY0004] Input of lookup operator must be map or array: 1.*
To prevent ("forgive", thus "Forgiveness Problem") the raising of such
errors we could accept the rule that in XPath 4.0 any expression that
evaluates to something different than a map or an array, could be coerced
to the following map, which returns the empty sequence as the corresponding
value for any key requested in a lookup:
map {'\' : ()
} (: produces the empty sequence for any lookup:)
Thanks,
Dimitre
Received on Tuesday, 7 February 2023 17:06:51 UTC