Author: jstephens
Date: 2007-10-06 13:13:25 +0200 (Sat, 06 Oct 2007)
New Revision: 7997
Log:
Another XPath clarification + example (suggested by Bar - v. Bug #25701)
Modified:
trunk/refman-5.1/functions-core.xml
trunk/refman-5.2/functions-core.xml
Modified: trunk/refman-5.1/functions-core.xml
===================================================================
--- trunk/refman-5.1/functions-core.xml 2007-10-06 10:17:41 UTC (rev 7996)
+++ trunk/refman-5.1/functions-core.xml 2007-10-06 11:13:25 UTC (rev 7997)
Changed blocks: 1, Lines Added: 74, Lines Deleted: 0; 3546 bytes
@@ -13182,6 +13182,80 @@
or
<literal><a><b><c/></b></a></literal>
</para>
+
+ <note>
+ <para>
+ <literal>//<replaceable>tag</replaceable></literal> is the
+ equivalent of
+ <literal>/descendant-or-self::*/<replaceable>tag</replaceable></literal>.
+ A common error is to confuse this with
+ <literal>/descendant-or-self::/<replaceable>tag</replaceable></literal>,
+ although the latter expression can actually lead to very
+ different results, as can be seen here:
+
+<programlisting>
+mysql> <userinput>SET @xml = '<a><b><c>w</c><b>x</b><d>y</d>z</b></a>';</userinput>
+Query OK, 0 rows affected (0.00 sec)
+
+mysql> <userinput>SELECT @xml;</userinput>
++-----------------------------------------+
+| @xml |
++-----------------------------------------+
+| <a><b><c>w</c><b>x</b><d>y</d>z</b></a> |
++-----------------------------------------+
+1 row in set (0.00 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '//b[1]');</userinput>
++------------------------------+
+| ExtractValue(@xml, '//b[1]') |
++------------------------------+
+| x z |
++------------------------------+
+1 row in set (0.00 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '//b[2]');</userinput>
++------------------------------+
+| ExtractValue(@xml, '//b[2]') |
++------------------------------+
+| |
++------------------------------+
+1 row in set (0.01 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '/descendant-or-self::*/b[1]');</userinput>
++---------------------------------------------------+
+| ExtractValue(@xml, '/descendant-or-self::*/b[1]') |
++---------------------------------------------------+
+| x z |
++---------------------------------------------------+
+1 row in set (0.06 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '/descendant-or-self::*/b[2]');</userinput>
++---------------------------------------------------+
+| ExtractValue(@xml, '/descendant-or-self::*/b[2]') |
++---------------------------------------------------+
+| |
++---------------------------------------------------+
+1 row in set (0.00 sec)
+
+
+mysql> <userinput>SELECT ExtractValue(@xml, '/descendant-or-self::b[1]');</userinput>
++-------------------------------------------------+
+| ExtractValue(@xml, '/descendant-or-self::b[1]') |
++-------------------------------------------------+
+| z |
++-------------------------------------------------+
+1 row in set (0.00 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '/descendant-or-self::b[2]');</userinput>
++-------------------------------------------------+
+| ExtractValue(@xml, '/descendant-or-self::b[2]') |
++-------------------------------------------------+
+| x |
++-------------------------------------------------+
+1 row in set (0.00 sec)
+</programlisting>
+ </para>
+ </note>
</listitem>
<listitem>
Modified: trunk/refman-5.2/functions-core.xml
===================================================================
--- trunk/refman-5.2/functions-core.xml 2007-10-06 10:17:41 UTC (rev 7996)
+++ trunk/refman-5.2/functions-core.xml 2007-10-06 11:13:25 UTC (rev 7997)
Changed blocks: 1, Lines Added: 74, Lines Deleted: 0; 3546 bytes
@@ -13146,6 +13146,80 @@
or
<literal><a><b><c/></b></a></literal>
</para>
+
+ <note>
+ <para>
+ <literal>//<replaceable>tag</replaceable></literal> is the
+ equivalent of
+ <literal>/descendant-or-self::*/<replaceable>tag</replaceable></literal>.
+ A common error is to confuse this with
+ <literal>/descendant-or-self::/<replaceable>tag</replaceable></literal>,
+ although the latter expression can actually lead to very
+ different results, as can be seen here:
+
+<programlisting>
+mysql> <userinput>SET @xml = '<a><b><c>w</c><b>x</b><d>y</d>z</b></a>';</userinput>
+Query OK, 0 rows affected (0.00 sec)
+
+mysql> <userinput>SELECT @xml;</userinput>
++-----------------------------------------+
+| @xml |
++-----------------------------------------+
+| <a><b><c>w</c><b>x</b><d>y</d>z</b></a> |
++-----------------------------------------+
+1 row in set (0.00 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '//b[1]');</userinput>
++------------------------------+
+| ExtractValue(@xml, '//b[1]') |
++------------------------------+
+| x z |
++------------------------------+
+1 row in set (0.00 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '//b[2]');</userinput>
++------------------------------+
+| ExtractValue(@xml, '//b[2]') |
++------------------------------+
+| |
++------------------------------+
+1 row in set (0.01 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '/descendant-or-self::*/b[1]');</userinput>
++---------------------------------------------------+
+| ExtractValue(@xml, '/descendant-or-self::*/b[1]') |
++---------------------------------------------------+
+| x z |
++---------------------------------------------------+
+1 row in set (0.06 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '/descendant-or-self::*/b[2]');</userinput>
++---------------------------------------------------+
+| ExtractValue(@xml, '/descendant-or-self::*/b[2]') |
++---------------------------------------------------+
+| |
++---------------------------------------------------+
+1 row in set (0.00 sec)
+
+
+mysql> <userinput>SELECT ExtractValue(@xml, '/descendant-or-self::b[1]');</userinput>
++-------------------------------------------------+
+| ExtractValue(@xml, '/descendant-or-self::b[1]') |
++-------------------------------------------------+
+| z |
++-------------------------------------------------+
+1 row in set (0.00 sec)
+
+mysql> <userinput>SELECT ExtractValue(@xml, '/descendant-or-self::b[2]');</userinput>
++-------------------------------------------------+
+| ExtractValue(@xml, '/descendant-or-self::b[2]') |
++-------------------------------------------------+
+| x |
++-------------------------------------------------+
+1 row in set (0.00 sec)
+</programlisting>
+ </para>
+ </note>
</listitem>
<listitem>
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r7997 - in trunk: refman-5.1 refman-5.2 | jon | 6 Oct |