Test effect of validation on xs:ID and xs:IDREF attributes
authorMichael Kay <mike@saxonica.com>
Wed, 17 Jun 2015 23:48:00 +0100
changeset 988 f87c2cc8d879
parent 987 55bdb4168724
child 989 4f9cdb59e50e
Test effect of validation on xs:ID and xs:IDREF attributes
tests/insn/copy/_copy-test-set.xml
tests/insn/copy/copy-5001.xsl
--- a/tests/insn/copy/_copy-test-set.xml	Fri Jun 12 13:00:48 2015 +0100
+++ b/tests/insn/copy/_copy-test-set.xml	Wed Jun 17 23:48:00 2015 +0100
@@ -230,6 +230,10 @@
    <environment name="copy-48">
       <source role="." file="copy-48.xml"/>
    </environment>
+   
+   <environment name="copy-50">
+      <stylesheet file="copy-5001.xsl"/>
+   </environment>
 
 
    <test-case name="copy-0101">
@@ -2056,6 +2060,262 @@
          </all-of>
       </result>
    </test-case>
+   
+   <test-case name="copy-5001">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-001"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<data><thing id="p1" parts="q1 q2 q3"/><thing id="q1" parts="r1 r2"/><thing id="q2"/><thing id="q3"/><thing id="r1"/><thing id="r2"/></data>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5002">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-002"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<data><thing id="p1" parts="q1 q2 q3"/><thing id="q1" parts="r1 r2"/><thing id="q2"/><thing id="q3"/><thing id="r1"/><thing id="r2"/></data>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5003">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-003"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<data><thing id="p1" parts="q1 q2 q3"/><thing id="q1" parts="r1 r2"/><thing id="q2"/><thing id="q3"/><thing id="r1"/><thing id="r2"/></data>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5004">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-004"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<data><thing id="p1" parts="q1 q2 q3"/><thing id="q1" parts="r1 r2"/><thing id="q2"/><thing id="q3"/><thing id="r1"/><thing id="r2"/></data>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5011">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-011"/>
+      </test>
+      <result>
+         <error code="XTTE1555"/>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5012">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-012"/>
+      </test>
+      <result>
+         <error code="XTTE1555"/>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5013">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-013"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<data><thing id="p1" parts="q1 q2 q3"/><thing id="q1" parts="r1 r2"/><thing id="q2"/><thing id="q3"/><thing id="r1"/><thing id="r2"/><thing id="q2"/></data>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5014">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-014"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<data><thing id="p1" parts="q1 q2 q3"/><thing id="q1" parts="r1 r2"/><thing id="q2"/><thing id="q3"/><thing id="r1"/><thing id="r2"/><thing id="q2"/></data>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5021">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-021"/>
+      </test>
+      <result>
+         <error code="XTTE1555"/>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5022">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-022"/>
+      </test>
+      <result>
+         <error code="XTTE1555"/>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5023">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-023"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<data><thing id="p1" parts="q1 q2 q3"/><thing id="q1" parts="r1 r2"/><thing id="q2" parts="s1"/><thing id="q3"/><thing id="r1"/><thing id="r2"/></data>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5024">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-024"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<data><thing id="p1" parts="q1 q2 q3"/><thing id="q1" parts="r1 r2"/><thing id="q2" parts="s1"/><thing id="q3"/><thing id="r1"/><thing id="r2"/></data>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5031">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-031"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a>1</a><b>1</b></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5032">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-032"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a>1</a><b>1</b></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5033">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-033"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a>1</a><b>1</b></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="copy-5034">
+      <description>xsl:copy-of handling of xs:ID and xs:IDREF under validation</description>
+      <created by="Michael Kay" on="2015-06-17"/>
+      <environment ref="copy-50"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+         <feature value="schema_aware"/>
+      </dependencies>
+      <test>
+         <initial-template name="c-034"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a>1</a><b>1</b></out>]]></assert-xml>
+      </result>
+   </test-case>
 
 
 </test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/copy/copy-5001.xsl	Wed Jun 17 23:48:00 2015 +0100
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
+    
+    <!-- Test effect of validation on ID and IDREFS attributes -->
+    
+    <xsl:output method="xml" indent="no"/>
+
+    <xsl:import-schema>
+        <xs:schema>
+            <xs:element name="data">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element ref="thing" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="thing">
+                <xs:complexType>
+                    <xs:attribute name="id" type="xs:ID"/>
+                    <xs:attribute name="parts" type="xs:IDREFS"/>
+                </xs:complexType>
+            </xs:element>
+        </xs:schema>
+    </xsl:import-schema>
+    
+    <xsl:variable name="data">
+        <data>
+            <thing id="p1" parts="q1 q2 q3"/>
+            <thing id="q1" parts="r1 r2"/>
+            <thing id="q2"/>
+            <thing id="q3"/>
+            <thing id="r1"/>
+            <thing id="r2"/>
+        </data>
+    </xsl:variable>
+    
+    <xsl:variable name="bad-data-1">
+        <data>
+            <thing id="p1" parts="q1 q2 q3"/>
+            <thing id="q1" parts="r1 r2"/>
+            <thing id="q2"/>
+            <thing id="q3"/>
+            <thing id="r1"/>
+            <thing id="r2"/>
+            <thing id="q2"/> <!-- duplicate -->
+        </data>
+    </xsl:variable>
+    
+    <xsl:variable name="bad-data-2">
+        <data>
+            <thing id="p1" parts="q1 q2 q3"/>
+            <thing id="q1" parts="r1 r2"/>
+            <thing id="q2" parts="s1"/> <!-- dangling -->
+            <thing id="q3"/>
+            <thing id="r1"/>
+            <thing id="r2"/>
+        </data>
+    </xsl:variable>
+    
+    <xsl:template name="c-001">
+        <xsl:copy-of select="$data" validation="strict"/>
+    </xsl:template>
+    
+    <xsl:template name="c-002">
+        <xsl:copy-of select="$data" validation="lax"/>
+    </xsl:template>
+    
+    <xsl:template name="c-003">
+        <xsl:copy-of select="$data" validation="preserve"/>
+    </xsl:template>
+    
+    <xsl:template name="c-004">
+        <xsl:copy-of select="$data" validation="strip"/>
+    </xsl:template>
+    
+    <xsl:template name="c-011">
+        <xsl:copy-of select="$bad-data-1" validation="strict"/>
+    </xsl:template>
+    
+    <xsl:template name="c-012">
+        <xsl:copy-of select="$bad-data-1" validation="lax"/>
+    </xsl:template>
+    
+    <xsl:template name="c-013">
+        <xsl:copy-of select="$bad-data-1" validation="preserve"/>
+    </xsl:template>
+    
+    <xsl:template name="c-014">
+        <xsl:copy-of select="$bad-data-1" validation="strip"/>
+    </xsl:template>
+    
+    <xsl:template name="c-021">
+        <xsl:copy-of select="$bad-data-2" validation="strict"/>
+    </xsl:template>
+    
+    <xsl:template name="c-022">
+        <xsl:copy-of select="$bad-data-2" validation="lax"/>
+    </xsl:template>
+    
+    <xsl:template name="c-023">
+        <xsl:copy-of select="$bad-data-2" validation="preserve"/>
+    </xsl:template>
+    
+    <xsl:template name="c-024">
+        <xsl:copy-of select="$bad-data-2" validation="strip"/>
+    </xsl:template>
+    
+    <xsl:variable name="valid-data">
+        <xsl:copy-of select="$data" validation="strict"/>
+    </xsl:variable>
+    
+    <xsl:template name="c-031">
+        <xsl:variable name="v">
+            <xsl:copy-of select="$valid-data" validation="strict"/>
+        </xsl:variable>
+        <out>
+            <a><xsl:value-of select="count(id('p1', $v))"/></a>
+            <b><xsl:value-of select="count(idref('r1', $v))"/></b>
+        </out>
+    </xsl:template>
+    
+    <xsl:template name="c-032">
+        <xsl:variable name="v">
+            <xsl:copy-of select="$valid-data" validation="lax"/>
+        </xsl:variable>
+        <out>
+            <a><xsl:value-of select="count(id('p1', $v))"/></a>
+            <b><xsl:value-of select="count(idref('r1', $v))"/></b>
+        </out>
+    </xsl:template>
+    
+    <xsl:template name="c-033">
+        <xsl:variable name="v">
+            <xsl:copy-of select="$valid-data" validation="preserve"/>
+        </xsl:variable>
+        <out>
+            <a><xsl:value-of select="count(id('p1', $v))"/></a>
+            <b><xsl:value-of select="count(idref('r1', $v))"/></b>
+        </out>
+    </xsl:template>
+    
+    <xsl:template name="c-034">
+        <xsl:variable name="v">
+            <xsl:copy-of select="$valid-data" validation="strip"/>
+        </xsl:variable>
+        <out>
+            <a><xsl:value-of select="count(id('p1', $v))"/></a>
+            <b><xsl:value-of select="count(idref('r1', $v))"/></b>
+        </out>
+    </xsl:template>
+    
+
+</xsl:stylesheet>