2005-12-21 14:13:52 +01:00
|
|
|
SET @xml='<a aa1="aa1" aa2="aa2">a1<b ba1="ba1">b1<c>c1</c>b2</b>a2</a>';
|
|
|
|
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::*');
|
2006-03-01 10:16:12 +01:00
|
|
|
SELECT extractValue(@xml,'/a/self::*');
|
2005-12-21 14:13:52 +01:00
|
|
|
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='<a>a11<b ba="ba11" ba="ba12">b11</b><b ba="ba21" ba="ba22">b21<c>c1</c>b22</b>a12</a>';
|
|
|
|
SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*');
|
|
|
|
SELECT extractValue(@xml,'//@ba');
|
|
|
|
|
|
|
|
SET @xml='<a><b>b</b><c>c</c></a>';
|
|
|
|
SELECT extractValue(@xml,'/a/b');
|
|
|
|
SELECT extractValue(@xml,'/a/c');
|
|
|
|
SELECT extractValue(@xml,'/a/child::b');
|
|
|
|
SELECT extractValue(@xml,'/a/child::c');
|
|
|
|
|
|
|
|
SET @xml='<a><b>b1</b><c>c1</c><b>b2</b><c>c2</c></a>';
|
|
|
|
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='<a><b x="xb1" x="xb2"/><c x="xc1" x="xc2"/></a>';
|
|
|
|
SELECT extractValue(@xml,'/a//@x');
|
|
|
|
SELECT extractValue(@xml,'/a//@x[1]');
|
|
|
|
SELECT extractValue(@xml,'/a//@x[2]');
|
|
|
|
|
2006-04-17 11:40:25 +02:00
|
|
|
SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b></a>';
|
2005-12-21 14:13:52 +01:00
|
|
|
SELECT extractValue(@xml,'//b[1]');
|
|
|
|
SELECT extractValue(@xml,'/descendant::b[1]');
|
|
|
|
|
|
|
|
SET @xml='<a><b>b1</b><b>b2</b></a>';
|
|
|
|
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='<a><b>b11<c>c11</c></b><b>b21<c>c21</c></b></a>';
|
|
|
|
SELECT extractValue(@xml,'/a/b[c="c11"]');
|
|
|
|
SELECT extractValue(@xml,'/a/b[c="c21"]');
|
|
|
|
|
|
|
|
SET @xml='<a><b c="c11">b11</b><b c="c21">b21</b></a>';
|
|
|
|
SELECT extractValue(@xml,'/a/b[@c="c11"]');
|
|
|
|
SELECT extractValue(@xml,'/a/b[@c="c21"]');
|
|
|
|
|
|
|
|
SET @xml='<a>a1<b c="c11">b11<d>d11</d></b><b c="c21">b21<d>d21</d></b></a>';
|
|
|
|
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</a>', '/a[false()]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[true()]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[not(false())]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[not(true())]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[true() and true()]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[true() and false()]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[false()and false()]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[false()and true()]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[true() or true()]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[true() or false()]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[false()or false()]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[false()or true()]');
|
|
|
|
|
|
|
|
SET @xml='<a>ab<b c="c" c="e">b1</b><b c="d">b2</b><b c="f" c="e">b3</b></a>';
|
|
|
|
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='<a><b c="c" d="d">b1</b><b d="d" e="e">b2</b></a>';
|
|
|
|
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='<a><b c="c">b1</b><b>b2</b></a>';
|
|
|
|
SELECT extractValue(@xml,'/a/b[@*]');
|
|
|
|
SELECT extractValue(@xml,'/a/b[not(@*)]');
|
|
|
|
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[ceiling(3.1)=4]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[floor(3.1)=3]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[round(3.1)=3]');
|
|
|
|
SELECT extractValue('<a>a</a>', '/a[round(3.8)=4]');
|
|
|
|
|
|
|
|
SELECT extractValue('<a><b>b</b><c>c</c></a>', '/a/b | /a/c');
|
|
|
|
|
|
|
|
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=1]');
|
|
|
|
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=2]');
|
|
|
|
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3]');
|
|
|
|
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[1=position()]');
|
|
|
|
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2=position()]');
|
|
|
|
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[3=position()]');
|
|
|
|
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2>=position()]');
|
|
|
|
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2<=position()]');
|
|
|
|
select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3 or position()=2]');
|
|
|
|
|
|
|
|
SELECT extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=0]');
|
|
|
|
SELECT extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=1]');
|
|
|
|
select extractValue('<a>a1<b ba="1" ba="2">b1</b><b>b2</b>4</a>','/a/b[sum(@ba)=3]');
|
|
|
|
|
|
|
|
select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[1]');
|
|
|
|
select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[boolean(1)]');
|
|
|
|
select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[true()]');
|
|
|
|
select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[number(true())]');
|
|
|
|
|
|
|
|
select extractValue('<a>ab</a>','/a[contains("abc","b")]');
|
|
|
|
select extractValue('<a>ab</a>','/a[contains(.,"a")]');
|
|
|
|
select extractValue('<a>ab</a>','/a[contains(.,"b")]');
|
|
|
|
select extractValue('<a>ab</a>','/a[contains(.,"c")]');
|
|
|
|
|
|
|
|
select extractValue('<a b="1">ab</a>','/a[concat(@b,"2")="12"]');
|
|
|
|
|
|
|
|
SET @xml='<a b="11" b="12" b="21" b="22">ab</a>';
|
|
|
|
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"]');
|
|
|
|
|
2006-04-07 11:07:56 +02:00
|
|
|
#
|
|
|
|
# Bug#16319: XML: extractvalue() returns syntax errors for some functions
|
|
|
|
#
|
|
|
|
SET @xml='<a><b>b1</b><b>b2</b></a>';
|
|
|
|
SELECT extractValue(@xml, '/a/b[string-length("x")=1]');
|
|
|
|
SELECT extractValue(@xml, '/a/b[string-length("xx")=2]');
|
|
|
|
SELECT extractValue(@xml, '/a/b[string-length("xxx")=2]');
|
|
|
|
SELECT extractValue(@xml, '/a/b[string-length("x")]');
|
|
|
|
SELECT extractValue(@xml, '/a/b[string-length("xx")]');
|
|
|
|
SELECT extractValue(@xml, '/a/b[string-length()]');
|
|
|
|
--error 1105
|
|
|
|
SELECT extractValue(@xml, 'string-length()');
|
|
|
|
SELECT extractValue(@xml, 'string-length("x")');
|
|
|
|
|
2005-12-21 14:13:52 +01:00
|
|
|
SET @xml='<a b="b11" b="b12" b="b21" b="22"/>';
|
|
|
|
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='<a>a1<b>b1<c>c1</c>b2</b>a2</a>';
|
|
|
|
select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','+++++++++');
|
|
|
|
select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1>+++++++++</c1>');
|
|
|
|
select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1/>');
|
|
|
|
|
|
|
|
SET @xml='<a><b>bb</b></a>';
|
|
|
|
select UpdateXML(@xml, '/a/b', '<b>ccc</b>');
|
|
|
|
|
|
|
|
SET @xml='<a aa1="aa1" aa2="aa2"><b bb1="bb1" bb2="bb2">bb</b></a>';
|
|
|
|
select UpdateXML(@xml, '/a/b', '<b>ccc</b>');
|
|
|
|
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"');
|
2006-02-10 10:24:10 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#16234 XML: Crash if ExtractValue()
|
|
|
|
#
|
|
|
|
SET @xml= '<order><clerk>lesser wombat</clerk></order>';
|
|
|
|
select extractvalue(@xml,'order/clerk');
|
|
|
|
select extractvalue(@xml,'/order/clerk');
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#16314 XML: extractvalue() crash if vertical bar
|
|
|
|
#
|
|
|
|
select extractvalue('<a><b>B</b></a>','/a|/b');
|
|
|
|
select extractvalue('<a><b>B</b></a>','/a|b');
|
|
|
|
select extractvalue('<a>a<b>B</b></a>','/a|/b');
|
|
|
|
select extractvalue('<a>a<b>B</b></a>','/a|b');
|
|
|
|
select extractvalue('<a>a<b>B</b></a>','a|/b');
|
2006-02-27 08:21:20 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#16312 XML: extractvalue() crash if angle brackets
|
|
|
|
#
|
|
|
|
--error 1105
|
|
|
|
select extractvalue('<a>A</a>','/<a>');
|
Bug#16313 XML: extractvalue() ignores '!' in names
xml.result, xml.test:
Adding test case.
item_xmlfunc.cc:
Fixed that the "!" character written at the end was ignored.
Now if we try to scan "!=", and if "!" is not
followed by "=", we rollback lex scanner back
to "!" token, so the parser will start to check
the next rule from the "!" character again.
Previously parser started from the next character,
which was EOF in the example in xml.test,
which led to query being successfully parsed,
instead of producing a syntax error.
sql/item_xmlfunc.cc:
Bug#16313 XML: extractvalue() ignores '!' in names
'!' at the end was ignored.
Now if we try to scan "!=", and if "!" is not
followed by "=", we rollback lex scanner back
to "!" token, so the parser will start to check
the next rule from the "!" character again.
Previously it started from the next character,
which was EOF in the example in xml.test, and
which led to query being successfully parsed,
instead of producing a syntax error.
mysql-test/t/xml.test:
Adding test case.
mysql-test/r/xml.result:
Adding test case.
2006-02-28 10:59:16 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#16313 XML: extractvalue() ignores '!' in names
|
|
|
|
#
|
|
|
|
--error 1105
|
|
|
|
select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
|
2006-03-01 07:36:22 +01:00
|
|
|
|
|
|
|
#
|
2006-03-01 10:16:12 +01:00
|
|
|
# Bug #16315 XML: extractvalue() handles self badly
|
|
|
|
#
|
|
|
|
select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
|
|
|
|
select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*');
|
|
|
|
select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*');
|
2006-03-01 07:36:22 +01:00
|
|
|
# Bug #16320 XML: extractvalue() won't accept names containing underscores
|
|
|
|
#
|
|
|
|
select extractvalue('<A_B>A</A_B>','/A_B');
|
2006-03-02 11:05:38 +01:00
|
|
|
|
2006-03-03 15:36:14 +01:00
|
|
|
#
|
|
|
|
# Bug#16318: XML: extractvalue() incorrectly returns last() = 1
|
|
|
|
#
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[position()]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=last()]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()-1]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=1]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=2]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=position()]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)-1]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=1]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=2]');
|
|
|
|
select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=position()]');
|
2006-03-02 11:05:38 +01:00
|
|
|
#
|
|
|
|
# Bug#16316: XML: extractvalue() is case-sensitive with contains()
|
|
|
|
#
|
|
|
|
select extractvalue('<a>Jack</a>','/a[contains(../a,"J")]');
|
|
|
|
select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]');
|
|
|
|
select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin);
|
|
|
|
select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');
|
2006-03-15 08:57:37 +01:00
|
|
|
|
2006-04-07 08:04:33 +02:00
|
|
|
#
|
|
|
|
# Bug#18285: ExtractValue not returning character
|
|
|
|
# data within <![CDATA[]]> as expected
|
|
|
|
#
|
|
|
|
select ExtractValue('<tag1><![CDATA[test]]></tag1>','/tag1');
|
|
|
|
|
2006-04-17 11:40:25 +02:00
|
|
|
#
|
|
|
|
# Bug#18201: XML: ExtractValue works even if the xml fragment
|
|
|
|
# is not well-formed xml
|
|
|
|
#
|
|
|
|
select extractValue('<a>a','/a');
|
|
|
|
select extractValue('<a>a<','/a');
|
|
|
|
select extractValue('<a>a</','/a');
|
|
|
|
select extractValue('<a>a</a','/a');
|
|
|
|
select extractValue('<a>a</a></b>','/a');
|
|
|
|
select extractValue('<a b=>a</a>','/a');
|
|
|
|
|
2006-03-15 08:57:37 +01:00
|
|
|
#
|
|
|
|
# Bug #18171 XML: ExtractValue: the XPath position()
|
|
|
|
# function crashes the server!
|
|
|
|
#
|
|
|
|
--error 1105
|
|
|
|
select extractValue('<e>1</e>','position()');
|
|
|
|
--error 1105
|
|
|
|
select extractValue('<e>1</e>','last()');
|
2006-03-20 11:57:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bug #18172 XML: Extractvalue() accepts mallformed
|
|
|
|
# XPath without a XPath syntax error
|
|
|
|
#
|
|
|
|
--error 1105
|
|
|
|
select extractValue('<e><a>1</a></e>','/e/');
|
|
|
|
|
2006-04-11 10:25:02 +02:00
|
|
|
#
|
|
|
|
# Bug#16233: XML: ExtractValue() fails with special characters
|
|
|
|
#
|
|
|
|
set names utf8;
|
|
|
|
select extractValue('<Ñ><r>r</r></Ñ>','/Ñ/r');
|
|
|
|
select extractValue('<r><Ñ>Ñ</Ñ></r>','/r/Ñ');
|
|
|
|
select extractValue('<Ñ r="r"/>','/Ñ/@r');
|
|
|
|
select extractValue('<r Ñ="Ñ"/>','/r/@Ñ');
|
|
|
|
--disable_warnings
|
|
|
|
DROP PROCEDURE IF EXISTS p2;
|
|
|
|
--enable_warnings
|
|
|
|
DELIMITER //;
|
|
|
|
CREATE PROCEDURE p2 ()
|
|
|
|
BEGIN
|
|
|
|
DECLARE p LONGTEXT CHARACTER SET UTF8 DEFAULT '<Ñ><r>A</r></Ñ>';
|
|
|
|
SELECT EXTRACTVALUE(p,'/Ñ/r');
|
|
|
|
END//
|
|
|
|
DELIMITER ;//
|
|
|
|
CALL p2();
|
|
|
|
DROP PROCEDURE p2;
|
2006-04-17 08:49:20 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#18170: XML: ExtractValue():
|
|
|
|
# XPath expression can't use QNames (colon in names)
|
|
|
|
#
|
|
|
|
select extractValue('<ns:element xmlns:ns="myns"/>','count(ns:element)');
|
|
|
|
select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element');
|
|
|
|
select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns');
|
2006-07-25 15:46:43 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#20795 extractvalue() won't accept names containing a dot (.)
|
|
|
|
#
|
|
|
|
select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/foo.bar');
|
|
|
|
select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/something');
|
2006-09-14 08:47:19 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#20854 XML functions: wrong result in ExtractValue
|
|
|
|
#
|
|
|
|
--error 1105
|
|
|
|
select extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','/zot/tim0/02');
|
|
|
|
select extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','//*');
|
|
|
|
# dot and dash are bad identtifier start character
|
|
|
|
select extractValue('<.>test</.>','//*');
|
|
|
|
select extractValue('<->test</->','//*');
|
|
|
|
# semicolon is good identifier start character
|
|
|
|
select extractValue('<:>test</:>','//*');
|
|
|
|
# underscore is good identifier start character
|
|
|
|
select extractValue('<_>test</_>','//*');
|
|
|
|
# dot, dash, underscore and semicolon are good identifier middle characters
|
|
|
|
select extractValue('<x.-_:>test</x.-_:>','//*');
|
2006-10-23 11:17:57 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#22823 gt and lt operators appear to be
|
|
|
|
# reversed in ExtractValue() command
|
|
|
|
#
|
|
|
|
set @xml= "<entry><id>pt10</id><pt>10</pt></entry><entry><id>pt50</id><pt>50</pt></entry>";
|
|
|
|
select ExtractValue(@xml, "/entry[(pt=10)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt!=10)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt<10)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt<=10)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt>10)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt>=10)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt=50)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt!=50)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt<50)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt<=50)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt>50)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(pt>=50)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(10=pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(10!=pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(10>pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(10>=pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(10<pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(10<=pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(50=pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(50!=pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(50>pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(50>=pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(50<pt)]/id");
|
|
|
|
select ExtractValue(@xml, "/entry[(50<=pt)]/id");
|
2006-12-27 15:14:28 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug#24747 XPath error with the node name "Text"
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Test nodetypes in node name context
|
|
|
|
#
|
|
|
|
select ExtractValue('<a><b><Text>test</Text></b></a>','/a/b/Text');
|
|
|
|
select ExtractValue('<a><b><comment>test</comment></b></a>','/a/b/comment');
|
|
|
|
select ExtractValue('<a><b><node>test</node></b></a>','/a/b/node');
|
|
|
|
select ExtractValue('<a><b><processing-instruction>test</processing-instruction></b></a>','/a/b/processing-instruction');
|
|
|
|
#
|
|
|
|
# Test keywords in node name contexts
|
|
|
|
#
|
|
|
|
select ExtractValue('<a><and>test</and></a>', '/a/and');
|
|
|
|
select ExtractValue('<a><or>test</or></a>', '/a/or');
|
|
|
|
select ExtractValue('<a><mod>test</mod></a>', '/a/mod');
|
|
|
|
select ExtractValue('<a><div>test</div></a>', '/a/div');
|
|
|
|
select ExtractValue('<a><and:and>test</and:and></a>', '/a/and:and');
|
|
|
|
select ExtractValue('<a><or:or>test</or:or></a>', '/a/or:or');
|
|
|
|
select ExtractValue('<a><mod:mod>test</mod:mod></a>', '/a/mod:mod');
|
|
|
|
select ExtractValue('<a><div:div>test</div:div></a>', '/a/div:div');
|
|
|
|
#
|
|
|
|
# Test axis names in node name context
|
|
|
|
#
|
|
|
|
select ExtractValue('<a><ancestor>test</ancestor></a>', '/a/ancestor');
|
|
|
|
select ExtractValue('<a><ancestor-or-self>test</ancestor-or-self></a>', '/a/ancestor-or-self');
|
|
|
|
select ExtractValue('<a><attribute>test</attribute></a>', '/a/attribute');
|
|
|
|
select ExtractValue('<a><child>test</child></a>', '/a/child');
|
|
|
|
select ExtractValue('<a><descendant>test</descendant></a>', '/a/descendant');
|
|
|
|
select ExtractValue('<a><descendant-or-self>test</descendant-or-self></a>', '/a/descendant-or-self');
|
|
|
|
select ExtractValue('<a><following>test</following></a>', '/a/following');
|
|
|
|
select ExtractValue('<a><following-sibling>test</following-sibling></a>', '/a/following-sibling');
|
|
|
|
select ExtractValue('<a><namespace>test</namespace></a>', '/a/namespace');
|
|
|
|
select ExtractValue('<a><parent>test</parent></a>', '/a/parent');
|
|
|
|
select ExtractValue('<a><preceding>test</preceding></a>', '/a/preceding');
|
|
|
|
select ExtractValue('<a><preceding-sibling>test</preceding-sibling></a>', '/a/preceding-sibling');
|
|
|
|
select ExtractValue('<a><self>test</self></a>', '/a/self');
|