New XSD 1.1 validation test
authorMichael Kay <mike@saxonica.com>
Wed, 18 Feb 2015 11:39:21 +0000
changeset 821 e3eaf0110b9e
parent 820 4c027872f426
child 822 063bca1530c1
New XSD 1.1 validation test
tests/attr/validation/_validation-test-set.xml
tests/attr/validation/validation-1301.xsl
--- a/tests/attr/validation/_validation-test-set.xml	Wed Feb 04 23:46:55 2015 +0000
+++ b/tests/attr/validation/_validation-test-set.xml	Wed Feb 18 11:39:21 2015 +0000
@@ -820,6 +820,25 @@
          <assert-xml><![CDATA[<z xmlns:t="http://ns.example.com/val12/"><a>true</a><a>false</a></z>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="validation-1301">
+      <description>
+        Test validation="strict" on an LRE using XSD 1.1 conditional type assignment.
+        Saxon bug 2316.
+      </description>
+      <created by="Michael Kay" on="2015-02-18"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+         <feature value="XSD_1.1"/>
+      </dependencies>
+      <test>
+         <stylesheet file="validation-1301.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<list><element type="type2"><child1/><child2/></element></list>]]></assert-xml>
+      </result>
+   </test-case>
 
    <test-case name="validation-1401">
       <description>test use of a path expression containing an axis step referring to document-node(element(X))</description>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/validation/validation-1301.xsl	Wed Feb 18 11:39:21 2015 +0000
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
+   
+   <xsl:import-schema>
+       <xs:schema>
+           <xs:element name="list">
+               <xs:complexType>
+                   <xs:sequence>
+                       <xs:element ref="element" minOccurs="0" maxOccurs="unbounded"/>
+                   </xs:sequence>
+               </xs:complexType>
+           </xs:element>
+           
+           <xs:element name="element" type="type1">
+               <xs:alternative test="@type = 'type2'" type="type2"/>
+           </xs:element>
+           
+           <xs:complexType name="type1">
+               <xs:sequence>
+                   <xs:element name="child1"/>
+               </xs:sequence>
+               <xs:attribute name="type" type="xs:string"/>
+           </xs:complexType>
+           
+           <xs:complexType name="type2">
+               <xs:complexContent>
+                   <xs:extension base="type1">
+                       <xs:sequence>
+                           <xs:element name="child2"/>
+                       </xs:sequence>
+                   </xs:extension>
+               </xs:complexContent>
+           </xs:complexType>
+       </xs:schema>
+   </xsl:import-schema>
+   
+   <xsl:template match="/">
+       <list xsl:validation="strict"> <!-- strict validation here works -->
+           <element xsl:validation="strict"> <!-- strict validation here causes error -->
+               <xsl:attribute name="type" select="'type2'"/>
+               <child1/>
+               <child2/>
+           </element>
+       </list>
+   </xsl:template>
+   
+</xsl:transform> 
\ No newline at end of file