List:Commits« Previous MessageNext Message »
From:jon Date:November 29 2007 1:38pm
Subject:svn commit - mysqldoc@docsrva: r8977 - in trunk: refman-5.1 refman-6.0
View as plain text  
Author: jstephens
Date: 2007-11-29 14:38:08 +0100 (Thu, 29 Nov 2007)
New Revision: 8977

Log:

Updated discussion of 5.1/6.0 XPath support (Thanks, Bar!):

  | = logical UNION, not OR

  logical or can be used inside predicates

  relative paths are supported, including within predicates



Modified:
   trunk/refman-5.1/functions-core.xml
   trunk/refman-6.0/functions-core.xml


Modified: trunk/refman-5.1/functions-core.xml
===================================================================
--- trunk/refman-5.1/functions-core.xml	2007-11-29 13:07:30 UTC (rev 8976)
+++ trunk/refman-5.1/functions-core.xml	2007-11-29 13:38:08 UTC (rev 8977)
Changed blocks: 3, Lines Added: 59, Lines Deleted: 11; 3875 bytes

@@ -13559,11 +13559,11 @@
 
       <listitem>
         <para>
-          Multiple locators may be matched using the
-          <literal>|</literal> (logical <literal>OR</literal>) operator.
-          For example, the expression <literal>//b|//c</literal> matches
-          all <replaceable>b</replaceable> and
-          <replaceable>c</replaceable> elements in the XML target.
+          You can match any of several locators using the
+          <literal>|</literal> (<literal>UNION</literal>) operator. For
+          example, the expression <literal>//b|//c</literal> matches all
+          <replaceable>b</replaceable> and <replaceable>c</replaceable>
+          elements in the XML target.
         </para>
       </listitem>
 

@@ -13591,14 +13591,24 @@
         </para>
 
         <para>
-          To find elements for which the same attribute matches one of
-          several values, you must use multiple locators joined by the
+          To find elements for which the same attribute matches any of
+          several values, you can use multiple locators joined by the
           <literal>|</literal> operator. For example, to match all
           <replaceable>b</replaceable> elements whose
           <replaceable>c</replaceable> attributes have either of the
           values 23 or 17, use the expression
-          <literal>//b[@c="23"]|b[@c="17"]</literal>.
+          <literal>//b[@c="23"]|//b[@c="17"]</literal>. You can also use
+          the logical <literal>or</literal> operator for this purpose:
+          <literal>//b[@c="23" or @c="17"]</literal>.
         </para>
+
+        <note>
+          <para>
+            The difference between <literal>or</literal> and
+            <literal>|</literal> is that <literal>or</literal> joins
+            conditions, while <literal>|</literal> joins result sets.
+          </para>
+        </note>
       </listitem>
 
     </itemizedlist>

@@ -13645,10 +13655,48 @@
 
           <listitem>
             <para>
-              Relative locator expressions are not supported. XPath
-              expressions must begin with <literal>/</literal> or
-              <literal>//</literal>.
+              Relative locator expressions are resolved in the context
+              of the root node. For example, consider the following
+              query and result:
+
+<programlisting>
+mysql&gt; <userinput>SELECT ExtractValue(</userinput>
+    -&gt;   <userinput>'&lt;a&gt;&lt;b c="1"&gt;X&lt;/b&gt;&lt;b c="2"&gt;Y&lt;/b&gt;&lt;/a&gt;',</userinput> 
+    -&gt;    <userinput>'a/b'</userinput>
+    -&gt; <userinput>) AS result;</userinput>
++--------+
+| result |
++--------+
+| X Y    |
++--------+
+1 row in set (0.03 sec)
+</programlisting>
+
+              In this case, the locator <literal>a/b</literal> resolves
+              to <literal>/a/b</literal>.
             </para>
+
+            <para>
+              Relative locators are also supported within predicates. In
+              the following example, <literal>d[../@c="1"]</literal> is
+              resolved as <literal>/a/b[@c="1"]/d</literal>:
+
+<programlisting>
+mysql&gt; <userinput>SELECT ExtractValue(</userinput>
+    -&gt;      <userinput>'&lt;a&gt;</userinput>
+    -&gt;        <userinput>&lt;b c="1"&gt;&lt;d&gt;X&lt;/d&gt;&lt;/b&gt;</userinput>
+    -&gt;        <userinput>&lt;b c="2"&gt;&lt;d&gt;X&lt;/d&gt;&lt;/b&gt;</userinput>
+    -&gt;      <userinput>&lt;/a&gt;',</userinput> 
+    -&gt;      <userinput>'a/b/d[../@c="1"]')</userinput> 
+    -&gt; <userinput>AS result;</userinput>
++--------+
+| result |
++--------+
+| X      |
++--------+
+1 row in set (0.00 sec)
+</programlisting>
+            </para>
           </listitem>
 
           <listitem>


