Skip to content
Browse files

Merge branch 'develop' of https://github.com/eXist-db/exist into develop

  • Loading branch information...
2 parents 4764a46 + c2c7788 commit 0da9e236196862f0d5cf847382583d2761c96f92 @wolfgangmm wolfgangmm committed Jul 13, 2014
Showing with 41 additions and 3 deletions.
  1. +40 −2 src/org/exist/xquery/lib/json.xq
  2. +1 −1 tools/wrapper/conf/wrapper.conf.in
View
42 src/org/exist/xquery/lib/json.xq
@@ -12,11 +12,49 @@
: <p>An empty element becomes 'null', i.e. &lt;e/&gt; becomes {"e": null}.</p>
: <p>An element with a single text child becomes a property with the value of the text child, i.e.
: &lt;e&gt;text&lt;/e&gt; becomes {"e": "text"}</p>
- : <p>If the attribute json:literal="true" is present on an element, then its text value is considered literal and not quoted as a string. Useful for boolean and numberic values!</p>
+ : <p>If the attribute json:literal="true" is present on an element, then its text value
+ : is considered literal and not quoted as a string. Useful for boolean and numberic
+ : values! The json:annotate-json-literals function can be used to assist in this. </p>
:)
module namespace json="http://www.json.org";
(:~
+: Helper function that annotates
+: elements with `json:literal="true"`
+: if their QNames are present in $literals
+:
+: @param $src One or more nodes to consider for annotation
+: @param $literals The QNames of the elements to annotate
+:
+: @return The $src annotated with json:literal="true" as requested
+:)
+declare function json:annotate-json-literals($src as node()*, $literals as xs:QName+) as node()* {
+ for $n in $src
+ return
+ typeswitch($n)
+ case $d as document-node()
+ return
+ document {
+ json:annotate-json-literals($d/*, $literals)
+ }
+
+ case $e as element()
+ return
+ element { node-name($e) } {
+ if(node-name($e) = $literals)then
+ attribute json:literal { "true" }
+ else(),
+ $e/@*,
+ json:annotate-json-literals($e/node(), $literals)
+ }
+
+ default
+ return
+ $n
+};
+
+
+(:~
: Helper function: output element content for elements with more than one child node or attribute.
:
: Special cases:
@@ -113,4 +151,4 @@ declare function json:node-to-json($node as node()+) {
:)
declare function json:xml-to-json($node as node()) {
json:contents-to-json($node)
-};
+};
View
2 tools/wrapper/conf/wrapper.conf.in
@@ -241,5 +241,5 @@ wrapper.ntservice.interactive=false
#********************************************************************
# Timeouts
#********************************************************************
-# DWES: still valid?
wrapper.ping.timeout=120
+wrapper.startup.timeout=300

0 comments on commit 0da9e23

Please sign in to comment.
Something went wrong with that request. Please try again.