title: JSON to XML with XSLT 3.0 using saxon
body: <p>I'm using XSLT 3.0 to transform this document <a href="http://docs.oasis-open.org/ubl/UBL-2.1-JSON/v1.0/cnd02/json/UBL-Invoice-2.1-Example-Trivial.json" rel="nofollow noreferrer">JSON</a> to this document <a href="https://docs.oasis-open.org/ubl/prd4-UBL-2.1/xml/UBL-Invoice-2.1-Example-Trivial.xml" rel="nofollow noreferrer">XML</a> with the function json-to-xml, </p>
  
  <pre><code>&lt;xsl:variable name="input-as-xml" select="json-to-xml(.)"/&gt;
  </code></pre>
  
  <p>From saxon I pass this json like document XML:</p>
  
  <pre><code>String XML = "&lt;root&gt;" + JSON + "&lt;/root&gt;";
  </code></pre>
  
  <p>I get an XML when call the function json-to-xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;map
      xmlns="http://www.w3.org/2005/xpath-functions"&gt;
      &lt;string key="_D"&gt;urn:oasis:names:specification:ubl:schema:xsd:Invoice-2&lt;/string&gt;
      &lt;string key="_S"&gt;urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2&lt;/string&gt;
      &lt;string key="_B"&gt;urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2&lt;/string&gt;
      &lt;array key="Invoice"&gt;
          &lt;map&gt;
              &lt;array key="ID"&gt;
                  &lt;map&gt;
                      &lt;string key="IdentifierContent"&gt;123&lt;/string&gt;
                  &lt;/map&gt;
              &lt;/array&gt;
              &lt;array key="IssueDate"&gt;
                  &lt;map&gt;
                      &lt;string key="DateContent"&gt;2011-09-22&lt;/string&gt;
                  &lt;/map&gt;
              &lt;/array&gt;
              &lt;array key="InvoicePeriod"&gt;
                  &lt;map&gt;
                      &lt;array key="StartDate"&gt;
                          &lt;map&gt;
                              &lt;string key="DateContent"&gt;2011-08-01&lt;/string&gt;
                          &lt;/map&gt;
                      &lt;/array&gt;
                      &lt;array key="EndDate"&gt;
                          &lt;map&gt;
                              &lt;string key="DateContent"&gt;2011-08-31&lt;/string&gt;
                          &lt;/map&gt;
                      &lt;/array&gt;
                  &lt;/map&gt;
              &lt;/array&gt;
              &lt;array key="AccountingSupplierParty"&gt;
                  &lt;map&gt;
                      &lt;array key="Party"&gt;
                          &lt;map&gt;
                              &lt;array key="PartyName"&gt;
                                  &lt;map&gt;
                                      &lt;array key="Name"&gt;
                                          &lt;map&gt;
                                              &lt;string key="TextContent"&gt;Custom Cotter Pins&lt;/string&gt;
                                          &lt;/map&gt;
                                      &lt;/array&gt;
                                  &lt;/map&gt;
                              &lt;/array&gt;
                          &lt;/map&gt;
                      &lt;/array&gt;
                  &lt;/map&gt;
              &lt;/array&gt;
              &lt;array key="AccountingCustomerParty"&gt;
                  &lt;map&gt;
                      &lt;array key="Party"&gt;
                          &lt;map&gt;
                              &lt;array key="PartyName"&gt;
                                  &lt;map&gt;
                                      &lt;array key="Name"&gt;
                                          &lt;map&gt;
                                              &lt;string key="TextContent"&gt;North American Veeblefetzer&lt;/string&gt;
                                          &lt;/map&gt;
                                      &lt;/array&gt;
                                  &lt;/map&gt;
                              &lt;/array&gt;
                          &lt;/map&gt;
                      &lt;/array&gt;
                  &lt;/map&gt;
              &lt;/array&gt;
              &lt;array key="LegalMonetaryTotal"&gt;
                  &lt;map&gt;
                      &lt;array key="PayableAmount"&gt;
                          &lt;map&gt;
                              &lt;number key="AmountContent"&gt;100.00&lt;/number&gt;
                              &lt;string key="AmountCurrencyIdentifier"&gt;CAD&lt;/string&gt;
                          &lt;/map&gt;
                      &lt;/array&gt;
                  &lt;/map&gt;
              &lt;/array&gt;
              &lt;array key="InvoiceLine"&gt;
                  &lt;map&gt;
                      &lt;array key="ID"&gt;
                          &lt;map&gt;
                              &lt;string key="IdentifierContent"&gt;1&lt;/string&gt;
                          &lt;/map&gt;
                      &lt;/array&gt;
                      &lt;array key="LineExtensionAmount"&gt;
                          &lt;map&gt;
                              &lt;number key="AmountContent"&gt;100.00&lt;/number&gt;
                              &lt;string key="AmountCurrencyIdentifier"&gt;CAD&lt;/string&gt;
                          &lt;/map&gt;
                      &lt;/array&gt;
                      &lt;array key="Item"&gt;
                          &lt;map&gt;
                              &lt;array key="Description"&gt;
                                  &lt;map&gt;
                                      &lt;string key="TextContent"&gt;Cotter pin, MIL-SPEC&lt;/string&gt;
                                  &lt;/map&gt;
                              &lt;/array&gt;
                          &lt;/map&gt;
                      &lt;/array&gt;
                  &lt;/map&gt;
              &lt;/array&gt;
          &lt;/map&gt;
      &lt;/array&gt;
  &lt;/map&gt;
  </code></pre>
  
  <p>Is it correct pass this XML as parameter?</p>
  
  <pre><code>&lt;xsl:apply-templates select="$input-as-xml" /&gt;
  </code></pre>
  
  <p>Please, any suggestion in how can I use templates to transform the XML that I want? I just want some suggestions. </p>