Modified: trunk/refman-6.0/functions-core.xml
===================================================================
--- trunk/refman-6.0/functions-core.xml	2007-11-29 13:07:30 UTC (rev 8976)
+++ trunk/refman-6.0/functions-core.xml	2007-11-29 13:38:08 UTC (rev 8977)
Changed blocks: 3, Lines Added: 59, Lines Deleted: 11; 3875 bytes

@@ -13500,11 +13500,11 @@
 
       <listitem>
         <para>
-          Multiple locators may be matched using the
-          <literal>|</literal> (logical <literal>OR</literal>) operator.
-          For example, the expression <literal>//b|//c</literal> matches
-          all <replaceable>b</replaceable> and
-          <replaceable>c</replaceable> elements in the XML target.
+          You can match any of several locators using the
+          <literal>|</literal> (<literal>UNION</literal>) operator. For
+          example, the expression <literal>//b|//c</literal> matches all
+          <replaceable>b</replaceable> and <replaceable>c</replaceable>
+          elements in the XML target.
         </para>
       </listitem>
 

@@ -13532,14 +13532,24 @@
         </para>
 
         <para>
-          To find elements for which the same attribute matches one of
-          several values, you must use multiple locators joined by the
+          To find elements for which the same attribute matches any of
+          several values, you can use multiple locators joined by the
           <literal>|</literal> operator. For example, to match all
           <replaceable>b</replaceable> elements whose
           <replaceable>c</replaceable> attributes have either of the
           values 23 or 17, use the expression
-          <literal>//b[@c="23"]|b[@c="17"]</literal>.
+          <literal>//b[@c="23"]|//b[@c="17"]</literal>. You can also use
+          the logical <literal>or</literal> operator for this purpose:
+          <literal>//b[@c="23" or @c="17"]</literal>.
         </para>
+
+        <note>
+          <para>
+            The difference between <literal>or</literal> and
+            <literal>|</literal> is that <literal>or</literal> joins
+            conditions, while <literal>|</literal> joins result sets.
+          </para>
+        </note>
       </listitem>
 
     </itemizedlist>

@@ -13583,10 +13593,48 @@
 
           <listitem>
             <para>
-              Relative locator expressions are not supported. XPath
-              expressions must begin with <literal>/</literal> or
-              <literal>//</literal>.
+              Relative locator expressions are resolved in the context
+              of the root node. For example, consider the following
+              query and result:
+
+<programlisting>
+mysql&gt; <userinput>SELECT ExtractValue(</userinput>
+    -&gt;   <userinput>'&lt;a&gt;&lt;b c="1"&gt;X&lt;/b&gt;&lt;b c="2"&gt;Y&lt;/b&gt;&lt;/a&gt;',</userinput> 
+    -&gt;    <userinput>'a/b'</userinput>
+    -&gt; <userinput>) AS result;</userinput>
++--------+
+| result |
++--------+
+| X Y    |
++--------+
+1 row in set (0.03 sec)
+</programlisting>
+
+              In this case, the locator <literal>a/b</literal> resolves
+              to <literal>/a/b</literal>.
             </para>
+
+            <para>
+              Relative locators are also supported within predicates. In
+              the following example, <literal>d[../@c="1"]</literal> is
+              resolved as <literal>/a/b[@c="1"]/d</literal>:
+
+<programlisting>
+mysql&gt; <userinput>SELECT ExtractValue(</userinput>
+    -&gt;      <userinput>'&lt;a&gt;</userinput>
+    -&gt;        <userinput>&lt;b c="1"&gt;&lt;d&gt;X&lt;/d&gt;&lt;/b&gt;</userinput>
+    -&gt;        <userinput>&lt;b c="2"&gt;&lt;d&gt;X&lt;/d&gt;&lt;/b&gt;</userinput>
+    -&gt;      <userinput>&lt;/a&gt;',</userinput> 
+    -&gt;      <userinput>'a/b/d[../@c="1"]')</userinput> 
+    -&gt; <userinput>AS result;</userinput>
++--------+
+| result |
++--------+
+| X      |
++--------+
+1 row in set (0.00 sec)
+</programlisting>
+            </para>
           </listitem>
 
           <listitem>


Thread
svn commit - mysqldoc@docsrva: r8977 - in trunk: refman-5.1 refman-6.0jon29 Nov