A few of the newer extension commands use statjson and work with json instead of xml. I don't know of plans to extend this, but I am not in on the planning process. Maybe someone else can comment.
JSON output from OMS would be really useful. There are Python libraries such as xmljson and ElementTree that could be useful here.. (STATS PACKAGE INSTALL PYTHON=xmljson.) You probably know about those already.
------------------------------
Jon Peck
------------------------------
Original Message:
Sent: Thu November 30, 2023 11:02 AM
From: Soren V. Raben
Subject: XML custom table to output window
Thanks Jon.
This special formatting mostly deals with relocating some values from columns to rows, deleting certain columns and - most importantly - merging proportional comparison test into one table (`CTABLES` syntax does not offer satisfying results, not to mention that when results of comparison are automatically merged they are different than divided into two separate custom tables!).
I've just found statjson.py module in util folder (in site-packages) and I find it to may be possibly useful. Are there any examples how to use this API? In general, StatJSON and `OUTPUT CREATE` documentation lacks of good, various examples. If I'm wrong - where should I look for them?
Last but not least - do SPSS developers plan to implement (via `OMS` or `OUTPUT EXPORT`) feature to convert output elements to JSON? On the other hand, a Python module for extraction/conversion from XML would do a great job (I hope).
Original Message:
Sent: Thu November 30, 2023 09:53 AM
From: Jon Peck
Subject: XML custom table to output window
There is no direct way to create or replace a table using XML You can retrieve the XML representation from the Viewer or via OMS, but you would have to use the general pivot table apis to modify the table.
If you can explain more about what you are trying to produce, there might be an alternative way to do it.
You can set charts via the chart xml apis, but those do not deal with pivot tables.
--
Original Message:
Sent: 11/30/2023 9:28:00 AM
From: Soren V. Raben
Subject: XML custom table to output window
I have a set of tables where each table has to be formatted individually. I'm writing a Python script. I've managed to extract XML chart for each table however, I can't find a way to insert formatted XML to output window. Is there any solution? I'm aware of `OUTPUT CREATE` command but it requires JSON which schema is not compatible with XML chart (meaning, when I use `xmltodict` Python external library, I can't simply put this dictionary (hence JSON) into `OUTPUT CREATE`). So, alternatively, is there any way to extract JSON directly from output window (using OMS or `OUTPUT EXPORT`) - OR - any tool to convert easily this XML chart/Python dictionary extracted from XML to StatJSON 2.0 schema?