List:Commits« Previous MessageNext Message »
From:jon Date:October 6 2007 11:13am
Subject:svn commit - mysqldoc@docsrva: r7997 - in trunk: refman-5.1 refman-5.2
View as plain text  
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>&lt;a&gt;&lt;b&gt;&lt;c/&gt;&lt;/b&gt;&lt;/a&gt;</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&gt; <userinput>SET @xml = '&lt;a&gt;&lt;b&gt;&lt;c&gt;w&lt;/c&gt;&lt;b&gt;x&lt;/b&gt;&lt;d&gt;y&lt;/d&gt;z&lt;/b&gt;&lt;/a&gt;';</userinput>
+Query OK, 0 rows affected (0.00 sec)
+
+mysql&gt; <userinput>SELECT @xml;</userinput>
++-----------------------------------------+
+| @xml                                    |
++-----------------------------------------+
+| &lt;a&gt;&lt;b&gt;&lt;c&gt;w&lt;/c&gt;&lt;b&gt;x&lt;/b&gt;&lt;d&gt;y&lt;/d&gt;z&lt;/b&gt;&lt;/a&gt; |
++-----------------------------------------+
+1 row in set (0.00 sec)
+
+mysql&gt; <userinput>SELECT ExtractValue(@xml, '//b[1]');</userinput>
++------------------------------+
+| ExtractValue(@xml, '//b[1]') |
++------------------------------+
+| x z                          |
++------------------------------+
+1 row in set (0.00 sec)
+
+mysql&gt; <userinput>SELECT ExtractValue(@xml, '//b[2]');</userinput>
++------------------------------+
+| ExtractValue(@xml, '//b[2]') |
++------------------------------+
+|                              |
++------------------------------+
+1 row in set (0.01 sec)
+
+mysql&gt; <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&gt; <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&gt; <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&gt; <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>&lt;a&gt;&lt;b&gt;&lt;c/&gt;&lt;/b&gt;&lt;/a&gt;</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&gt; <userinput>SET @xml = '&lt;a&gt;&lt;b&gt;&lt;c&gt;w&lt;/c&gt;&lt;b&gt;x&lt;/b&gt;&lt;d&gt;y&lt;/d&gt;z&lt;/b&gt;&lt;/a&gt;';</userinput>
+Query OK, 0 rows affected (0.00 sec)
+
+mysql&gt; <userinput>SELECT @xml;</userinput>
++-----------------------------------------+
+| @xml                                    |
++-----------------------------------------+
+| &lt;a&gt;&lt;b&gt;&lt;c&gt;w&lt;/c&gt;&lt;b&gt;x&lt;/b&gt;&lt;d&gt;y&lt;/d&gt;z&lt;/b&gt;&lt;/a&gt; |
++-----------------------------------------+
+1 row in set (0.00 sec)
+
+mysql&gt; <userinput>SELECT ExtractValue(@xml, '//b[1]');</userinput>
++------------------------------+
+| ExtractValue(@xml, '//b[1]') |
++------------------------------+
+| x z                          |
++------------------------------+
+1 row in set (0.00 sec)
+
+mysql&gt; <userinput>SELECT ExtractValue(@xml, '//b[2]');</userinput>
++------------------------------+
+| ExtractValue(@xml, '//b[2]') |
++------------------------------+
+|                              |
++------------------------------+
+1 row in set (0.01 sec)
+
+mysql&gt; <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&gt; <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&gt; <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&gt; <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.2jon6 Oct