Just did a short blog posting on this topic
here.
In order to make that JSONiq script work on
try.json.io the input needed to be incorporated into the script.
This works on
Xidel processor as well.
JSON input cannot be processed directly, and I was not able to get the "let $m := pxp:json($raw);" trick work.
Next I wanted to "Share" on
try.zorba.io, and to "permalink" on Xidel.
Unfortunately "Share" goes into an endless loop without providing a link.
And the Unicode characters in mapping string break "permalink" feature of Xidel.
Anyway, just copying as slightly modified DataPower JSONiq into both just works!
This is the diff:
$ diff upside-down-ascii.xq upside-down-ascii-inp.xq
3c3
< declare option jsoniq-version "0.4.42";
---
> (: declare option jsoniq-version "0.4.42"; :)
6c6
< declare variable $inp := .;
---
> declare variable $inp := [ "Merry Christmas,", "and a happy new year!", "(2014)" ];
$
Next I did try to get the "!" map feature working.
It is mentioned in the free
JSONiq - The SQL of NoSQL in "III. 10. FLWOR Expressions, Map Operator".
(1 to 10) ! ($$ * 2) in XQ-- or
(1 to 10) ! (. * 2) in XQ++
is equivalent to
for $i in 1 to 10 return $i * 2resulting in
2 4 6 8 10 12 14 16 18 20
I tried to make use of that in
try.zorba.ioThis diff produces "interesting" output:
$ diff upside-down-ascii-inp.xq a.xq
12c12
< for $i in (1 to 31) return $i, fn:string-to-codepoints($m)
---
> for $i in (1 to 31) return 0, fn:string-to-codepoints($m)
20,22c20
< for $c in fn:string-to-codepoints($s)
< return
< fn:codepoints-to-string( $M[$c] )
---
> fn:string-to-codepoints($s) ! fn:codepoints-to-string( $M[.] )
$
It seems that $M[.] is the problem, because this modified script does what it should:
$ diff a.xq b.xq
20c20
< fn:string-to-codepoints($s) ! fn:codepoints-to-string( $M[.] )
---
> fn:string-to-codepoints($s) ! fn:codepoints-to-string( . )
$ Outputs:
[ ")4102(", "!raey wen yppah a dna", ",samtsirhC yrreM" ]
Can somebody make "Share" work again on
try.zorbo.io?
What is the problem with Xidel's "permalink"?
Is the $M[.] for map operator a bug in zorba engine?
Where can I find the map operation in
JSONiq 1.0 spec?
(only found it in the JSONiq book)
Hermann.