Bug #24747 XPath error with the node name "Text"
Submitted: 1 Dec 2006 9:35 Modified: 9 Mar 2007 4:52
Reporter: Alexander Barkov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: XML functions Severity:S3 (Non-critical)
Version:5.1.14-BK OS:Linux (Linux)
Assigned to: Alexander Barkov CPU Architecture:Any

[1 Dec 2006 9:35] Alexander Barkov
Description:
clay_croft wrote on the XML forum:
http://forums.mysql.com/read.php?44,123018,123018#msg-123018

> Hi, I encountered a problem when I use MySql to read XML string. The word
> "Text" seems to be reserved in MySql. So expressions like 
> extractvalue(xml_string, "a/b/Text") cannot get executed. I would think
> this is
> quite restrictive because it is fairly common to use "Text" as the name of an 
> XML element. Would you guys correct this in the next release?

This looks like a bug.

How to repeat:
mysql> select ExtractValue('<a><b><Txt>test</Txt></b></a>','/a/b/Txt');
+----------------------------------------------------------+
| ExtractValue('<a><b><Txt>test</Txt></b></a>','/a/b/Txt') |
+----------------------------------------------------------+
| test                                                     |
+----------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select ExtractValue('<a><b><Text>test</Text></b></a>','/a/b/Text');
ERROR 1105 (HY000): XPATH syntax error: ''

It also happens with other tag names which are XPath keywords:

mysql> select ExtractValue('<a><b><comment>test</comment></b></a>','/a/b/comment');
ERROR 1105 (HY000): XPATH syntax error: ''

mysql> select ExtractValue('<a><b><node>test</node></b></a>','/a/b/node');
ERROR 1105 (HY000): XPATH syntax error: ''

mysql> select ExtractValue('<a><b><processing-instruction>test</processing-instruction></b></a>','/a/b/processing-instruction');
ERROR 1105 (HY000): XPATH syntax error: ''

mysql> select ExtractValue('<a><b><self>test</self></b></a>','/a/b/self');
ERROR 1105 (HY000): XPATH syntax error: ''

Suggested fix:
Allow to refer to tags, even if their names coincide with XPath keywords.
[1 Dec 2006 15:06] Valeriy Kravchuk
Thank you for a problem report. Verified just as described with 5.1.14-BK on Linux:

mysql> select ExtractValue('<a><b><Txt>test</Txt></b></a>','/a/b/Txt');
+----------------------------------------------------------+
| ExtractValue('<a><b><Txt>test</Txt></b></a>','/a/b/Txt') |
+----------------------------------------------------------+
| test                                                     |
+----------------------------------------------------------+
1 row in set (0.01 sec)

mysql> select ExtractValue('<a><b><Text>test</Text></b></a>','/a/b/Text');
ERROR 1105 (HY000): XPATH syntax error: ''
mysql> select
    -> ExtractValue('<a><b><comment>test</comment></b></a>','/a/b/comment');
ERROR 1105 (HY000): XPATH syntax error: ''
mysql>  select ExtractValue('<a><b><node>test</node></b></a>','/a/b/node');
ERROR 1105 (HY000): XPATH syntax error: ''
mysql> select ExtractValue('<a><b><self>test</self></b></a>','/a/b/self');
ERROR 1105 (HY000): XPATH syntax error: ''
mysql> select version();
+-------------+
| version()   |
+-------------+
| 5.1.14-beta |
+-------------+
1 row in set (0.01 sec)
[27 Dec 2006 14:09] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/17414
[8 Mar 2007 8:15] Andrei Elkin
pushed to 5.1.17-beta
[9 Mar 2007 4:52] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix in 5.1.17 changelog.