Changes

Jump to navigation Jump to search
104 bytes removed ,  18:53, 24 September 2013
no edit summary
All errors are assigned to the {{Code|http://basex.org/errors}} namespace, which is statically bound to the {{Code|bxerr}} prefix.
=JSON FunctionsFormats=
[[#json:parse|json:parse]] and [[#json:serialize|json:serialize]] facilitate ==BaseX== The standard BaseX JSON format facilitates a lossless conversion from JSON to XML and back. The transformation is based on the following rules:
# The resulting document has a {{Code|<json/>}} root node.
# Names (keys) of objects are represented as elements:
## The ''string'' type is omitted, as it is treated as default type.
## If a name has the same type throughout the document, the {{Code|type}} attribute will be omitted. Instead, the name will be listed in additional, type-specific attributes in the root node. The attributes are named by their type in the plural (''numbers'', ''booleans'', ''nulls'', ''objects'' and ''arrays''), and the attribute value contains all names with that type, separated by whitespaces.
 
==JsonML==
 
The JsonML format can be used to transform XML to JSON and back, using the JsonML dialect. JsonML allows the transformation of arbitrary XML documents, but namespaces, comments and processing instructions will be discarded in the transformation process. More details are found in the official [http://jsonml.org/XML JsonML documentation].
 
=Functions=
==json:parse==
|}
==json:serialize-ml== {{Version|7.7.2}}: deprecated; please use [[#json:serialize|json:serialize]] instead. {| width='100%'|-| width='120' | '''Signatures'''|{{Func|json:serialize-ml|$input as node()|xs:string}}|-| '''Summary'''|Serializes the node specified by {{Code|$input}} and returns the result as {{Code|xs:string}} instance.<br />XML documents can also be output in the JsonML format by setting the [[Serialization|Serialization Option]] {{Code|"method"}} to {{Code|"jsonml"}}.|-| '''Errors'''|{{Error|BXJS0002|#Errors}} the specified value cannot be serialized.|} ==json:parse-ml== {{Version|7.7.2}}: deprecated; please use [[#json:parse|json:parse]] instead. {| width='100%'|-| width='120' | '''Signatures'''|{{Func|json:parse-ml|$input as xs:string|element()}}|-| '''Summary'''|Converts the [http://jsonml.org JsonML] document specified by {{Code|$input}} to XML, and returns the result as {{Code|element()}} instance. The JSON input must conform to the JsonML specification to be successfully converted.|-| '''Errors'''|{{Error|BXJS0001|#Errors}} the specified input cannot be parsed as JsonML instance.|} =Examples= ==BaseX Format==
'''Example 1: Adds all JSON documents in a directory to a database'''
</pre>
=JsonML Functions[[#json:serialize-ml|json:serialize-ml]] and [[#json:parse-ml|json:parse-ml]] are used to transform XML to JSON and back, using the [http://jsonml.org JsonML] dialect. JsonML can be used to transform arbitrary XML documents, but namespaces, comments and processing instructions will be discarded in the transformation process. More details are found in the official [http://jsonml.org/XML JsonML documentation]. {{Version|7.7.2}}: the functions are now marked as deprecated. Please use [[#json:parse|json:parse]] and [[#json:serialize|json:serialize]] and the <code>{ "format":"jsonml" }</code> option instead. ==json:serialize-ml=={| width='100%'|-| width='120' | '''Signatures'''|{{Func|json:serialize-ml|$input as node()|xs:string}}|-| '''Summary'''|Serializes the node specified by {{Code|$input}} and returns the result as {{Code|xs:string}} instance.<br />XML documents can also be output in the JsonML format by setting the [[Serialization|Serialization Option]] {{Code|"method"}} to {{Code|"jsonml"}}.|-| '''Errors'''|{{Error|BXJS0002|#Errors}} the specified value cannot be serialized.|} ==json:parse-ml=={| width='100%'|-| width='120' | '''Signatures'''|{{Func|json:parse-ml|$input as xs:string|element()}}|-| '''Summary'''|Converts the [http://jsonml.org JsonML] document specified by {{Code|$input}} to XML, and returns the result as {{Code|element()}} instance. The JSON input must conform to the JsonML specification to be successfully converted.|-| '''Errors'''|{{Error|BXJS0001|#Errors}} the specified input cannot be parsed as JsonML instance.|} ==ExamplesFormat==
'''Example 1: Converts all XML documents in a database to JsonML and writes them to disk'''
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu