Reverting json-to-xml tests (they were partially deleted)
authorabraaksm
Wed, 08 Apr 2015 01:22:16 +0200
changeset 938 48070b20cd79
parent 937 d6e14de632e4
child 939 f0c29b5d9a9b
Reverting json-to-xml tests (they were partially deleted)
Rationale: the QT3 tests are likely going to include XP31 syntax, so we should keep at least
a minimal set of these functions around, unless XP31 becomes mandatory.
tests/fn/json-to-xml/data001.json
tests/fn/json-to-xml/data005.json
tests/fn/json-to-xml/escapeText.json
tests/fn/json-to-xml/json-to-xml-A.xsl
tests/fn/json-to-xml/json-to-xml-E.xsl
tests/fn/json-to-xml/json-to-xml-typed.xsl
tests/fn/json-to-xml/schema-for-json.xsd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/json-to-xml/data001.json	Wed Apr 08 01:22:16 2015 +0200
@@ -0,0 +1,22 @@
+{
+    "glossary": {
+        "title": "example glossary",
+		"GlossDiv": {
+            "title": "S",
+			"GlossList": {
+                "GlossEntry": {
+                    "ID": "SGML",
+					"SortAs": "SGML",
+					"GlossTerm": "Standard Generalized Markup Language",
+					"Acronym": "SGML",
+					"Abbrev": "ISO 8879:1986",
+					"GlossDef": {
+                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
+						"GlossSeeAlso": ["GML", "XML"]
+                    },
+					"GlossSee": "markup"
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/json-to-xml/data005.json	Wed Apr 08 01:22:16 2015 +0200
@@ -0,0 +1,27 @@
+{"menu": {
+    "header": "SVG Viewer",
+    "items": [
+        {"id": "Open"},
+        {"id": "OpenNew", "label": "Open New"},
+        null,
+        {"id": "ZoomIn", "label": "Zoom In"},
+        {"id": "ZoomOut", "label": "Zoom Out"},
+        {"id": "OriginalView", "label": "Original View"},
+        null,
+        {"id": "Quality"},
+        {"id": "Pause"},
+        {"id": "Mute"},
+        null,
+        {"id": "Find", "label": "Find..."},
+        {"id": "FindAgain", "label": "Find Again"},
+        {"id": "Copy"},
+        {"id": "CopyAgain", "label": "Copy Again"},
+        {"id": "CopySVG", "label": "Copy SVG"},
+        {"id": "ViewSVG", "label": "View SVG"},
+        {"id": "ViewSource", "label": "View Source"},
+        {"id": "SaveAs", "label": "Save As"},
+        null,
+        {"id": "Help"},
+        {"id": "About", "label": "About Adobe CVG Viewer..."}
+    ]
+}}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/json-to-xml/escapeText.json	Wed Apr 08 01:22:16 2015 +0200
@@ -0,0 +1,3 @@
+{
+    "key" : "Data with \" within it"
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/json-to-xml/json-to-xml-A.xsl	Wed Apr 08 01:22:16 2015 +0200
@@ -0,0 +1,298 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:j="http://www.w3.org/2013/XSL/json">
+    <xsl:param name="options.escape" select="map{'unescape':false()}"/>
+    <xsl:param name="options.validate" select="map{'validate':true()}"/>
+
+    <!--<xsl:param name="options.rfc" select="map{'spec':'RFC4627'}"/>
+    <xsl:param name="options.ecma" select="map{'spec':'ECMA-262'}"/>-->
+
+    <xsl:param name="s0.map" select="'{}'"/>
+    <xsl:param name="s0.array" select="'[]'"/>
+    <xsl:param name="s1.number" select="'[1]'"/>
+    <xsl:param name="s1.string" select="'[&#34;a&#34;]'"/>
+    <xsl:param name="s1.true" select="'[true]'"/>
+    <xsl:param name="s1.false" select="'[false]'"/>
+    <xsl:param name="s1.null" select="'[null]'"/>
+
+    <xsl:param name="s2" select="'{&#34;x&#34;:1, &#34;y&#34;:[1,2,3]}'"/>
+
+    <xsl:param name="escape.1" select="'[&#34;Data with \&#34; within it&#34;]'"/>
+    <xsl:param name="escape.2"
+        select="'{&#34;Key \&#34; with quote&#34;:&#34;Data with \&#34; within it&#34;}'"/>
+
+
+    <xsl:template name="json-to-xml-001">
+        <xsl:variable name="metadata">
+            <description>Empty object as document-node</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($s0.map) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>document-node()</assert-type>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-002">
+        <xsl:variable name="metadata">
+            <description>Empty object</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($s0.map) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>element(Q{http://www.w3.org/2013/XSL/json}map)</assert-type>
+                <assert>count($result/*) eq 0</assert>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-003">
+        <xsl:variable name="metadata">
+            <description>Empty array as document-node</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($s0.array) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>document-node()</assert-type>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-004">
+        <xsl:variable name="metadata">
+            <description>Empty array</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($s0.array) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>element(Q{http://www.w3.org/2013/XSL/json}array)</assert-type>
+                <assert>count($result/*) eq 0</assert>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-005">
+        <xsl:variable name="metadata">
+            <description>Array Number</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($s1.number) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>element(Q{http://www.w3.org/2013/XSL/json}array)</assert-type>
+                <assert>count($result/*) eq 1</assert>
+                <assert>$result/*[1] instance of element(j:number,xs:untyped)</assert>
+                <assert>xs:double($result/*[1]) eq 1</assert>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-006">
+        <xsl:variable name="metadata">
+            <description>Array String</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($s1.string) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>element(*)</assert-type>
+                <assert>count($result/*) eq 1</assert>
+                <assert>$result/*[1] instance of element(j:string,xs:untyped)</assert>
+                <assert>xs:string($result/*[1]) eq "a"</assert>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-007">
+        <xsl:variable name="metadata">
+            <description>Array True</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($s1.true) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>element(*)</assert-type>
+                <assert>count($result/*) eq 1</assert>
+                <assert>$result/*[1] instance of element(j:boolean,xs:untyped)</assert>
+                <assert>xs:boolean($result/*[1]) eq true()</assert>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-008">
+        <xsl:variable name="metadata">
+            <description>Array False</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($s1.false) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>element(*)</assert-type>
+                <assert>count($result/*) eq 1</assert>
+                <assert>$result/*[1] instance of element(j:boolean,xs:untyped)</assert>
+                <assert>xs:boolean($result/*[1]) eq false()</assert>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-009">
+        <xsl:variable name="metadata">
+            <description>Array Null</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($s1.null) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>element(*)</assert-type>
+                <assert>count($result/*) eq 1</assert>
+                <assert>$result/*[1] instance of element(j:null,xs:untyped)</assert>
+                <assert>empty($result/*[1]/(*|text()))</assert>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-010">
+        <xsl:variable name="metadata">
+            <description>Larger 2</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml(unparsed-text('data001.json')) "/>
+        <xsl:variable name="expected-results">
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert-type>element(*)</assert-type>
+                <assert>count($result/*) eq 1</assert>
+            </all-of>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-011">
+        <xsl:variable name="metadata">
+            <description>Larger 2</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml(unparsed-text('data005.json')) "/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-012">
+        <xsl:variable name="metadata">
+            <description>Larger 2</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml(unparsed-text('escapeText.json')) "/>
+    </xsl:template>
+
+    <!-- Escaping tests -->
+    <xsl:template name="json-to-xml-escape-001">
+        <xsl:variable name="metadata">
+            <description>Escaped quote string</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($escape.1)//j:string "/>
+        <xsl:variable name="expected-results">
+            <test> json-to-xml($escape.1)//j:string</test>
+            <result>
+                <all-of>
+                    <!--<assert-count>1</assert-count>
+                    <assert-type>element(Q{http://www.w3.org/2013/XSL/json}string)</assert-type>
+                    <assert-string-value>Data with " within it</assert-string-value>
+                    <any-of>
+                        <assert>empty($result/@escaped)</assert>
+                        <assert>$result/@escaped eq "false"</assert>
+                    </any-of>
+                    <any-of>
+                        <assert>empty($result/@escaped-key)</assert>
+                        <assert>$result/@escaped-key eq "false"</assert>
+                    </any-of>-->
+                </all-of>
+            </result>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-escape-002">
+        <xsl:variable name="metadata">
+            <description>Escaped quote and key string</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($escape.2)//j:string "/>
+        <xsl:variable name="expected-results">
+            <test> json-to-xml($escape.2)//j:string</test>
+            <result>
+                <all-of>
+                    <!--<assert-count>1</assert-count>
+                    <assert-type>element(Q{http://www.w3.org/2013/XSL/json}string)</assert-type>
+                    <assert-string-value>Data with " within it</assert-string-value>
+                    <assert>$result/@key eq 'Key " with quote'</assert>
+                    <any-of>
+                        <assert>empty($result/@escaped)</assert>
+                        <assert>$result/@escaped eq "false"</assert>
+                    </any-of>
+                    <any-of>
+                        <assert>empty($result/@escaped-key)</assert>
+                        <assert>$result/@escaped-key eq "false"</assert>
+                    </any-of>-->
+                </all-of>
+            </result>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-escape-003">
+        <xsl:variable name="metadata">
+            <description>Escaped quote string - remaining escaped</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($escape.1,$options.escape)//j:string "/>
+        <xsl:variable name="expected-results">
+            <test> json-to-xml($escape.1,$options.escape)//j:string</test>
+            <result>
+                <!-- <all-of>
+                    <assert-count>1</assert-count>
+                    <assert-type>element(Q{http://www.w3.org/2013/XSL/json}string)</assert-type>
+                    <assert-string-value>Data with \" within it</assert-string-value>
+                    <assert>$result/@escaped eq "true"</assert>
+                    <any-of>
+                        <assert>empty($result/@escaped-key)</assert>
+                        <assert>$result/@escaped-key eq "false"</assert>
+                    </any-of>
+                </all-of>-->
+            </result>
+        </xsl:variable>
+    </xsl:template>
+    <xsl:template name="json-to-xml-escape-004">
+        <xsl:variable name="metadata">
+            <description>Escaped quote string and key - remaining escaped</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:copy-of select=" json-to-xml($escape.2,$options.escape)//j:string "/>
+        <xsl:variable name="expected-results">
+            <test> json-to-xml($escape.2,$options.escape)//j:string</test>
+            <result>
+                <!--<all-of>
+                    <assert-count>1</assert-count>
+                    <assert-type>element(Q{http://www.w3.org/2013/XSL/json}string)</assert-type>
+                    <assert-string-value>Data with \" within it</assert-string-value>
+                    <assert>$result/@key eq 'Key \" with quote'</assert>
+                    <assert>$result/@escaped eq "true"</assert>
+                    <assert>$result/@escaped-key eq "true"</assert>
+                </all-of>-->
+            </result>
+        </xsl:variable>
+    </xsl:template>
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/json-to-xml/json-to-xml-E.xsl	Wed Apr 08 01:22:16 2015 +0200
@@ -0,0 +1,262 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:template name="json-to-xml-error-001">
+        <xsl:variable name="metadata">
+            <description>Empty string</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json" select="''"/>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-002">
+        <xsl:variable name="metadata">
+            <description>Unknown token</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">{error}</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-003">
+        <xsl:variable name="metadata">
+            <description>Unknown token</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">{terriblyWrong}</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-004">
+        <xsl:variable name="metadata">
+            <description>Extra token</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">{}"extra token"</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-005">
+        <xsl:variable name="metadata">
+            <description>Non-string key</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">{1:1}</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-006">
+        <xsl:variable name="metadata">
+            <description>Non-string key</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">{true:1}</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-007">
+        <xsl:variable name="metadata">
+            <description>Missing colon after key</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">{"key" 1}</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-008">
+        <xsl:variable name="metadata">
+            <description>Extra token after map value</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">{"key":1 2}</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-009">
+        <xsl:variable name="metadata">
+            <description>Extra token after array value</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["key",1 2]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-010">
+        <xsl:variable name="metadata">
+            <description>Leading + on number</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">[+1]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-011">
+        <xsl:variable name="metadata">
+            <description>Redundant leading 0 on number</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">[01]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-012">
+        <xsl:variable name="metadata">
+            <description>Hex number</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">[1234A]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-013">
+        <xsl:variable name="metadata">
+            <description>Trailing backslash</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["123\"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-014">
+        <xsl:variable name="metadata">
+            <description>Short unicode</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["123\u234"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-015">
+        <xsl:variable name="metadata">
+            <description>Unicode null</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String with \u0000 backspace"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-016">
+        <xsl:variable name="metadata">
+            <description>Trailing comma in object</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">{"key":123,}</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-017">
+        <xsl:variable name="metadata">
+            <description>Trailing comma in object - liberal spec</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <modified by="John Lumley" on="2014-07-22"
+                change="option 'spec':'liberal' altered to 'liberal':true()"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">{"key":123 ,}</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json,map{'liberal':true()})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-018">
+        <xsl:variable name="metadata">
+            <description>Trailing comma in array</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["key",123,]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json)"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-019">
+        <xsl:variable name="metadata">
+            <description>Trailing comma in array - liberal spec</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <modified by="John Lumley" on="2014-07-22"
+                change="option 'spec':'liberal' altered to 'liberal':true()"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["key",123,]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json,map{'liberal':true()})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-020">
+        <xsl:variable name="metadata">
+            <description>Liberal option error</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <modified by="John Lumley" on="2014-07-22" change="option 'spec' altered to 'liberal'"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json,map{'liberal':()})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-021">
+        <xsl:variable name="metadata">
+            <description>Liberal option error</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <modified by="John Lumley" on="2014-07-22" change="option 'spec' altered to 'liberal'"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json,map{'liberal':'some string'})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-022">
+        <xsl:variable name="metadata">
+            <description>Validate option error</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json, map{'validate':()})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-023">
+        <xsl:variable name="metadata">
+            <description>Validate option error</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json, map{'validate':(true(),true())})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-024">
+        <xsl:variable name="metadata">
+            <description>Validate option error</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json, map{'validate':'EMCA-262'})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-025">
+        <xsl:variable name="metadata">
+            <description>Unescape option error</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json, map{'unescape':()})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-026">
+        <xsl:variable name="metadata">
+            <description>Unescape option error</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json,map{'unescape':(true(),true())})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-027">
+        <xsl:variable name="metadata">
+            <description>Unescape option error</description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json, map{'unescape':'EMCA-262'})"/>
+    </xsl:template>
+    <xsl:template name="json-to-xml-error-028">
+        <xsl:variable name="metadata">
+            <description>Fallback option not function </description>
+            <created by="John Lumley" on="2013-10-01"/>
+            <modified by="Abel Braaksma" on="2014-10-21" change="':=' for maps is replaced by ':'" />
+            <environment ref="JSON-XML"/>
+        </xsl:variable>
+        <xsl:variable name="json">["String"]</xsl:variable>
+        <xsl:copy-of select="json-to-xml($json,map{'fallback':'dummy'})"/>
+    </xsl:template>
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/json-to-xml/json-to-xml-typed.xsl	Wed Apr 08 01:22:16 2015 +0200
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:j="http://www.w3.org/2013/XSL/json">
+
+    <!-- Tests for schema aware typing of nodes from json-to-xml()
+    Note that these *only* check type and little more -
+    the other non-typed tests should be employed for structure etc. 
+    -->
+    <xsl:param name="options.validate" select="map{'validate':true()}"/>
+
+    <xsl:param name="s0.map" select="'{}'"/>
+    <xsl:param name="s0.array" select="'[]'"/>
+    <xsl:param name="s1.number" select="'[1]'"/>
+    <xsl:param name="s1.string" select="'[&#34;a&#34;]'"/>
+    <xsl:param name="s1.true" select="'[true]'"/>
+    <xsl:param name="s1.false" select="'[false]'"/>
+    <xsl:param name="s1.null" select="'[null]'"/>
+
+
+    <!--<xsl:import-schema namespace="http://www.w3.org/2013/XSL/json"
+        schema-location="http://www.w3.org/TR/2013/WD-xslt-30-20131212/schema-for-json.xsd"/>-->
+    <xsl:import-schema namespace="http://www.w3.org/2013/XSL/json"
+        schema-location="schema-for-json.xsd"/>
+
+    <!-- Note that whilst it would be cleaner perhaps to do the type checking in the assertions
+        (though they are in another file :-( ) there appears to be no way for
+        schema association with *result* documents, as opposed to source, 
+        to be described in the XLST test schema 
+    
+    Consequently we do the tests here and transmit true/false to the harness, in a very inelegant manner.
+    
+    When invocation of a function within XSLT is permitted, there will have to be some modifications I suspect
+    -->
+    <xsl:template name="json-to-xml-typed-001">
+        <!-- <description>Basic map type</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="JSON-XML-typed"/>-->
+        <result>
+            <xsl:value-of
+                select=" json-to-xml($s0.map,$options.validate)/* instance of element(j:map,j:mapType) "
+            />
+        </result>
+    </xsl:template>
+    <xsl:template name="json-to-xml-typed-002">
+        <!-- <description>Basic array type</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="JSON-XML-typed"/>-->
+        <result>
+            <xsl:value-of
+                select=" json-to-xml($s0.array,$options.validate)/* instance of element(j:array,j:arrayType) "
+            />
+        </result>
+    </xsl:template>
+
+    <xsl:template name="json-to-xml-typed-003">
+        <!--<description>Array Number typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="JSON-XML-typed"/>-->
+        <result>
+            <xsl:value-of
+                select=" let $result := json-to-xml($s1.number,$options.validate)/* return
+            count($result) = 1 and
+            $result instance of element(j:array) and
+            $result/*[1] instance of element(j:number,j:numberType) and
+            xs:double($result/*[1]) eq 1.0"
+            />
+        </result>
+    </xsl:template>
+
+    <xsl:template name="json-to-xml-typed-004">
+        <!--<description>Array String typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="JSON-XML-typed"/>-->
+        <result>
+            <xsl:value-of
+                select=" let $result := json-to-xml($s1.string,$options.validate)/* return
+            count($result) = 1 and
+            $result instance of element(j:array) and
+            $result/*[1] instance of element(j:string,j:stringType) and
+            xs:string($result/*[1]) eq 'a'"
+            />
+        </result>
+    </xsl:template>
+    <xsl:template name="json-to-xml-typed-005">
+        <!--<description>Array True typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="JSON-XML-typed"/>-->
+        <result>
+            <xsl:value-of
+                select=" let $result := json-to-xml($s1.true,$options.validate)/* return
+            count($result) = 1 and
+            $result instance of element(j:array) and
+            $result/*[1] instance of element(j:boolean,xs:boolean) and
+            xs:boolean($result/*[1]) eq true()"
+            />
+        </result>
+    </xsl:template>
+    <xsl:template name="json-to-xml-typed-006">
+        <!--<description>Array False typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="JSON-XML-typed"/>-->
+        <result>
+            <xsl:value-of
+                select=" let $result := json-to-xml($s1.false,$options.validate)/* return
+            count($result) = 1 and
+            $result instance of element(j:array) and
+            $result/*[1] instance of element(j:boolean,xs:boolean) and
+            xs:boolean($result/*[1]) eq false()"
+            />
+        </result>
+    </xsl:template>
+    <xsl:template name="json-to-xml-typed-007">
+        <!--<description>Array Null typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="JSON-XML-typed"/>-->
+        <result>
+            <xsl:value-of
+                select=" let $result := json-to-xml($s1.null,$options.validate)/* return
+            count($result) = 1 and
+            $result instance of element(j:array) and
+            $result/*[1] instance of element(j:null,j:nullType) and
+            empty($result/*[1]/(*|text()))"
+            />
+        </result>
+    </xsl:template>
+
+
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/json-to-xml/schema-for-json.xsd	Wed Apr 08 01:22:16 2015 +0200
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    elementFormDefault="qualified"
+    targetNamespace="http://www.w3.org/2013/XSL/json"
+    xmlns:j="http://www.w3.org/2013/XSL/json">
+    
+    <!-- 
+     * This is a schema for the XML representation of JSON used as the target for the
+     * XSLT 3.0 function fn:json-to-xml()
+     *
+     * The schema is made available under the terms of the W3C software notice and license
+     * at http://www.w3.org/Consortium/Legal/copyright-software-19980720
+     *
+    -->
+    
+    <xs:element name="map" type="j:mapType">
+        <xs:unique name="unique-key">
+            <xs:selector xpath="*"/>
+            <xs:field xpath="@key"/>
+        </xs:unique>
+    </xs:element>
+    
+    <xs:element name="array" type="j:arrayType"/>
+    
+    <xs:element name="string" type="j:stringType"/>
+    
+    <xs:element name="number" type="j:numberType"/>
+    
+    <xs:element name="boolean" type="xs:boolean"/>
+    
+    <xs:element name="null" type="j:nullType"/>
+    
+    <xs:complexType name="nullType">
+        <xs:sequence/>
+    </xs:complexType>
+    
+    <xs:complexType name="stringType">
+        <xs:simpleContent>
+            <xs:extension base="xs:string">
+                <xs:attribute name="escaped" type="xs:boolean" use="optional" default="false"/>
+            </xs:extension>
+        </xs:simpleContent>
+    </xs:complexType>
+    
+    <xs:simpleType name="numberType">
+        <xs:restriction base="xs:double">
+            <!-- exclude positive and negative infinity, and NaN -->
+            <xs:minExclusive value="-INF"/>
+            <xs:maxExclusive value="INF"/>
+        </xs:restriction>
+    </xs:simpleType>
+    
+    <xs:complexType name="arrayType">
+        <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:element ref="j:map"/>
+            <xs:element ref="j:array"/>
+            <xs:element ref="j:string"/>
+            <xs:element ref="j:number"/>
+            <xs:element ref="j:boolean"/>
+            <xs:element ref="j:null"/>
+        </xs:choice>       
+    </xs:complexType>
+    
+    <xs:complexType name="mapType">
+        <xs:choice minOccurs="0" maxOccurs="unbounded">
+            <xs:element name="map">
+                <xs:complexType>
+                    <xs:complexContent>
+                        <xs:extension base="j:mapType">
+                            <xs:attribute name="key" type="xs:string"/>
+                        </xs:extension>
+                    </xs:complexContent>
+                </xs:complexType>
+                <xs:unique name="unique-key-2">
+                    <xs:selector xpath="*"/>
+                    <xs:field xpath="@key"/>
+                </xs:unique>
+            </xs:element>
+            <xs:element name="array">
+                <xs:complexType>
+                    <xs:complexContent>
+                        <xs:extension base="j:arrayType">
+                            <xs:attributeGroup ref="j:key-group"/>
+                        </xs:extension>
+                    </xs:complexContent>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="string">
+                <xs:complexType>
+                    <xs:simpleContent>
+                        <xs:extension base="j:stringType">
+                            <xs:attributeGroup ref="j:key-group"/>
+                        </xs:extension>
+                    </xs:simpleContent>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="number">
+                <xs:complexType>
+                    <xs:simpleContent>
+                        <xs:extension base="j:numberType">
+                            <xs:attributeGroup ref="j:key-group"/>
+                        </xs:extension>
+                    </xs:simpleContent>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="boolean">
+                <xs:complexType>
+                    <xs:simpleContent>
+                        <xs:extension base="xs:boolean">
+                            <xs:attributeGroup ref="j:key-group"/>
+                        </xs:extension>
+                    </xs:simpleContent>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="null">
+                <xs:complexType>
+                    <xs:attributeGroup ref="j:key-group"/>
+                </xs:complexType>
+            </xs:element>
+        </xs:choice>
+    </xs:complexType>
+    
+    <xs:attributeGroup name="key-group">
+        <xs:attribute name="key" type="xs:string"/>
+        <xs:attribute name="escaped-key" type="xs:boolean" use="optional" default="false"/>
+    </xs:attributeGroup>
+    
+</xs:schema>