From dca598334a9ba6d46a2d240abcdb2b1c5d99b845 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Dec 2005 17:13:52 +0400 Subject: Adding XPath support: ExtractValue and UpdateXML functions. libmysqld/Makefile.am: sql/Makefile.am: Adding new source files. Adding new file into build process. include/my_xml.h: strings/xml.c: Adding new XML parse flags to skip text normalization and to use relative tag names. Adding enum for XML token types. sql/lex.h: Making parser aware of new SQL functions. sqll/item_create.h, sql/item_create.cc: Adding creators for ExtractValue and UpdateXML. sql/item.h: Adding new Item types: nodeset and nodeset comparator. sql/item_xmlfunc.h sql/item_xmlfunc.cc Adding new classes implementing XPath functions. mysql-test/t/xml.test, mysql-test/r/xml.result: New files: adding test case include/my_xml.h: Adding ExtractValue and UpdateXML functions. Adding XML parser flags and enum for XML token types. sql/Makefile.am: Adding new source files. sql/item.h: Adding new Item types: nodeset and nodeset comparator. sql/item_create.cc: Adding creators for ExtractValue and UpdateXML. sql/item_create.h: Adding creators for ExtractValue and UpdateXML. sql/lex.h: Make parse aware of new SQL functions. strings/xml.c: Adding new flags to skip text normalization and to use relative tag names. libmysqld/Makefile.am: Adding new file into build process. --- mysql-test/r/xml.result | 522 ++++++++++++++++++++++++++++++++++++++++++++++++ mysql-test/t/xml.test | 217 ++++++++++++++++++++ 2 files changed, 739 insertions(+) create mode 100644 mysql-test/r/xml.result create mode 100644 mysql-test/t/xml.test (limited to 'mysql-test') diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result new file mode 100644 index 00000000000..693dd6eea81 --- /dev/null +++ b/mysql-test/r/xml.result @@ -0,0 +1,522 @@ +SET @xml='a1b1c1b2a2'; +SELECT extractValue(@xml,'/a'); +extractValue(@xml,'/a') +a1 a2 +SELECT extractValue(@xml,'/a/b'); +extractValue(@xml,'/a/b') +b1 b2 +SELECT extractValue(@xml,'/a/b/c'); +extractValue(@xml,'/a/b/c') +c1 +SELECT extractValue(@xml,'/a/@aa1'); +extractValue(@xml,'/a/@aa1') +aa1 +SELECT extractValue(@xml,'/a/@aa2'); +extractValue(@xml,'/a/@aa2') +aa2 +SELECT extractValue(@xml,'/a/@*'); +extractValue(@xml,'/a/@*') +aa1 aa2 +SELECT extractValue(@xml,'//@ba1'); +extractValue(@xml,'//@ba1') +ba1 +SELECT extractValue(@xml,'//a'); +extractValue(@xml,'//a') +a1 a2 +SELECT extractValue(@xml,'//b'); +extractValue(@xml,'//b') +b1 b2 +SELECT extractValue(@xml,'//c'); +extractValue(@xml,'//c') +c1 +SELECT extractValue(@xml,'/a//b'); +extractValue(@xml,'/a//b') +b1 b2 +SELECT extractValue(@xml,'/a//c'); +extractValue(@xml,'/a//c') +c1 +SELECT extractValue(@xml,'//*'); +extractValue(@xml,'//*') +a1 b1 c1 b2 a2 +SELECT extractValue(@xml,'/a//*'); +extractValue(@xml,'/a//*') +b1 c1 b2 +SELECT extractValue(@xml,'/./a'); +extractValue(@xml,'/./a') +a1 a2 +SELECT extractValue(@xml,'/a/b/.'); +extractValue(@xml,'/a/b/.') +b1 b2 +SELECT extractValue(@xml,'/a/b/..'); +extractValue(@xml,'/a/b/..') +a1 a2 +SELECT extractValue(@xml,'/a/b/../@aa1'); +extractValue(@xml,'/a/b/../@aa1') +aa1 +SELECT extractValue(@xml,'/*'); +extractValue(@xml,'/*') +a1 a2 +SELECT extractValue(@xml,'/*/*'); +extractValue(@xml,'/*/*') +b1 b2 +SELECT extractValue(@xml,'/*/*/*'); +extractValue(@xml,'/*/*/*') +c1 +SELECT extractValue(@xml,'/a/child::*'); +extractValue(@xml,'/a/child::*') +b1 b2 +SELECT extractValue(@xml,'/a/descendant::*'); +extractValue(@xml,'/a/descendant::*') +b1 c1 b2 +SELECT extractValue(@xml,'/a/descendant-or-self::*'); +extractValue(@xml,'/a/descendant-or-self::*') +a1 b1 c1 b2 a2 +SELECT extractValue(@xml,'/a/attribute::*'); +extractValue(@xml,'/a/attribute::*') +aa1 aa2 +SELECT extractValue(@xml,'/a/b/c/parent::*'); +extractValue(@xml,'/a/b/c/parent::*') +b1 b2 +SELECT extractValue(@xml,'/a/b/c/ancestor::*'); +extractValue(@xml,'/a/b/c/ancestor::*') +a1 b1 b2 a2 +SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*'); +extractValue(@xml,'/a/b/c/ancestor-or-self::*') +a1 b1 c1 b2 a2 +SELECT extractValue(@xml,'/descendant-or-self::*'); +extractValue(@xml,'/descendant-or-self::*') +a1 b1 c1 b2 a2 +SET @xml='a11b11b21c1b22a12'; +SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*'); +extractValue(@xml,'/a/b/c/ancestor-or-self::*') +a11 b21 c1 b22 a12 +SELECT extractValue(@xml,'//@ba'); +extractValue(@xml,'//@ba') +ba11 ba12 ba21 ba22 +SET @xml='bc'; +SELECT extractValue(@xml,'/a/b'); +extractValue(@xml,'/a/b') +b +SELECT extractValue(@xml,'/a/c'); +extractValue(@xml,'/a/c') +c +SELECT extractValue(@xml,'/a/child::b'); +extractValue(@xml,'/a/child::b') +b +SELECT extractValue(@xml,'/a/child::c'); +extractValue(@xml,'/a/child::c') +c +SET @xml='b1c1b2c2'; +SELECT extractValue(@xml,'/a/b[1]'); +extractValue(@xml,'/a/b[1]') +b1 +SELECT extractValue(@xml,'/a/b[2]'); +extractValue(@xml,'/a/b[2]') +b2 +SELECT extractValue(@xml,'/a/c[1]'); +extractValue(@xml,'/a/c[1]') +c1 +SELECT extractValue(@xml,'/a/c[2]'); +extractValue(@xml,'/a/c[2]') +c2 +SET @xml=''; +SELECT extractValue(@xml,'/a//@x'); +extractValue(@xml,'/a//@x') +xb1 xb2 xc1 xc2 +SELECT extractValue(@xml,'/a//@x[1]'); +extractValue(@xml,'/a//@x[1]') +xb1 xc1 +SELECT extractValue(@xml,'/a//@x[2]'); +extractValue(@xml,'/a//@x[2]') +xb2 xc2 +SET @xml='b1b2c1b1c1b2c2b1/a>'; +SELECT extractValue(@xml,'//b[1]'); +extractValue(@xml,'//b[1]') +b1 c1b1 c2b1 +SELECT extractValue(@xml,'/descendant::b[1]'); +extractValue(@xml,'/descendant::b[1]') +b1 +SET @xml='b1b2'; +SELECT extractValue(@xml,'/a/b[1+0]'); +extractValue(@xml,'/a/b[1+0]') +b1 +SELECT extractValue(@xml,'/a/b[1*1]'); +extractValue(@xml,'/a/b[1*1]') +b1 +SELECT extractValue(@xml,'/a/b[--1]'); +extractValue(@xml,'/a/b[--1]') +b1 +SELECT extractValue(@xml,'/a/b[2*1-1]'); +extractValue(@xml,'/a/b[2*1-1]') +b1 +SELECT extractValue(@xml,'/a/b[1+1]'); +extractValue(@xml,'/a/b[1+1]') +b2 +SELECT extractValue(@xml,'/a/b[1*2]'); +extractValue(@xml,'/a/b[1*2]') +b2 +SELECT extractValue(@xml,'/a/b[--2]'); +extractValue(@xml,'/a/b[--2]') +b2 +SELECT extractValue(@xml,'/a/b[1*(3-1)]'); +extractValue(@xml,'/a/b[1*(3-1)]') +b2 +SELECT extractValue(@xml,'//*[1=1]'); +extractValue(@xml,'//*[1=1]') +b1 b2 +SELECT extractValue(@xml,'//*[1!=1]'); +extractValue(@xml,'//*[1!=1]') + +SELECT extractValue(@xml,'//*[1>1]'); +extractValue(@xml,'//*[1>1]') + +SELECT extractValue(@xml,'//*[2>1]'); +extractValue(@xml,'//*[2>1]') +b1 b2 +SELECT extractValue(@xml,'//*[1>2]'); +extractValue(@xml,'//*[1>2]') + +SELECT extractValue(@xml,'//*[1>=1]'); +extractValue(@xml,'//*[1>=1]') +b1 b2 +SELECT extractValue(@xml,'//*[2>=1]'); +extractValue(@xml,'//*[2>=1]') +b1 b2 +SELECT extractValue(@xml,'//*[1>=2]'); +extractValue(@xml,'//*[1>=2]') + +SELECT extractValue(@xml,'//*[1<1]'); +extractValue(@xml,'//*[1<1]') + +SELECT extractValue(@xml,'//*[2<1]'); +extractValue(@xml,'//*[2<1]') + +SELECT extractValue(@xml,'//*[1<2]'); +extractValue(@xml,'//*[1<2]') +b1 b2 +SELECT extractValue(@xml,'//*[1<=1]'); +extractValue(@xml,'//*[1<=1]') +b1 b2 +SELECT extractValue(@xml,'//*[2<=1]'); +extractValue(@xml,'//*[2<=1]') + +SELECT extractValue(@xml,'//*[1<=2]'); +extractValue(@xml,'//*[1<=2]') +b1 b2 +SET @xml='b11c11b21c21'; +SELECT extractValue(@xml,'/a/b[c="c11"]'); +extractValue(@xml,'/a/b[c="c11"]') +b11 +SELECT extractValue(@xml,'/a/b[c="c21"]'); +extractValue(@xml,'/a/b[c="c21"]') +b21 +SET @xml='b11b21'; +SELECT extractValue(@xml,'/a/b[@c="c11"]'); +extractValue(@xml,'/a/b[@c="c11"]') +b11 +SELECT extractValue(@xml,'/a/b[@c="c21"]'); +extractValue(@xml,'/a/b[@c="c21"]') +b21 +SET @xml='a1b11d11b21d21'; +SELECT extractValue(@xml, '/a/b[@c="c11"]/d'); +extractValue(@xml, '/a/b[@c="c11"]/d') +d11 +SELECT extractValue(@xml, '/a/b[@c="c21"]/d'); +extractValue(@xml, '/a/b[@c="c21"]/d') +d21 +SELECT extractValue(@xml, '/a/b[d="d11"]/@c'); +extractValue(@xml, '/a/b[d="d11"]/@c') +c11 +SELECT extractValue(@xml, '/a/b[d="d21"]/@c'); +extractValue(@xml, '/a/b[d="d21"]/@c') +c21 +SELECT extractValue(@xml, '/a[b="b11"]'); +extractValue(@xml, '/a[b="b11"]') +a1 +SELECT extractValue(@xml, '/a[b/@c="c11"]'); +extractValue(@xml, '/a[b/@c="c11"]') +a1 +SELECT extractValue(@xml, '/a[b/d="d11"]'); +extractValue(@xml, '/a[b/d="d11"]') +a1 +SELECT extractValue(@xml, '/a[/a/b="b11"]'); +extractValue(@xml, '/a[/a/b="b11"]') +a1 +SELECT extractValue(@xml, '/a[/a/b/@c="c11"]'); +extractValue(@xml, '/a[/a/b/@c="c11"]') +a1 +SELECT extractValue(@xml, '/a[/a/b/d="d11"]'); +extractValue(@xml, '/a[/a/b/d="d11"]') +a1 +SELECT extractValue('a', '/a[false()]'); +extractValue('a', '/a[false()]') + +SELECT extractValue('a', '/a[true()]'); +extractValue('a', '/a[true()]') +a +SELECT extractValue('a', '/a[not(false())]'); +extractValue('a', '/a[not(false())]') +a +SELECT extractValue('a', '/a[not(true())]'); +extractValue('a', '/a[not(true())]') + +SELECT extractValue('a', '/a[true() and true()]'); +extractValue('a', '/a[true() and true()]') +a +SELECT extractValue('a', '/a[true() and false()]'); +extractValue('a', '/a[true() and false()]') + +SELECT extractValue('a', '/a[false()and false()]'); +extractValue('a', '/a[false()and false()]') + +SELECT extractValue('a', '/a[false()and true()]'); +extractValue('a', '/a[false()and true()]') + +SELECT extractValue('a', '/a[true() or true()]'); +extractValue('a', '/a[true() or true()]') +a +SELECT extractValue('a', '/a[true() or false()]'); +extractValue('a', '/a[true() or false()]') +a +SELECT extractValue('a', '/a[false()or false()]'); +extractValue('a', '/a[false()or false()]') + +SELECT extractValue('a', '/a[false()or true()]'); +extractValue('a', '/a[false()or true()]') +a +SET @xml='abb1b2b3'; +select extractValue(@xml,'/a/b[@c="c"]'); +extractValue(@xml,'/a/b[@c="c"]') +b1 +select extractValue(@xml,'/a/b[@c="d"]'); +extractValue(@xml,'/a/b[@c="d"]') +b2 +select extractValue(@xml,'/a/b[@c="e"]'); +extractValue(@xml,'/a/b[@c="e"]') +b1 b3 +select extractValue(@xml,'/a/b[not(@c="e")]'); +extractValue(@xml,'/a/b[not(@c="e")]') +b2 +select extractValue(@xml,'/a/b[@c!="e"]'); +extractValue(@xml,'/a/b[@c!="e"]') +b1 b2 b3 +select extractValue(@xml,'/a/b[@c="c" or @c="d"]'); +extractValue(@xml,'/a/b[@c="c" or @c="d"]') +b1 b2 +select extractValue(@xml,'/a/b[@c="c" and @c="e"]'); +extractValue(@xml,'/a/b[@c="c" and @c="e"]') +b1 +SET @xml='b1b2'; +select extractValue(@xml,'/a/b[@c]'); +extractValue(@xml,'/a/b[@c]') +b1 +select extractValue(@xml,'/a/b[@d]'); +extractValue(@xml,'/a/b[@d]') +b1 b2 +select extractValue(@xml,'/a/b[@e]'); +extractValue(@xml,'/a/b[@e]') +b2 +select extractValue(@xml,'/a/b[not(@c)]'); +extractValue(@xml,'/a/b[not(@c)]') +b2 +select extractValue(@xml,'/a/b[not(@d)]'); +extractValue(@xml,'/a/b[not(@d)]') + +select extractValue(@xml,'/a/b[not(@e)]'); +extractValue(@xml,'/a/b[not(@e)]') +b1 +select extractValue(@xml, '/a/b[boolean(@c) or boolean(@d)]'); +extractValue(@xml, '/a/b[boolean(@c) or boolean(@d)]') +b1 b2 +select extractValue(@xml, '/a/b[boolean(@c) or boolean(@e)]'); +extractValue(@xml, '/a/b[boolean(@c) or boolean(@e)]') +b1 b2 +select extractValue(@xml, '/a/b[boolean(@d) or boolean(@e)]'); +extractValue(@xml, '/a/b[boolean(@d) or boolean(@e)]') +b1 b2 +select extractValue(@xml, '/a/b[boolean(@c) and boolean(@d)]'); +extractValue(@xml, '/a/b[boolean(@c) and boolean(@d)]') +b1 +select extractValue(@xml, '/a/b[boolean(@c) and boolean(@e)]'); +extractValue(@xml, '/a/b[boolean(@c) and boolean(@e)]') + +select extractValue(@xml, '/a/b[boolean(@d) and boolean(@e)]'); +extractValue(@xml, '/a/b[boolean(@d) and boolean(@e)]') +b2 +select extractValue(@xml, '/a/b[@c or @d]'); +extractValue(@xml, '/a/b[@c or @d]') +b1 b2 +select extractValue(@xml, '/a/b[@c or @e]'); +extractValue(@xml, '/a/b[@c or @e]') +b1 b2 +select extractValue(@xml, '/a/b[@d or @e]'); +extractValue(@xml, '/a/b[@d or @e]') +b1 b2 +select extractValue(@xml, '/a/b[@c and @d]'); +extractValue(@xml, '/a/b[@c and @d]') +b1 +select extractValue(@xml, '/a/b[@c and @e]'); +extractValue(@xml, '/a/b[@c and @e]') + +select extractValue(@xml, '/a/b[@d and @e]'); +extractValue(@xml, '/a/b[@d and @e]') +b2 +SET @xml='b1b2'; +SELECT extractValue(@xml,'/a/b[@*]'); +extractValue(@xml,'/a/b[@*]') +b1 +SELECT extractValue(@xml,'/a/b[not(@*)]'); +extractValue(@xml,'/a/b[not(@*)]') +b2 +SELECT extractValue('a', '/a[ceiling(3.1)=4]'); +extractValue('a', '/a[ceiling(3.1)=4]') +a +SELECT extractValue('a', '/a[floor(3.1)=3]'); +extractValue('a', '/a[floor(3.1)=3]') +a +SELECT extractValue('a', '/a[round(3.1)=3]'); +extractValue('a', '/a[round(3.1)=3]') +a +SELECT extractValue('a', '/a[round(3.8)=4]'); +extractValue('a', '/a[round(3.8)=4]') +a +SELECT extractValue('bc', '/a/b | /a/c'); +extractValue('bc', '/a/b | /a/c') +b c +select extractValue('','/a/@b[position()=1]'); +extractValue('','/a/@b[position()=1]') +b1 +select extractValue('','/a/@b[position()=2]'); +extractValue('','/a/@b[position()=2]') +b2 +select extractValue('','/a/@b[position()=3]'); +extractValue('','/a/@b[position()=3]') +b3 +select extractValue('','/a/@b[1=position()]'); +extractValue('','/a/@b[1=position()]') +b1 +select extractValue('','/a/@b[2=position()]'); +extractValue('','/a/@b[2=position()]') +b2 +select extractValue('','/a/@b[3=position()]'); +extractValue('','/a/@b[3=position()]') +b3 +select extractValue('','/a/@b[2>=position()]'); +extractValue('','/a/@b[2>=position()]') +b1 b2 +select extractValue('','/a/@b[2<=position()]'); +extractValue('','/a/@b[2<=position()]') +b2 b3 +select extractValue('','/a/@b[position()=3 or position()=2]'); +extractValue('','/a/@b[position()=3 or position()=2]') +b2 b3 +SELECT extractValue('aa1c1a2','/a/b[count(c)=0]'); +extractValue('aa1c1a2','/a/b[count(c)=0]') +a2 +SELECT extractValue('aa1c1a2','/a/b[count(c)=1]'); +extractValue('aa1c1a2','/a/b[count(c)=1]') +a1 +select extractValue('a1b1b24','/a/b[sum(@ba)=3]'); +extractValue('a1b1b24','/a/b[sum(@ba)=3]') +b1 +select extractValue('b1b2','/a/b[1]'); +extractValue('b1b2','/a/b[1]') +b1 +select extractValue('b1b2','/a/b[boolean(1)]'); +extractValue('b1b2','/a/b[boolean(1)]') +b1 b2 +select extractValue('b1b2','/a/b[true()]'); +extractValue('b1b2','/a/b[true()]') +b1 b2 +select extractValue('b1b2','/a/b[number(true())]'); +extractValue('b1b2','/a/b[number(true())]') +b1 +select extractValue('ab','/a[contains("abc","b")]'); +extractValue('ab','/a[contains("abc","b")]') +ab +select extractValue('ab','/a[contains(.,"a")]'); +extractValue('ab','/a[contains(.,"a")]') +ab +select extractValue('ab','/a[contains(.,"b")]'); +extractValue('ab','/a[contains(.,"b")]') +ab +select extractValue('ab','/a[contains(.,"c")]'); +extractValue('ab','/a[contains(.,"c")]') + +select extractValue('ab','/a[concat(@b,"2")="12"]'); +extractValue('ab','/a[concat(@b,"2")="12"]') +ab +SET @xml='ab'; +select extractValue(@xml, '/a/@b[substring(.,2)="1"]'); +extractValue(@xml, '/a/@b[substring(.,2)="1"]') +11 21 +select extractValue(@xml, '/a/@b[substring(.,2)="2"]'); +extractValue(@xml, '/a/@b[substring(.,2)="2"]') +12 22 +select extractValue(@xml, '/a/@b[substring(.,1,1)="1"]'); +extractValue(@xml, '/a/@b[substring(.,1,1)="1"]') +11 12 +select extractValue(@xml, '/a/@b[substring(.,1,1)="2"]'); +extractValue(@xml, '/a/@b[substring(.,1,1)="2"]') +21 22 +select extractValue(@xml, '/a/@b[substring(.,2,1)="1"]'); +extractValue(@xml, '/a/@b[substring(.,2,1)="1"]') +11 21 +select extractValue(@xml, '/a/@b[substring(.,2,1)="2"]'); +extractValue(@xml, '/a/@b[substring(.,2,1)="2"]') +12 22 +SET @xml=''; +select extractValue(@xml,'/a/@b'); +extractValue(@xml,'/a/@b') +b11 b12 b21 22 +select extractValue(@xml,'/a/@b[contains(.,"1")]'); +extractValue(@xml,'/a/@b[contains(.,"1")]') +b11 b12 b21 +select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")]'); +extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")]') +b12 b21 +select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")][2]'); +extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")][2]') +b21 +SET @xml='a1b1c1b2a2'; +select UpdateXML('a1b1c1b2a2','/a/b/c','+++++++++'); +UpdateXML('a1b1c1b2a2','/a/b/c','+++++++++') +a1b1+++++++++b2a2 +select UpdateXML('a1b1c1b2a2','/a/b/c','+++++++++'); +UpdateXML('a1b1c1b2a2','/a/b/c','+++++++++') +a1b1+++++++++b2a2 +select UpdateXML('a1b1c1b2a2','/a/b/c',''); +UpdateXML('a1b1c1b2a2','/a/b/c','') +a1b1b2a2 +SET @xml='bb'; +select UpdateXML(@xml, '/a/b', 'ccc'); +UpdateXML(@xml, '/a/b', 'ccc') +ccc +SET @xml='bb'; +select UpdateXML(@xml, '/a/b', 'ccc'); +UpdateXML(@xml, '/a/b', 'ccc') +ccc +select UpdateXML(@xml, '/a/@aa1', ''); +UpdateXML(@xml, '/a/@aa1', '') +bb +select UpdateXML(@xml, '/a/@aa1', 'aa3="aa3"'); +UpdateXML(@xml, '/a/@aa1', 'aa3="aa3"') +bb +select UpdateXML(@xml, '/a/@aa2', ''); +UpdateXML(@xml, '/a/@aa2', '') +bb +select UpdateXML(@xml, '/a/@aa2', 'aa3="aa3"'); +UpdateXML(@xml, '/a/@aa2', 'aa3="aa3"') +bb +select UpdateXML(@xml, '/a/b/@bb1', ''); +UpdateXML(@xml, '/a/b/@bb1', '') +bb +select UpdateXML(@xml, '/a/b/@bb1', 'bb3="bb3"'); +UpdateXML(@xml, '/a/b/@bb1', 'bb3="bb3"') +bb +select UpdateXML(@xml, '/a/b/@bb2', ''); +UpdateXML(@xml, '/a/b/@bb2', '') +bb +select UpdateXML(@xml, '/a/b/@bb2', 'bb3="bb3"'); +UpdateXML(@xml, '/a/b/@bb2', 'bb3="bb3"') +bb diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test new file mode 100644 index 00000000000..472f6d49300 --- /dev/null +++ b/mysql-test/t/xml.test @@ -0,0 +1,217 @@ +SET @xml='a1b1c1b2a2'; +SELECT extractValue(@xml,'/a'); +SELECT extractValue(@xml,'/a/b'); +SELECT extractValue(@xml,'/a/b/c'); +SELECT extractValue(@xml,'/a/@aa1'); +SELECT extractValue(@xml,'/a/@aa2'); +SELECT extractValue(@xml,'/a/@*'); +SELECT extractValue(@xml,'//@ba1'); + +SELECT extractValue(@xml,'//a'); +SELECT extractValue(@xml,'//b'); +SELECT extractValue(@xml,'//c'); +SELECT extractValue(@xml,'/a//b'); +SELECT extractValue(@xml,'/a//c'); +SELECT extractValue(@xml,'//*'); +SELECT extractValue(@xml,'/a//*'); +SELECT extractValue(@xml,'/./a'); +SELECT extractValue(@xml,'/a/b/.'); +SELECT extractValue(@xml,'/a/b/..'); +SELECT extractValue(@xml,'/a/b/../@aa1'); +SELECT extractValue(@xml,'/*'); +SELECT extractValue(@xml,'/*/*'); +SELECT extractValue(@xml,'/*/*/*'); + +SELECT extractValue(@xml,'/a/child::*'); +SELECT extractValue(@xml,'/a/descendant::*'); +SELECT extractValue(@xml,'/a/descendant-or-self::*'); +SELECT extractValue(@xml,'/a/attribute::*'); +SELECT extractValue(@xml,'/a/b/c/parent::*'); +SELECT extractValue(@xml,'/a/b/c/ancestor::*'); +SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*'); +SELECT extractValue(@xml,'/descendant-or-self::*'); + +SET @xml='a11b11b21c1b22a12'; +SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*'); +SELECT extractValue(@xml,'//@ba'); + +SET @xml='bc'; +SELECT extractValue(@xml,'/a/b'); +SELECT extractValue(@xml,'/a/c'); +SELECT extractValue(@xml,'/a/child::b'); +SELECT extractValue(@xml,'/a/child::c'); + +SET @xml='b1c1b2c2'; +SELECT extractValue(@xml,'/a/b[1]'); +SELECT extractValue(@xml,'/a/b[2]'); +SELECT extractValue(@xml,'/a/c[1]'); +SELECT extractValue(@xml,'/a/c[2]'); + +SET @xml=''; +SELECT extractValue(@xml,'/a//@x'); +SELECT extractValue(@xml,'/a//@x[1]'); +SELECT extractValue(@xml,'/a//@x[2]'); + +SET @xml='b1b2c1b1c1b2c2b1/a>'; +SELECT extractValue(@xml,'//b[1]'); +SELECT extractValue(@xml,'/descendant::b[1]'); + +SET @xml='b1b2'; +SELECT extractValue(@xml,'/a/b[1+0]'); +SELECT extractValue(@xml,'/a/b[1*1]'); +SELECT extractValue(@xml,'/a/b[--1]'); +SELECT extractValue(@xml,'/a/b[2*1-1]'); + +SELECT extractValue(@xml,'/a/b[1+1]'); +SELECT extractValue(@xml,'/a/b[1*2]'); +SELECT extractValue(@xml,'/a/b[--2]'); +SELECT extractValue(@xml,'/a/b[1*(3-1)]'); + +SELECT extractValue(@xml,'//*[1=1]'); +SELECT extractValue(@xml,'//*[1!=1]'); +SELECT extractValue(@xml,'//*[1>1]'); +SELECT extractValue(@xml,'//*[2>1]'); +SELECT extractValue(@xml,'//*[1>2]'); +SELECT extractValue(@xml,'//*[1>=1]'); +SELECT extractValue(@xml,'//*[2>=1]'); +SELECT extractValue(@xml,'//*[1>=2]'); +SELECT extractValue(@xml,'//*[1<1]'); +SELECT extractValue(@xml,'//*[2<1]'); +SELECT extractValue(@xml,'//*[1<2]'); +SELECT extractValue(@xml,'//*[1<=1]'); +SELECT extractValue(@xml,'//*[2<=1]'); +SELECT extractValue(@xml,'//*[1<=2]'); + +SET @xml='b11c11b21c21'; +SELECT extractValue(@xml,'/a/b[c="c11"]'); +SELECT extractValue(@xml,'/a/b[c="c21"]'); + +SET @xml='b11b21'; +SELECT extractValue(@xml,'/a/b[@c="c11"]'); +SELECT extractValue(@xml,'/a/b[@c="c21"]'); + +SET @xml='a1b11d11b21d21'; +SELECT extractValue(@xml, '/a/b[@c="c11"]/d'); +SELECT extractValue(@xml, '/a/b[@c="c21"]/d'); +SELECT extractValue(@xml, '/a/b[d="d11"]/@c'); +SELECT extractValue(@xml, '/a/b[d="d21"]/@c'); +SELECT extractValue(@xml, '/a[b="b11"]'); +SELECT extractValue(@xml, '/a[b/@c="c11"]'); +SELECT extractValue(@xml, '/a[b/d="d11"]'); +SELECT extractValue(@xml, '/a[/a/b="b11"]'); +SELECT extractValue(@xml, '/a[/a/b/@c="c11"]'); +SELECT extractValue(@xml, '/a[/a/b/d="d11"]'); + +SELECT extractValue('a', '/a[false()]'); +SELECT extractValue('a', '/a[true()]'); +SELECT extractValue('a', '/a[not(false())]'); +SELECT extractValue('a', '/a[not(true())]'); +SELECT extractValue('a', '/a[true() and true()]'); +SELECT extractValue('a', '/a[true() and false()]'); +SELECT extractValue('a', '/a[false()and false()]'); +SELECT extractValue('a', '/a[false()and true()]'); +SELECT extractValue('a', '/a[true() or true()]'); +SELECT extractValue('a', '/a[true() or false()]'); +SELECT extractValue('a', '/a[false()or false()]'); +SELECT extractValue('a', '/a[false()or true()]'); + +SET @xml='abb1b2b3'; +select extractValue(@xml,'/a/b[@c="c"]'); +select extractValue(@xml,'/a/b[@c="d"]'); +select extractValue(@xml,'/a/b[@c="e"]'); +select extractValue(@xml,'/a/b[not(@c="e")]'); +select extractValue(@xml,'/a/b[@c!="e"]'); +select extractValue(@xml,'/a/b[@c="c" or @c="d"]'); +select extractValue(@xml,'/a/b[@c="c" and @c="e"]'); + +SET @xml='b1b2'; +select extractValue(@xml,'/a/b[@c]'); +select extractValue(@xml,'/a/b[@d]'); +select extractValue(@xml,'/a/b[@e]'); +select extractValue(@xml,'/a/b[not(@c)]'); +select extractValue(@xml,'/a/b[not(@d)]'); +select extractValue(@xml,'/a/b[not(@e)]'); + +select extractValue(@xml, '/a/b[boolean(@c) or boolean(@d)]'); +select extractValue(@xml, '/a/b[boolean(@c) or boolean(@e)]'); +select extractValue(@xml, '/a/b[boolean(@d) or boolean(@e)]'); +select extractValue(@xml, '/a/b[boolean(@c) and boolean(@d)]'); +select extractValue(@xml, '/a/b[boolean(@c) and boolean(@e)]'); +select extractValue(@xml, '/a/b[boolean(@d) and boolean(@e)]'); + +select extractValue(@xml, '/a/b[@c or @d]'); +select extractValue(@xml, '/a/b[@c or @e]'); +select extractValue(@xml, '/a/b[@d or @e]'); +select extractValue(@xml, '/a/b[@c and @d]'); +select extractValue(@xml, '/a/b[@c and @e]'); +select extractValue(@xml, '/a/b[@d and @e]'); + +SET @xml='b1b2'; +SELECT extractValue(@xml,'/a/b[@*]'); +SELECT extractValue(@xml,'/a/b[not(@*)]'); + +SELECT extractValue('a', '/a[ceiling(3.1)=4]'); +SELECT extractValue('a', '/a[floor(3.1)=3]'); +SELECT extractValue('a', '/a[round(3.1)=3]'); +SELECT extractValue('a', '/a[round(3.8)=4]'); + +SELECT extractValue('bc', '/a/b | /a/c'); + +select extractValue('','/a/@b[position()=1]'); +select extractValue('','/a/@b[position()=2]'); +select extractValue('','/a/@b[position()=3]'); +select extractValue('','/a/@b[1=position()]'); +select extractValue('','/a/@b[2=position()]'); +select extractValue('','/a/@b[3=position()]'); +select extractValue('','/a/@b[2>=position()]'); +select extractValue('','/a/@b[2<=position()]'); +select extractValue('','/a/@b[position()=3 or position()=2]'); + +SELECT extractValue('aa1c1a2','/a/b[count(c)=0]'); +SELECT extractValue('aa1c1a2','/a/b[count(c)=1]'); +select extractValue('a1b1b24','/a/b[sum(@ba)=3]'); + +select extractValue('b1b2','/a/b[1]'); +select extractValue('b1b2','/a/b[boolean(1)]'); +select extractValue('b1b2','/a/b[true()]'); +select extractValue('b1b2','/a/b[number(true())]'); + +select extractValue('ab','/a[contains("abc","b")]'); +select extractValue('ab','/a[contains(.,"a")]'); +select extractValue('ab','/a[contains(.,"b")]'); +select extractValue('ab','/a[contains(.,"c")]'); + +select extractValue('ab','/a[concat(@b,"2")="12"]'); + +SET @xml='ab'; +select extractValue(@xml, '/a/@b[substring(.,2)="1"]'); +select extractValue(@xml, '/a/@b[substring(.,2)="2"]'); +select extractValue(@xml, '/a/@b[substring(.,1,1)="1"]'); +select extractValue(@xml, '/a/@b[substring(.,1,1)="2"]'); +select extractValue(@xml, '/a/@b[substring(.,2,1)="1"]'); +select extractValue(@xml, '/a/@b[substring(.,2,1)="2"]'); + +SET @xml=''; +select extractValue(@xml,'/a/@b'); +select extractValue(@xml,'/a/@b[contains(.,"1")]'); +select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")]'); +select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")][2]'); + +SET @xml='a1b1c1b2a2'; +select UpdateXML('a1b1c1b2a2','/a/b/c','+++++++++'); +select UpdateXML('a1b1c1b2a2','/a/b/c','+++++++++'); +select UpdateXML('a1b1c1b2a2','/a/b/c',''); + +SET @xml='bb'; +select UpdateXML(@xml, '/a/b', 'ccc'); + +SET @xml='bb'; +select UpdateXML(@xml, '/a/b', 'ccc'); +select UpdateXML(@xml, '/a/@aa1', ''); +select UpdateXML(@xml, '/a/@aa1', 'aa3="aa3"'); +select UpdateXML(@xml, '/a/@aa2', ''); +select UpdateXML(@xml, '/a/@aa2', 'aa3="aa3"'); +select UpdateXML(@xml, '/a/b/@bb1', ''); +select UpdateXML(@xml, '/a/b/@bb1', 'bb3="bb3"'); +select UpdateXML(@xml, '/a/b/@bb2', ''); +select UpdateXML(@xml, '/a/b/@bb2', 'bb3="bb3"'); -- cgit v1.2.1