This task is far easier accomplished using JavaScript instead of XSLT only because the ending grammar is not XML affiliated, and because it is unlikely you are transforming anything beyond mere syntax.
You are only transforming the syntax and nothing affiliated with the data then it is a syntax only translation. This is not what XSLT was designed for. Every XML technology shares a common syntax, so syntax translations are a non-issue when shaping data from one XML grammar to another. Additionally this is a simple task.
What you need is the following:
A string literal that represents your JS code of an array or object literal index prior to the data element, the data element using the innerHTML of the document.getElementsByTagName array, and then bit of JS to finish the array or object literal index code. Use a loop to go through each element from the XML and build it into a string literal that represents the necessary JS code to build each index of your JSON object. Then once complete stick the appropriate beginning and end on what is dynamically created to finish the syntax. This should be a very quick process.