Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

In sync with API changes.

  • Loading branch information...
commit fe39b761916c76027ba700108ca1c6427cc1179f 1 parent 32a95e0
@ryangrimm authored
Showing with 28 additions and 25 deletions.
  1. +14 −13 test/xq/isomorphic.xqy
  2. +14 −12 test/xq/parse.xqy
View
27 test/xq/isomorphic.xqy
@@ -1,17 +1,18 @@
xquery version "1.0-ml";
-import module namespace json = "http://marklogic.com/json"
- at "/lib/json.xqy" ;
-
-declare variable $json := xdmp:get-request-field( "json" ) ;
-declare variable $transformed :=
- fn:string( json:xmlToJSON( json:jsonToXML( $json )/* ) ) ;
-declare variable $valid := $json = $transformed ;
+import module namespace json = "http://marklogic.com/json" at "/lib/json.xqy";
try {
-$valid,
-if( $valid ) then () else
- xdmp:log( ("Got: ", $transformed, "Expected: ", $json ) ) }
-catch ( $e ) {
- fn:concat( "Logged Exception: ", $e//*:message ),
- xdmp:log( ("Exception: ", $e, "Expected: ", $json ) ) }
+ let $json := xdmp:get-request-field("json")
+ let $transformed := json:xmlToJSON(json:jsonToXML($json))
+ let $valid := $json = $transformed
+ let $log :=
+ if($valid)
+ then ()
+ else xdmp:log(fn:concat("Got: ", $transformed, " Expected: ", $json))
+ return $valid
+}
+catch ($e) {
+ fn:concat("Logged Exception: ", $e//*:message),
+ xdmp:log(fn:concat("Exception: ", xdmp:quote($e), " Expected: ", xdmp:get-request-field("json")))
+}
View
26 test/xq/parse.xqy
@@ -1,17 +1,19 @@
xquery version "1.0-ml";
-import module namespace json = "http://marklogic.com/json-query"
- at "/lib/json-query.xqy" ;
+import module namespace json = "http://marklogic.com/json-query" at "/lib/json-query.xqy" ;
-declare variable $json := xdmp:get-request-field( "json" ) ;
-declare variable $path := xdmp:get-request-field( "path" ) ;
-declare variable $got := json:parse($json) ;
-declare variable $valid := $got = $path ;
+declare variable $json := xdmp:get-request-field("json");
+declare variable $path := xdmp:get-request-field("path");
+declare variable $got := json:parse($json);
+declare variable $valid := $got = $path;
try {
-$got,
-if( $valid ) then () else
- xdmp:log( ("Got: ", $got, "Expected: ", $path ) ) }
-catch ( $e ) {
- fn:concat( "Logged Exception: ", $e//*:message ),
- xdmp:log( ("Exception: ", $e, "JSON: ", $json, "Expected:", $path ) ) }
+ $got,
+ if($valid)
+ then ()
+ else xdmp:log(fn:concat("Got: ", $got, "Expected: ", $path))
+}
+catch ($e) {
+ fn:concat("Logged Exception: ", $e//*:message),
+ xdmp:log(fn:concat("Exception: ", $e, "JSON: ", $json, "Expected:", $path))
+}
Please sign in to comment.
Something went wrong with that request. Please try again.