Add attribute test (selecting attributes in different namespaces)
authordlockett <debbie@saxonica.com>
Wed, 05 Jul 2017 15:26:05 +0100
changeset 1709 15726a30e906
parent 1708 23dd4fcab10b
child 1711 8edfbe533862
Add attribute test (selecting attributes in different namespaces)
tests/insn/attribute/_attribute-test-set.xml
tests/insn/attribute/attribute-0902.xsl
tests/insn/attribute/attribute-09b.xml
--- a/tests/insn/attribute/_attribute-test-set.xml	Mon Jul 03 11:10:05 2017 +0100
+++ b/tests/insn/attribute/_attribute-test-set.xml	Wed Jul 05 15:26:05 2017 +0100
@@ -53,6 +53,10 @@
    <environment name="attribute-09">
       <source role="." file="attribute-09.xml"/>
    </environment>
+   
+   <environment name="attribute-09b">
+      <source role="." file="attribute-09b.xml"/>
+   </environment>
 
    <environment name="attribute-11">
       <source role="." file="attribute-11.xml"/>
@@ -368,6 +372,21 @@
 </out>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="attribute-0902">
+      <description>Test for selecting attributes with namespace.</description>
+      <created by="Debbie Lockett" on="2017-07-05"/>
+      <environment ref="attribute-09b"/>
+      <dependencies>
+         <spec value="XSLT10+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="attribute-0902.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>true</out>]]></assert-xml>
+      </result>
+   </test-case>
 
    <test-case name="attribute-1101">
       <description>Verify that attributes that contain text nodes with a newline, the output must contain a character reference.</description>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/attribute/attribute-0902.xsl	Wed Jul 05 15:26:05 2017 +0100
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+  <!-- Purpose: Test for selecting attributes with namespace. -->
+  
+  <xsl:template match="/docs">
+    <xsl:variable name="union">
+      <xsl:for-each select="//@*[namespace-uri() eq 'http://www.ped.com'] | //@*[local-name() eq 'att1']">
+        <xsl:value-of select="."/>
+      </xsl:for-each>
+    </xsl:variable>
+    <xsl:variable name="or">
+      <xsl:for-each select="//@*[namespace-uri() eq 'http://www.ped.com' or local-name() eq 'att1']">
+        <xsl:value-of select="."/>
+      </xsl:for-each>
+    </xsl:variable>
+    
+    <out><xsl:value-of select="$union eq $or"/></out>
+    
+  </xsl:template>
+  
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/attribute/attribute-09b.xml	Wed Jul 05 15:26:05 2017 +0100
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<docs>
+<doc xmlns:ped="http://www.ped.com">
+  <foo ped:att1="a" att1="b" ped:att2="c" att2="z"/>
+  <outer xml:att1="d" att1="e"/>
+</doc>
+<doc xmlns:ped="http://www.ped.com">
+  <inner att1="f" ped:att1="g" att2="y" ped:att2="h"/>
+  <foo att1="i" xml:att1="j"/>
+</doc>
+</docs>
+   
\ No newline at end of file