
You can also call the stylesheet programmatically, but this depends heavily on your programming environment, so please consult the documentation of your programming language or XSLT processor. Java net.sf.saxon.Transform source.xml xml-to-json.xsl This is the only function you should call from your stylesheet. The json:generate() function takes a XML node as input, generates a JSON representation of that node and returns it as an xs:string. If you import XSLTJSON in your stylesheet, you have to add the JSON namespace xmlns:json="" to your stylesheet because all functions and templates are in that namespace. The stylesheet example below would transform any node matching my-node to JSON. You can call the stylesheet from the command line, programmatically, or import it in your own stylesheets. There are three options in using XSLTJSON. If you do not have an XSLT 2.0 processor, you can use XSLTJSON Lite, which is an XSLT 1.0 stylesheet to transforms XML to the JSONML format. To make things even better, it is completely free and open-source. XSLTJSON supports several different JSON output formats, from a compact output format to support for the BadgerFish convention, which allows round-trips between XML and JSON. To make life easier XSLTJSON allows you to transform XML to JSON automatically. JSON is a lightweight data-interchange format based on a subset of the JavaScript language, and often offered as an alternative to XML in-for example-web services.

XSLTJSON is an XSLT 2.0 stylesheet to transform arbitrary XML to JavaScript Object Notation (JSON).

XSLTJSON: Transforming XML to JSON using XSLT
