⚲
Project
Profile
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Search
:
Projects
All Projects
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Saxon
Overview
Roadmap
Issues
Calendar
Blog
Documents
Forums
Files
Repository
Download (918 Bytes)
Bug #1981
» group_by_map.xq
Ed Gimzewski
, 2014-01-16 01:25
declare
namespace
output
=
"http://www.w3.org/2010/xslt-xquery-serialization"
;
declare
namespace
map
=
"http://www.w3.org/2005/xpath-functions/map"
;
declare
option
output:method
"text"
;
declare
option
output:encoding
"utf-8"
;
let
$coll_of_maps
:=
(
map
{
"a"
:=
1
,
"b"
:=
2
}
,
map
{
"a"
:=
1
,
"b"
:=
3
}
,
map
{
"a"
:=
2
,
"b"
:=
2
}
,
map
{
"a"
:=
2
,
"b"
:=
4
}
,
map
{
"a"
:=
3
,
"b"
:=
2
})
(: this creates an exception if returned :)
let
$grouping_not_trapped
:=
for
$m
in
$coll_of_maps
let
$a
:=
$m
(
'a'
)
group
by
$a
return
map
{
"key"
:=
$a
,
"members"
:=
$m
}
(: this same code trapped works OK :)
let
$grouping_trapped
:=
try
{
for
$m
in
$coll_of_maps
let
$a
:=
$m
(
'a'
)
group
by
$a
return
map
{
"key"
:=
$a
,
"members"
:=
$m
}
}
catch
*
{
map
{
"err"
:=
$err:description
}
}
(: edit to return $grouping_not_trapped to see it fail :)
return
serialize-json
(
$grouping_trapped
)
« Previous
1
2
Next »
(1-1/2)
Loading...