Module URI

http://www.json.org

Module Description

Transform XML fragments into JSON. The target of this module is to create a straight-forward Javasript representation of data-centric XML. It does not try to handle mixed content nodes (with a mix of elements and text).

Special rules

The root element will be absorbed, i.e. <root>text</root> becomes "text".

Child elements with the same name are added to an array.

If an element has attribute and text content, the text content becomes a property, e.g. '#text': 'my text'.

In mixed content nodes, text nodes will be dropped.

An empty element becomes 'null', i.e. <e/> becomes {"e": null}.

An element with a single text child becomes a property with the value of the text child, i.e. <e>text</e> becomes {"e": "text"}

   

Function Summary

 

Function Detail

contents-to-json

Helper function: output the contents of a node or attribute. Special cases:

An empty element becomes 'null', i.e. <e/> becomes {"e": null}.

An element with a single text child becomes a property with the value of the text child, i.e. <e>text</e> becomes {"e": "text"}

External Functions that are used by this Function
Module URIFunction Name
  
http://www.w3.org/2005/xpath-functionsconcat
count
string
Internal Functions used by this Function
Module URIFunction Name
  
http://www.json.orgelement-helper
node-to-json
Internal Functions that invoke this Function
Module URIFunction Name
  
http://www.json.orgnode-to-json
xml-to-json
 
element-helper

Helper function: output element content for elements with more than one child node or attribute. Special cases:

Child elements with the same name are added to an array.

If an element has attribute and text content, the text content becomes a property, e.g. '#text': 'my text'.

In mixed content nodes, text nodes will be dropped.

External Functions that are used by this Function
Module URIFunction Name
  
http://www.w3.org/2005/xpath-functionsconcat
distinct-values
node-name
string-join
Internal Functions used by this Function
Module URIFunction Name
  
http://www.json.orgnode-to-json
Internal Functions that invoke this Function
Module URIFunction Name
  
http://www.json.orgcontents-to-json
 
node-to-json

Helper function: convert a node into JSON.

External Functions that are used by this Function
Module URIFunction Name
  
http://www.w3.org/2005/xpath-functionsconcat
node-name
string-join
Internal Functions used by this Function
Module URIFunction Name
  
http://www.json.orgcontents-to-json
Internal Functions that invoke this Function
Module URIFunction Name
  
http://www.json.orgcontents-to-json
element-helper
 
xml-to-json

Main entry point of the module. Convert a single node into JSON. The root element will be absorbed.

Internal Functions used by this Function
Module URIFunction Name
  
http://www.json.orgcontents-to-json
 
 
Created by xqDoc-Lite version 1.0 on Sat Nov 03 20:11:39 CET 2007