-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from agh2342/feature/xml-to-json
Add fn:xml-to-json()
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# 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 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. | ||
|
||
`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 := <string></string> | ||
return fn:xml-to-json($node) | ||
``` | ||
does return `""` and not `"\u007F"`. | ||
|
||
## 2) | ||
```xquery | ||
let $node := <string escaped="true">\/</string> | ||
return fn:xml-to-json($node) | ||
``` | ||
does return `"/"` and not `"\/"`. | ||
|
||
##3) | ||
```xquery | ||
let $node := <string escaped="true"></string> | ||
return fn:xml-to-json($node) | ||
``` | ||
does return `""` and not `"\u007F"`. | ||
|
||
## 4) | ||
```xquery | ||
let $node := <string escaped="true">""</string> | ||
return fn:xml-to-json($node) | ||
``` | ||
does return `""` and not `"\"\""`. |