Skip to content

Commit

Permalink
Merge pull request #37 from agh2342/feature/xml-to-json
Browse files Browse the repository at this point in the history
Add fn:xml-to-json()
  • Loading branch information
joewiz authored Jan 31, 2020
2 parents d9188fd + 66d6980 commit 614f19a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/main/xar-resources/data/docs/fn/xml-to-json.md
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>&#127;</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">&#127;</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 `"\"\""`.

0 comments on commit 614f19a

Please sign in to comment.