From 7060dd890190267b15a6b33c039e3f65d31f2571 Mon Sep 17 00:00:00 2001 From: Adrian Hamm Date: Tue, 28 Jan 2020 16:25:51 +0100 Subject: [PATCH 1/2] Add fn:xml-to-json() Add documentation and examples for fn:xml-to-json(). --- .../xar-resources/data/docs/fn/xml-to-json.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/xar-resources/data/docs/fn/xml-to-json.md diff --git a/src/main/xar-resources/data/docs/fn/xml-to-json.md b/src/main/xar-resources/data/docs/fn/xml-to-json.md new file mode 100644 index 0000000..f5c195e --- /dev/null +++ b/src/main/xar-resources/data/docs/fn/xml-to-json.md @@ -0,0 +1,41 @@ +# fn:xml-to-json() ([specification](https://www.w3.org/TR/xpath-functions-31/#func-xml-to-json")) +handles most valid input according to specification. Notable exceptions follow. + +All (un-)escaping is delegated to com.fasterxml.jackson. All output is generated by jackson +and should be proper JSON. + +`fn:xml-to-json()` does not replace codepoints in the range `1-31` or `127-159` in any string or map key. + +`fn:xml-to-json()` unescapes and reescapes any string and map key marked as being escaped. +It does not do additional special character replacements mentioned in the spec. +It does not do an otherwise verbatim copy. + +# Examples +## 1) +```xquery +let $node :=  +return fn:xml-to-json($node) +``` +does return `""` and not `"\u007F"`. + +## 2) +```xquery +let $node := \/ +return fn:xml-to-json($node) +``` +does return `"/"` and not `"\/"`. + +##3) +```xquery +let $node :=  +return fn:xml-to-json($node) +``` +does return `""` and not `"\u007F"`. + +## 4) +```xquery +let $node := "" +return fn:xml-to-json($node) +``` +does return `""` and not `"\"\""`. + From 66d69800147da3835cd4c3e5852b86d64ba13cb7 Mon Sep 17 00:00:00 2001 From: agh2342 <58335520+agh2342@users.noreply.github.com> Date: Fri, 31 Jan 2020 17:48:00 +0100 Subject: [PATCH 2/2] Update src/main/xar-resources/data/docs/fn/xml-to-json.md Co-Authored-By: Duncan Paterson --- src/main/xar-resources/data/docs/fn/xml-to-json.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/xar-resources/data/docs/fn/xml-to-json.md b/src/main/xar-resources/data/docs/fn/xml-to-json.md index f5c195e..ae648a5 100644 --- a/src/main/xar-resources/data/docs/fn/xml-to-json.md +++ b/src/main/xar-resources/data/docs/fn/xml-to-json.md @@ -1,7 +1,7 @@ # fn:xml-to-json() ([specification](https://www.w3.org/TR/xpath-functions-31/#func-xml-to-json")) handles most valid input according to specification. Notable exceptions follow. -All (un-)escaping is delegated to com.fasterxml.jackson. All output is generated by jackson +All output is generated by the `jackson` library and should be proper JSON. All (un-) escaping is delegated to `com.fasterxml.jackson`. and should be proper JSON. `fn:xml-to-json()` does not replace codepoints in the range `1-31` or `127-159` in any string or map key. @@ -38,4 +38,3 @@ let $node := "" return fn:xml-to-json($node) ``` does return `""` and not `"\"\""`. -