Transforming JSON Documents with XSLT
There are several methods that can be used to transform JSON documents through XSLT processing.
Transforming a JSON Document Directly with XSLT
- Create a new transformation
scenario using one of the following types of transformations:
- JSON Transformation with XSLT - This scenario is useful if you want to develop a JSON document and the XSLT document is in its final form.
- XSLT Transformation on JSON - This scenario is useful if you want to develop an XSLT document and the JSON document is in its final form.
- Configure the transformation scenario to suit your needs. In the XSLT tab, make sure you select the JSON file in the JSON URL field and the XSL file in the XSL URL field.
- Run the transformation.
Transforming Multiple JSON Documents at Once
It is also possible to transform multiple JSON documents at once with XSLT processing. To achieve this, select the JSON documents in the Project view, right-click, and apply or configure a transformation scenario.
Transforming a JSON Document Using XSLT and XPath Functions
- Create an XSLT 3.0 stylesheet that has the
xsl:initial-template
. - 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
input
parameter 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
input
parameter (in thexsl:param
element).
- 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.