Utilizing JavaScript for this task is significantly more convenient compared to relying solely on XSLT. This is mainly due to the fact that the final grammar does not adhere to XML standards, and there is a slim chance that you are manipulating anything beyond basic syntax.
If all you are doing is manipulating syntax without touching the actual data, then it can be classified as a syntax-only translation. XSLT was not originally intended for this purpose. Since all XML technologies share a standard syntax, translating syntax is not a major concern when converting data from one XML format to another. Moreover, this task is relatively straightforward.
What you will require are the following components: a string literal representing your JavaScript code, an array or object literal index preceding the data element, fetching the data element using innerHTML of the document.getElementsByTagName array, and finally incorporating a bit of JavaScript to complete the code for the array or object literal index. You can iterate through each XML element using a loop and construct a string literal that mirrors the required JavaScript code to build each index of your JSON object. Once you have completed this step, append the necessary starting and ending components to the dynamically generated code to finalize the syntax. This process should be completed swiftly.