Transforming JSON Documents with XSLTEdit online
It is possible to transform JSON documents through XSLT processing. To do so, follow these steps:
- Create an XSLT 3.0 stylesheet that has the
xsl:initial-template. You can use one of the following two templates available in the New Document Wizard.- XSLT Stylesheet for JSON - Processes a JSON document by using a
json-doc()function and matches the JSON properties from the JSON map. - XSLT Stylesheet for JSON to XML - Processes a JSON document by using a
json-to-xml()function and matches the converted XML content.
- XSLT Stylesheet for JSON - Processes a JSON document by using a
- Create a new XSLT transformation scenario for your stylesheet.
- Reference the JSON document that you want to transform using one of these two methods:
- In the transformation scenario, click the Parameters button
in the XSLT tab and add a parameter that specifies the URL to
your JSON document in its value. For example, if you are transforming one of the
built-in templates mentioned above, the
inputparameter is added by default and you could specify the URL in its value. - Specify the URL to your JSON document in the stylesheet you created. For example, if
you use one of the built-in templates mentioned above, you would specify the URL in
the value of the
inputparameter (in thexsl:paramelement).
- In the transformation scenario, click the Parameters button
in the XSLT tab and add a parameter that specifies the URL to
your JSON document in its value. For example, if you are transforming one of the
built-in templates mentioned above, the
- Run the transformation.
Tip: There are some sample files in the
[OXYGEN_INSTALL_DIR]/samples/json/transform folder that can be used
to transform a JSON document to XML or HTML.