Merge with default keywords
authorabraaksm
Mon, 28 Jul 2014 20:22:34 +0200
branchkeywords
changeset 577 a87ff3c77938
parent 576 fa70d338e709 (current diff)
parent 573 d5641052be1f (diff)
child 578 863de18cb057
Merge with default
--- a/tests/fn/json-to-xml/_json-to-xml-test-set.xml	Mon Jul 28 20:21:43 2014 +0200
+++ b/tests/fn/json-to-xml/_json-to-xml-test-set.xml	Mon Jul 28 20:22:34 2014 +0200
@@ -1,122 +1,157 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <test-set xmlns:xs="http://www.w3.org/2001/XMLSchema"
-    xmlns="http://www.w3.org/2012/10/xslt-test-catalog"
-    xmlns:j="http://www.w3.org/2013/XSL/json"
+    xmlns="http://www.w3.org/2012/10/xslt-test-catalog" xmlns:j="http://www.w3.org/2013/XSL/json"
     name="json-to-xml">
     <description>json-to-xml() function</description>
-    
-    <!-- NOTE: currently missing tests for string escaping -->
+
+    <!-- Tests for type validation required - these need some machanism for storing a schema -->
 
     <environment name="json-to-xml-A">
         <stylesheet file="json-to-xml-A.xsl"/>
     </environment>
-    
+
     <environment name="json-to-xml-E">
         <stylesheet file="json-to-xml-E.xsl"/>
     </environment>
 
+    <!-- It would be helpful to assert schema-awareness on the stylesheet in a shared environment
+    Sadly 'dependencies' aren't appropriate and just adding 'schema' doesn't mean the same thing -->
+    <environment name="json-to-xml-typed">
+        <namespace prefix="j" uri="http://www.w3.org/2013/XSL/json"/>
+        <!-- <schema uri="http://www.w3.org/2013/XSL/json" file="schema-for-json.xsd">
+            <description>JSON XML representation schema</description>
+            <created by="John Lumley" on="2013-10-03"/>
+        </schema>-->
+        <!--<stylesheet file="json-to-xml-typed.xsl"/>-->
+    </environment>
+    <!-- This separate environment decouples the possibility of a shared compiled stylesheet  -->
+    <environment name="json-to-xml-typed2">
+        <namespace prefix="j" uri="http://www.w3.org/2013/XSL/json"/>
+    </environment>
+
 
 
     <dependencies>
         <spec value="XSLT30+"/>
+        <!--<feature value="schema_aware"/>-->
     </dependencies>
-    
-    
+
+
     <test-case name="json-to-xml-001">
         <description>Empty object as document-node</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-001"/></test>
+        <test>
+            <initial-template name="json-to-xml-001"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:map xmlns:j="http://www.w3.org/2013/XSL/json"/>]]></assert-xml>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-002">
         <description>Empty object</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-002"/></test>
+        <test>
+            <initial-template name="json-to-xml-002"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:map xmlns:j="http://www.w3.org/2013/XSL/json"/>]]></assert-xml>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-003">
         <description>Empty array as document-node</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-003"/></test>
+        <test>
+            <initial-template name="json-to-xml-003"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:array xmlns:j="http://www.w3.org/2013/XSL/json"/>]]></assert-xml>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-004">
         <description>Empty array</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-004"/></test>
+        <test>
+            <initial-template name="json-to-xml-004"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:array xmlns:j="http://www.w3.org/2013/XSL/json"/>]]></assert-xml>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-005">
         <description>Array Number</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-005"/></test>
+        <test>
+            <initial-template name="json-to-xml-005"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:array xmlns:j="http://www.w3.org/2013/XSL/json"><j:number>1</j:number></j:array>]]></assert-xml>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-006">
         <description>Array String</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-006"/></test>
+        <test>
+            <initial-template name="json-to-xml-006"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:array xmlns:j="http://www.w3.org/2013/XSL/json"><j:string>a</j:string></j:array>]]></assert-xml>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-007">
         <description>Array True</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-007"/></test>
+        <test>
+            <initial-template name="json-to-xml-007"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:array xmlns:j="http://www.w3.org/2013/XSL/json"><j:boolean>true</j:boolean></j:array>]]></assert-xml>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-008">
         <description>Array False</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-008"/></test>
+        <test>
+            <initial-template name="json-to-xml-008"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:array xmlns:j="http://www.w3.org/2013/XSL/json"><j:boolean>false</j:boolean></j:array>]]></assert-xml>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-009">
         <description>Array Null</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-009"/></test>
