New regex test from a Saxon bug report default tip
authorMichael Kay <mike@saxonica.com>
Sun, 16 Sep 2018 14:54:41 +0100
changeset 1894 5aca602b9d58
parent 1893 6378e52dfdf2
New regex test from a Saxon bug report
tests/insn/analyze-string/_analyze-string-test-set.xml
tests/insn/analyze-string/analyze-string-099.xsl
--- a/tests/insn/analyze-string/_analyze-string-test-set.xml	Tue Sep 11 15:08:59 2018 +0100
+++ b/tests/insn/analyze-string/_analyze-string-test-set.xml	Sun Sep 16 14:54:41 2018 +0100
@@ -1005,4 +1005,22 @@
       </result>
    </test-case>
    
+   <test-case name="analyze-string-099">
+      <description>A test for non-greedy matching</description>
+      <created by="Michael Kay after Vladimir Nestorovsky" on="2018-09-12"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="analyze-string-099.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>count(/out/match) = 2</assert>
+            <assert>/out/match[1] = '"a"'</assert>
+            <assert>/out/match[2] = '"b"'</assert> 
+         </all-of>
+      </result>
+   </test-case>
+   
 </test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/analyze-string/analyze-string-099.xsl	Sun Sep 16 14:54:41 2018 +0100
@@ -0,0 +1,22 @@
+<xsl:stylesheet version="3.0" 
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ exclude-result-prefixes="#all">
+ 
+ <!-- A test for non-greedy matching -->
+ 
+ <xsl:template match="/" name="xsl:initial-template">
+  <out>
+   <xsl:variable name="text" as="xs:string">'A = "a" OR B = "b"'</xsl:variable> 
+  
+  <xsl:analyze-string regex='"(%%|.)*?"' select="$text">
+   <xsl:matching-substring>
+    <match>
+     <xsl:sequence select="regex-group(0)"/>
+    </match>
+   </xsl:matching-substring>
+  </xsl:analyze-string>
+  </out>
+ </xsl:template>
+ 
+</xsl:stylesheet>
\ No newline at end of file