Test xsl copy with combinations of copy-namespaces and inherit-namespaces
authorMichael Kay <mike@saxonica.com>
Wed, 13 Jun 2018 12:32:53 +0100
changeset 1851 9d1e4a5dd1e8
parent 1850 2d943e2bde09
child 1852 60fb2cad43a4
Test xsl copy with combinations of copy-namespaces and inherit-namespaces
tests/insn/copy/_copy-test-set.xml
tests/insn/copy/copy-0612.xsl
tests/insn/copy/copy-0616.xsl
tests/insn/copy/copy-0620.xsl
tests/insn/copy/copy-0624.xsl
--- a/tests/insn/copy/_copy-test-set.xml	Wed Jun 13 12:31:35 2018 +0100
+++ b/tests/insn/copy/_copy-test-set.xml	Wed Jun 13 12:32:53 2018 +0100
@@ -544,6 +544,390 @@
          <assert>//red[namespace::rose="http://www.rose.com"]</assert>
       </result>
    </test-case>
+   
+   <test-case name="copy-0612">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied document, using in-scope-prefixes)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0612.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'true'"/>
+         <param name="INHERIT" static="yes" select="'true'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='p'][@uri='uri:p'][@in-scope='|=uri:p|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='q'][@uri='uri:q'][@in-scope='|=uri:q|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|b=uri:b|d=uri:d|s=uri:s']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0613">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied document, using in-scope-prefixes)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0612.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'true'"/>
+         <param name="INHERIT" static="yes" select="'false'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='p'][@uri='uri:p'][@in-scope='|=uri:p']</assert>
+            <assert>/out/element[@name='q'][@uri='uri:q'][@in-scope='|=uri:q']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|s=uri:s']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0614">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied document, using in-scope-prefixes)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0612.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'false'"/>
+         <param name="INHERIT" static="yes" select="'true'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='p'][@uri='uri:p'][@in-scope='|=uri:p|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='q'][@uri='uri:q'][@in-scope='|=uri:q|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|b=uri:b|d=uri:d']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0615">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied document, using in-scope-prefixes)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0612.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'false'"/>
+         <param name="INHERIT" static="yes" select="'false'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='p'][@uri='uri:p'][@in-scope='|=uri:p']</assert>
+            <assert>/out/element[@name='q'][@uri='uri:q'][@in-scope='|=uri:q']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0616">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied document, using namespace axis)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0616.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'true'"/>
+         <param name="INHERIT" static="yes" select="'true'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='p'][@uri='uri:p'][@in-scope='|=uri:p|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='q'][@uri='uri:q'][@in-scope='|=uri:q|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|b=uri:b|d=uri:d|s=uri:s']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0617">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied document, using namespace axis)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0616.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'true'"/>
+         <param name="INHERIT" static="yes" select="'false'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='p'][@uri='uri:p'][@in-scope='|=uri:p']</assert>
+            <assert>/out/element[@name='q'][@uri='uri:q'][@in-scope='|=uri:q']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|s=uri:s']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0618">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied document, using namespace axis)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0616.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'false'"/>
+         <param name="INHERIT" static="yes" select="'true'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='p'][@uri='uri:p'][@in-scope='|=uri:p|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='q'][@uri='uri:q'][@in-scope='|=uri:q|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|b=uri:b|d=uri:d']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0619">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied document, using namespace axis)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0616.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'false'"/>
+         <param name="INHERIT" static="yes" select="'false'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='p'][@uri='uri:p'][@in-scope='|=uri:p']</assert>
+            <assert>/out/element[@name='q'][@uri='uri:q'][@in-scope='|=uri:q']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0620">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied element, using in-scope-prefixes)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0620.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'true'"/>
+         <param name="INHERIT" static="yes" select="'true'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|b=uri:b|d=uri:d|s=uri:s']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0621">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied element, using in-scope-prefixes)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0620.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'true'"/>
+         <param name="INHERIT" static="yes" select="'false'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|s=uri:s']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0622">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied element, using in-scope-prefixes)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0620.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'false'"/>
+         <param name="INHERIT" static="yes" select="'true'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|b=uri:b|d=uri:d']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0623">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied element, using in-scope-prefixes)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0620.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'false'"/>
+         <param name="INHERIT" static="yes" select="'false'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0624">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied element, using namespace axis)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0624.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'true'"/>
+         <param name="INHERIT" static="yes" select="'true'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|b=uri:b|d=uri:d|s=uri:s']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0625">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied element, using namespace axis)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0624.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'true'"/>
+         <param name="INHERIT" static="yes" select="'false'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|s=uri:s']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0626">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied element, using namespace axis)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0624.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'false'"/>
+         <param name="INHERIT" static="yes" select="'true'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r|b=uri:b|d=uri:d']</assert>
+         </all-of>        
+      </result>
+   </test-case>
+   
+   <test-case name="copy-0627">
+      <description>test combinations of inherit=yes|no and copy-namespaces=yes|no (copied element, using namespace axis)</description>
+      <created by="Michael Kay" on="2018-05-17"/>
+      <environment ref="copy-06"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-0624.xsl"/>
+         <initial-template name="main"/>
+         <param name="COPY" static="yes" select="'false'"/>
+         <param name="INHERIT" static="yes" select="'false'"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/element[@name='a'][@uri='uri:a'][@in-scope='|=uri:a']</assert>
+            <assert>/out/element[@name='b'][@uri='uri:b'][@in-scope='|=uri:a|b=uri:b']</assert>
+            <assert>/out/element[@name='c'][@uri='uri:c'][@in-scope='|=uri:c|b=uri:b|d=uri:d']</assert>
+            <assert>/out/element[@name='r'][@uri='uri:r'][@in-scope='|=uri:r']</assert>
+         </all-of>        
+      </result>
+   </test-case>
 
    <test-case name="copy-0701">
       <description> Test for copy-of with '*' wildcard pattern. This test also checks handling of
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/copy/copy-0612.xsl	Wed Jun 13 12:32:53 2018 +0100
@@ -0,0 +1,64 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:f="http://local-functions/"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="f xs">
+
+    <!-- test combinations of copy-namespaces and inherit-namespaces -->
+    
+    <xsl:param name="INHERIT" static="yes" select="true()"/>
+    <xsl:param name="COPY" static="yes" select="true()"/>
+    
+    <xsl:variable name="outer">
+        <a xmlns="uri:a">
+            <b:b xmlns:b="uri:b">
+                <c xmlns="uri:c" xmlns:d="uri:d">
+                    <graft xmlns=""/>
+                </c>
+            </b:b>
+        </a>
+    </xsl:variable>
+    
+    <xsl:variable name="inner">
+        <p xmlns="uri:p">
+            <q xmlns="uri:q">
+                <r xmlns="uri:r" xmlns:s="uri:s"/>
+            </q>
+        </p>
+    </xsl:variable>
+    
+    <xsl:mode on-no-match="shallow-copy"/>
+    
+    <xsl:template match="*">
+        <xsl:copy _inherit-namespaces="{$INHERIT}">
+            <xsl:apply-templates/>
+        </xsl:copy>
+    </xsl:template>
+    
+    <xsl:template match="graft">
+        <xsl:copy-of select="$inner" _copy-namespaces="{$COPY}"/>
+    </xsl:template>
+
+    <xsl:output method="xml" encoding="utf-8"/>
+    <xsl:template name="main">
+        <xsl:variable name="capture">
+            <xsl:apply-templates select="$outer"/>
+        </xsl:variable>
+        <out>
+            <xsl:for-each select="$capture//*">
+                <element name="{local-name()}" uri="{namespace-uri()}" in-scope="{f:in-scope-namespaces(.)}"/>
+            </xsl:for-each>
+        </out>
+    </xsl:template>
+
+    <xsl:function name="f:in-scope-namespaces" as="xs:string">
+        <xsl:param name="e" as="element(*)"/>
+        <xsl:value-of>
+            <xsl:for-each select="in-scope-prefixes($e)[. != 'xml']">
+                <xsl:sort select="."/>
+                <xsl:value-of select="concat('|', ., '=', namespace-uri-for-prefix(., $e))"/>
+            </xsl:for-each> 
+        </xsl:value-of>       
+    </xsl:function>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/copy/copy-0616.xsl	Wed Jun 13 12:32:53 2018 +0100
@@ -0,0 +1,23 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:f="http://local-functions/"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="f xs">
+
+    <!-- test combinations of copy-namespaces and inherit-namespaces -->
+    <!-- same as copy-0612, but using the namespace axis rather than in-scope-prefixes -->
+    
+    <xsl:import href="copy-0612.xsl"/>
+    
+    <xsl:function name="f:in-scope-namespaces" as="xs:string">
+        <xsl:param name="e" as="element(*)"/>
+        <xsl:value-of>
+            <xsl:for-each select="$e/namespace::*[name() != 'xml']">
+                <xsl:sort select="name()"/>
+                <xsl:variable name="ok" select="if (.. is $e) then '' else '(BAD!)'"/>
+                <xsl:value-of select="concat('|', name(), $ok, '=', string(.))"/>
+            </xsl:for-each> 
+        </xsl:value-of>       
+    </xsl:function>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/copy/copy-0620.xsl	Wed Jun 13 12:32:53 2018 +0100
@@ -0,0 +1,64 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:f="http://local-functions/"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="f xs">
+
+    <!-- test combinations of copy-namespaces and inherit-namespaces -->
+    
+    <xsl:param name="INHERIT" static="yes" select="true()"/>
+    <xsl:param name="COPY" static="yes" select="true()"/>
+    
+    <xsl:variable name="outer">
+        <a xmlns="uri:a">
+            <b:b xmlns:b="uri:b">
+                <c xmlns="uri:c" xmlns:d="uri:d">
+                    <graft xmlns=""/>
+                </c>
+            </b:b>
+        </a>
+    </xsl:variable>
+    
+    <xsl:variable name="inner">
+        <p xmlns="uri:p">
+            <q xmlns="uri:q">
+                <r xmlns="uri:r" xmlns:s="uri:s"/>
+            </q>
+        </p>
+    </xsl:variable>
+    
+    <xsl:mode on-no-match="shallow-copy"/>
+    
+    <xsl:template match="*">
+        <xsl:copy _inherit-namespaces="{$INHERIT}">
+            <xsl:apply-templates/>
+        </xsl:copy>
+    </xsl:template>
+    
+    <xsl:template match="graft">
+        <xsl:copy-of select="$inner//*:r" _copy-namespaces="{$COPY}"/>
+    </xsl:template>
+
+    <xsl:output method="xml" encoding="utf-8"/>
+    <xsl:template name="main">
+        <xsl:variable name="capture">
+            <xsl:apply-templates select="$outer"/>
+        </xsl:variable>
+        <out>
+            <xsl:for-each select="$capture//*">
+                <element name="{local-name()}" uri="{namespace-uri()}" in-scope="{f:in-scope-namespaces(.)}"/>
+            </xsl:for-each>
+        </out>
+    </xsl:template>
+
+    <xsl:function name="f:in-scope-namespaces" as="xs:string">
+        <xsl:param name="e" as="element(*)"/>
+        <xsl:value-of>
+            <xsl:for-each select="in-scope-prefixes($e)[. != 'xml']">
+                <xsl:sort select="."/>
+                <xsl:value-of select="concat('|', ., '=', namespace-uri-for-prefix(., $e))"/>
+            </xsl:for-each> 
+        </xsl:value-of>       
+    </xsl:function>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/copy/copy-0624.xsl	Wed Jun 13 12:32:53 2018 +0100
@@ -0,0 +1,23 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:f="http://local-functions/"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="f xs">
+
+    <!-- test combinations of copy-namespaces and inherit-namespaces -->
+    <!-- same as copy-0620, but using the namespace axis rather than in-scope-prefixes -->
+    
+    <xsl:import href="copy-0620.xsl"/>
+    
+    <xsl:function name="f:in-scope-namespaces" as="xs:string">
+        <xsl:param name="e" as="element(*)"/>
+        <xsl:value-of>
+            <xsl:for-each select="$e/namespace::*[name() != 'xml']">
+                <xsl:sort select="name()"/>
+                <xsl:variable name="ok" select="if (.. is $e) then '' else '(BAD!)'"/>
+                <xsl:value-of select="concat('|', name(), $ok, '=', string(.))"/>
+            </xsl:for-each> 
+        </xsl:value-of>       
+    </xsl:function>
+
+</xsl:stylesheet>