VideosTransform JSON Documents with XSLT/XQuery

Overview

Duration: 07:22

This video demonstrates using Oxygen XML Editor to transform JSON documents into HTML output with XSLT processing and into XML output with XQuery processing. For more technical details, see the 'Transforming and Querying JSON Documents' section in our user manual: www.oxygenxml.com/doc/ug-editor/topics/json-transforming.html.

Transcript

00:00:05this video demonstrates transforming
00:00:07Json content into various output formats
00:00:09using xslt and xquery processing
00:00:13specifically we will show you examples
00:00:15where we obtain HTML output from Json
00:00:17content using xslt and we obtain XML
00:00:21output from Json content using xquery
00:00:24note that you can transform Json content
00:00:26into a myriad of other output formats as
00:00:28well
00:00:30for the demonstration we're using a
00:00:32sample project about weather data this
00:00:34is our Json document that contains data
00:00:36about the weather for various
00:00:38cities and this is our xslt
00:00:42file for this example we want to produce
00:00:45HTML output from our Json document using
00:00:48the xslt in the transformation
00:00:51process for a bit of an explanation of
00:00:54our sample xslt file note that we have a
00:00:57template that matches the whole map of
00:00:58weather data then we flatten it as an
00:01:01array and it iterates through the
00:01:03weather data and then we retrieve the
00:01:05data to use
00:01:07locally so we'll go back to the Json
00:01:09document and we'll click the configure
00:01:12transformation scenarios button we'll
00:01:14choose to create a new transformation
00:01:16and we'll select Json transformation
00:01:18with
00:01:20xslt in the XSL URL field we need to
00:01:23specify the path to our xslt file then
00:01:26we'll go to the output Tab and for the
00:01:29save as field
00:01:30click the variables button and we'll
00:01:32choose the current file name
00:01:34variable and give it the HTML file
00:01:38extension we'll select the open and
00:01:40browser system application option and
00:01:42deselect the XML since we want HTML
00:01:45output and after clicking okay we'll
00:01:48apply the transformation
00:01:50scenario and you can see that it
00:01:52generated our output in HTML
00:01:55format you can also batch transfer
00:01:58multiple documents
00:02:00so we'll select three Json files in the
00:02:03project view rightclick go to the
00:02:05transform submenu and select configure
00:02:08transformation scenario then we need to
00:02:11select our scenario we
00:02:13created and apply it and you can see
00:02:16that it generated our output in HTML
00:02:19format for all three files we
00:02:22selected for the next example we'll use
00:02:25this xquery file and for this example we
00:02:29want to produce XML output from our Json
00:02:31document using the xquery file in the
00:02:33transformation
00:02:35process for an explanation of our xquery
00:02:38file we store the weather data from the
00:02:40map in a variable then we flatten it as
00:02:43an array and it iterates through the
00:02:45weather data and then we use the data
00:02:47from the variable for our
00:02:51query so we'll go back to the Json
00:02:54document click the configure
00:02:56transformation scenario
00:02:57button we'll deselect the previous
00:03:00scenario and create a new one and this
00:03:03time we'll choose Json transformation
00:03:05with
00:03:06xquery in the xquery URL field we need
00:03:09to specify the path to our xquery file
00:03:13switching to the output tab you see that
00:03:14for this type of transformation there's
00:03:16a present a sequence option that will
00:03:18produce the output in a sequential mode
00:03:21we'll click
00:03:23okay and apply the
00:03:25transformation and in this case it
00:03:27produced XML output in the results and
00:03:30presented the weather data
00:03:33sequentially the xquery transformation
00:03:35can also be done in
00:03:38bulk so we'll select three Json
00:03:42files
00:03:44rightclick go to
00:03:46transform select configure
00:03:47transformation
00:03:49scenario and select the scenario we
00:03:53created and apply
00:03:55it and you can see that it produced XML
00:03:58output in the results Paine with a tab
00:04:00for each file we
00:04:05transformed now we'll show some similar
00:04:08examples using a Jason array document
00:04:11and this is the xslt
00:04:13file and for this example we want to
00:04:16produce HTML output from our Json array
00:04:19using the xslt and the
00:04:21transformation so we'll go back to the
00:04:23Json array document click the configure
00:04:25transformation scenario button click new
00:04:30and we'll select Json transformation
00:04:31with
00:04:33xslt in the XSL URL field we'll specify
00:04:36the path to our xslt
00:04:39file then we'll go to the output
00:04:43Tab and click the variables button for
00:04:45the save as field and we'll choose the
00:04:48current file name variable and give it
00:04:51the HTML file
00:04:53extension we'll select the open and
00:04:55browser system application option and
00:04:57deselect XML and after clicking okay
00:05:01we'll apply the transformation
00:05:04scenario and again you see that it
00:05:06generated our output in HTML
00:05:09format Json array documents can also be
00:05:12batch transformed so we'll select three
00:05:14Json array files right click go to
00:05:18transform select configure
00:05:20transformation
00:05:22scenario select the scenario we created
00:05:25and apply
00:05:26it and it generated our output in H HTML
00:05:30format for all three files we
00:05:33selected for the next example we'll use
00:05:35this xquery file and we want to produce
00:05:39XML output from our Jason array using
00:05:41the xquery file in the
00:05:45transformation so we'll go back to the
00:05:47Json array document click configure
00:05:49transformation scenario we'll deselect
00:05:52the previous
00:05:53scenario create a new one and this time
00:05:57we'll choose Json transformation with
00:05:58xquery
00:06:00in the xquery URL field we'll specify
00:06:02the path to our xquery file click okay
00:06:06and apply the
00:06:08transformation and it generated XML
00:06:10output in the results
00:06:12Pane and again this type of
00:06:14transformation can also be done in bulk
00:06:17so we'll select three Json array files
00:06:20rightclick go to
00:06:22transform select configure
00:06:24transformation
00:06:26scenario select the scenario we created
00:06:30and apply it and again it produced the
00:06:33XML output in the results pane with a
00:06:36tab for each file we
00:06:41transformed you can also transform the
00:06:43current Jason document using the X paath
00:06:46xquery Builder view we'll click the
00:06:49engine drop down to show you that there
00:06:50are three additions of the Saxon xquery
00:06:53Json
00:06:54engine we'll select one and click the
00:06:58play button
00:07:00and it generated XML output in the
00:07:02results
00:07:03pane that concludes the demonstration
00:07:06about transforming Jason content thank
00:07:08you for watching for more technical
00:07:10details see the transforming and
00:07:12querying Json document section in our
00:07:14user manual that link is included in the
00:07:17description of the video

Use Oxygen Feedback to ask us anything about this video.