+        <test>
+            <initial-template name="json-to-xml-009"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:array xmlns:j="http://www.w3.org/2013/XSL/json"><j:null/></j:array>]]></assert-xml>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-010">
         <description>Larger JSON input</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-010"/></test>
+        <test>
+            <initial-template name="json-to-xml-010"/>
+        </test>
         <result>
             <all-of>
                 <assert>/j:map/j:map[@key='glossary']/j:string[@key='title']</assert>
@@ -124,12 +159,14 @@
             </all-of>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-011">
         <description>Larger JSON input</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-011"/></test>
+        <test>
+            <initial-template name="json-to-xml-011"/>
+        </test>
         <result>
             <all-of>
                 <assert>/j:map/j:map[@key='menu']/j:string[@key='header'][.='SVG Viewer']</assert>
@@ -137,18 +174,240 @@
             </all-of>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-012">
         <description>Escaped text</description>
         <created by="John Lumley" on="2013-10-01"/>
         <environment ref="json-to-xml-A"/>
-        <test><initial-template name="json-to-xml-012"/></test>
+        <test>
+            <initial-template name="json-to-xml-012"/>
+        </test>
         <result>
             <assert-xml><![CDATA[<j:map xmlns:j="http://www.w3.org/2013/XSL/json"><j:string key="key">Data with " within it</j:string></j:map>]]></assert-xml>
         </result>
     </test-case>
-    
 
+    <!-- Escaping tests -->
+
+    <test-case name="json-to-xml-escape-001">
+        <description>Escaped quote string</description>
+        <created by="John Lumley" on="2013-10-01"/>
+        <environment ref="json-to-xml-A"/>
+        <test>
+            <initial-template name="json-to-xml-escape-001"/>
+        </test>
+        <result>
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert>* instance of element(Q{http://www.w3.org/2013/XSL/json}string)</assert>
+                <assert>. = 'Data with " within it'</assert>
+                <any-of>
+                    <assert>empty(*/@escaped)</assert>
+                    <assert>*/@escaped eq "false"</assert>
+                </any-of>
+                <any-of>
+                    <assert>empty(*/@escaped-key)</assert>
+                    <assert>*/@escaped-key eq "false"</assert>
+                </any-of>
+            </all-of>
+        </result>
+    </test-case>
+    <test-case name="json-to-xml-escape-002">
+        <description>Escaped quote and key string</description>
+        <created by="John Lumley" on="2013-10-01"/>
+        <environment ref="json-to-xml-A"/>
+        <test>
+            <initial-template name="json-to-xml-escape-002"/>
+        </test>
+        <result>
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert>* instance of element(Q{http://www.w3.org/2013/XSL/json}string)</assert>
+                <assert>. = 'Data with " within it'</assert>
+                <assert>*/@key eq 'Key " with quote'</assert>
+                <any-of>
+                    <assert>empty(*/@escaped)</assert>
+                    <assert>*/@escaped eq "false"</assert>
+                </any-of>
+                <any-of>
+                    <assert>empty(*/@escaped-key)</assert>
+                    <assert>*/@escaped-key eq "false"</assert>
+                </any-of>
+            </all-of>
+        </result>
+    </test-case>
+    <test-case name="json-to-xml-escape-003">
+        <description>Escaped quote string - remaining escaped</description>
+        <created by="John Lumley" on="2013-10-01"/>
+        <environment ref="json-to-xml-A"/>
+        <test>
+            <initial-template name="json-to-xml-escape-003"/>
+        </test>
+        <result>
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert>* instance of element(Q{http://www.w3.org/2013/XSL/json}string)</assert>
+                <assert>. = 'Data with \" within it'</assert>
+                <assert>*/@escaped eq "true"</assert>
+                <any-of>
+                    <assert>empty(*/@escaped-key)</assert>
+                    <assert>*/@escaped-key eq "false"</assert>
+                </any-of>
+            </all-of>
+        </result>
+    </test-case>
+    <test-case name="json-to-xml-escape-004">
+        <description>Escaped quote string and key - remaining escaped</description>
+        <created by="John Lumley" on="2013-10-01"/>
+        <environment ref="json-to-xml-A"/>
+        <test>
+            <initial-template name="json-to-xml-escape-004"/>
+        </test>
+        <result>
+            <all-of>
+                <assert-count>1</assert-count>
+                <assert>* instance of element(Q{http://www.w3.org/2013/XSL/json}string)</assert>
+                <assert>. = 'Data with \" within it'</assert>
+                <assert>*/@key eq 'Key \" with quote'</assert>
+                <assert>*/@escaped eq "true"</assert>
+                <assert>*/@escaped-key eq "true"</assert>
+            </all-of>
+        </result>
+    </test-case>
+
+    <!-- Validation tests: nodes are given type -->
+    <!-- Note that the type tests are actually carried out in the XSLT transforms,
+    as it doesn't appear possible to associate schemas with result documents in the XSLT test schema. -->
+
+
+
+    <test-case name="json-to-xml-typed-001">
+        <description>Basic type</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="json-to-xml-typed"/>
+        <dependencies>
+            <feature value="schema_aware"/>
+        </dependencies>
+        <test>
+            <stylesheet file="json-to-xml-typed.xsl"/>
+            <initial-template name="json-to-xml-typed-001"/>
+        </test>
+        <result>
+            <assert>xs:boolean(*) = true()</assert>
+        </result>
+    </test-case>
+    <test-case name="json-to-xml-typed-002">
+        <description>Basic parsing typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="json-to-xml-typed"/>
+        <dependencies>
+            <feature value="schema_aware"/>
+        </dependencies>
+        <test>
+            <stylesheet file="json-to-xml-typed.xsl"/>
+            <initial-template name="json-to-xml-typed-002"/>
+        </test>
+        <result>
+            <assert>xs:boolean(*) = true()</assert>
+        </result>
+    </test-case>
+    <test-case name="json-to-xml-typed-003">
+        <description>Array Number typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="json-to-xml-typed"/>
+        <dependencies>
+            <feature value="schema_aware"/>
+        </dependencies>
+        <test>
+            <stylesheet file="json-to-xml-typed.xsl"/>
+            <initial-template name="json-to-xml-typed-004"/>
+        </test>
+        <result>
+            <assert>xs:boolean(*) = true()</assert>
+        </result>
+    </test-case>
+    <test-case name="json-to-xml-typed-004">
+        <description>Array String typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="json-to-xml-typed"/>
+        <dependencies>
+            <feature value="schema_aware"/>
+        </dependencies>
+        <test>
+            <stylesheet file="json-to-xml-typed.xsl"/>
+            <initial-template name="json-to-xml-typed-004"/>
+        </test>
+        <result>
+            <assert>xs:boolean(*) = true()</assert>
+        </result>
+    </test-case>
+    <test-case name="json-to-xml-typed-005">
+        <description>Array True typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="json-to-xml-typed"/>
+        <dependencies>
+            <feature value="schema_aware"/>
+        </dependencies>
+        <test>
+            <stylesheet file="json-to-xml-typed.xsl"/>
+            <initial-template name="json-to-xml-typed-005"/>
+        </test>
+        <result>
+            <assert>xs:boolean(*) = true()</assert>
+        </result>
+    </test-case>
+    <test-case name="json-to-xml-typed-006">
+        <description>Array False typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="json-to-xml-typed"/>
+        <dependencies>
+            <feature value="schema_aware"/>
+        </dependencies>
+        <test>
+            <stylesheet file="json-to-xml-typed.xsl"/>
+            <initial-template name="json-to-xml-typed-006"/>
+        </test>
+        <result>
+            <assert>xs:boolean(*) = true()</assert>
+        </result>
+    </test-case>
+    <test-case name="json-to-xml-typed-007">
+        <description>Array Null typed</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="json-to-xml-typed"/>
+        <dependencies>
+            <feature value="schema_aware"/>
+        </dependencies>
+        <test>
+            <stylesheet file="json-to-xml-typed.xsl"/>
+            <initial-template name="json-to-xml-typed-007"/>
+        </test>
+        <result>
+            <assert>xs:boolean(*) = true()</assert>
+        </result>
+    </test-case>
+
+    <!-- This uses a different environment to ensure that
+        any compiled stylesheet (which may be set schema-aware) isn't reused -->
+    <test-case name="json-to-xml-typed-010">
+        <description>Error when requesting type annotation on a non-schema aware
+            processor</description>
+        <created by="John Lumley" on="2013-10-08"/>
+        <environment ref="json-to-xml-typed2"/>
+        <dependencies>
+            <feature value="schema_aware" satisfied="false"/>
+        </dependencies>
+        <test>
+            <stylesheet file="json-to-xml-typed.xsl"/>
+            <initial-template name="json-to-xml-typed-001"/>
+        </test>
+        <result>
+            <error code="XTDE3245"/>
+        </result>
+    </test-case>
+
+
+    <!-- Error tests -->
     <test-case name="json-to-xml-error-001">
         <description>Empty string</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -160,7 +419,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-002">
         <description>Unknown token</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -172,7 +431,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-003">
         <description>Unknown token</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -184,7 +443,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-004">
         <description>Extra token</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -196,7 +455,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-005">
         <description>Non-string key</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -208,7 +467,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-006">
         <description>Non-string key</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -220,7 +479,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-007">
         <description>Missing colon after key</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -232,7 +491,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-008">
         <description>Extra token after map value</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -244,7 +503,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-009">
         <description>Extra token after array value</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -256,7 +515,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-010">
         <description>Leading + on number</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -268,7 +527,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-011">
         <description>Redundant leading 0 on number</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -280,7 +539,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-012">
         <description>Hex number</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -292,7 +551,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-013">
         <description>Trailing backslash</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -304,7 +563,7 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-014">
         <description>Short unicode</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -316,19 +575,21 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-015">
         <description>Short unicode</description>
         <created by="John Lumley" on="2013-10-01"/>
+        <modified by="John Lumley" on="2014-07-22"
+            change="changed from XTDE3240 to correct error code"/>
         <environment ref="json-to-xml-E"/>
         <test>
             <initial-template name="json-to-xml-error-015"/>
         </test>
         <result>
-            <error code="XTDE3240"/>
+            <error code="XTDE3250"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-016">
         <description>Trailing comma in object</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -340,10 +601,12 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-017">
         <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-to-xml-E"/>
         <test>
             <initial-template name="json-to-xml-error-017"/>
@@ -355,7 +618,7 @@
             </any-of>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-018">
         <description>Trailing comma in array</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -367,10 +630,12 @@
             <error code="XTDE3240"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-019">
         <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-to-xml-E"/>
         <test>
             <initial-template name="json-to-xml-error-019"/>
@@ -382,10 +647,11 @@
             </any-of>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-020">
-        <description>Spec option error</description>
+        <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-to-xml-E"/>
         <test>
             <initial-template name="json-to-xml-error-020"/>
@@ -394,10 +660,11 @@
             <error code="XTDE3260"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-021">
-        <description>Spec option error</description>
+        <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-to-xml-E"/>
         <test>
             <initial-template name="json-to-xml-error-021"/>
@@ -406,7 +673,7 @@
             <error code="XTDE3260"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-022">
         <description>Validate option error</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -418,7 +685,7 @@
             <error code="XTDE3260"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-023">
         <description>Validate option error</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -430,7 +697,7 @@
             <error code="XTDE3260"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-024">
         <description>Validate option error</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -442,7 +709,7 @@
             <error code="XTDE3260"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-025">
         <description>Unescape option error</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -454,7 +721,7 @@
             <error code="XTDE3260"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-026">
         <description>Unescape option error</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -466,7 +733,7 @@
             <error code="XTDE3260"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-027">
         <description>Unescape option error</description>
         <created by="John Lumley" on="2013-10-01"/>
@@ -478,7 +745,7 @@
             <error code="XTDE3260"/>
         </result>
     </test-case>
-    
+
     <test-case name="json-to-xml-error-028">
         <description>Fallback option not function </description>
         <created by="John Lumley" on="2013-10-01"/>
--- a/tests/fn/json-to-xml/json-to-xml-A.xsl	Mon Jul 28 20:21:43 2014 +0200
+++ b/tests/fn/json-to-xml/json-to-xml-A.xsl	Mon Jul 28 20:22:34 2014 +0200
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<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="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]'"/>
@@ -13,14 +14,14 @@
     <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>
@@ -195,4 +196,103 @@
         </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>
--- a/tests/fn/json-to-xml/json-to-xml-E.xsl	Mon Jul 28 20:21:43 2014 +0200
+++ b/tests/fn/json-to-xml/json-to-xml-E.xsl	Mon Jul 28 20:22:34 2014 +0200
@@ -148,10 +148,12 @@
         <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{'spec':'liberal'})"/>
+        <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">
@@ -166,28 +168,32 @@
         <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{'spec':'liberal'})"/>
+        <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>Spec option error</description>
+            <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{'spec':()})"/>
+        <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>Spec option error</description>
+            <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{'spec':('EMCA-262','RFC4627')})"/>
+        <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">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/json-to-xml/json-to-xml-typed.xsl	Mon Jul 28 20:22:34 2014 +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	Mon Jul 28 20:22:34 2014 +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>