// versus /*/

Monday, 7 October 2019 · 3 messages
T
thufir7 Oct 2019 08:28 #
Do these have the same meaning? Might there be a subtle distinction, or might they be read differently but functionally identical?
Quoted text · 2 lines
> > xquery /*/book[@id="bk112"]
<book id="bk112">
   <author>Galos, Mike</author>
   <title>Visual Studio 7: A Comprehensive Guide</title>
   <genre>Computer</genre>
   <price>49.95</price>
   <publish_date>2001-04-16</publish_date>
   <description>Microsoft Visual Studio 7 is explored in depth,
       looking at how Visual Basic, Visual C++, C#, and ASP+ are
       integrated into a comprehensive development
       environment.</description>
</book>
Query executed in 1.22 ms.
Quoted text · 2 lines
> > xquery //book[@id="bk112"]/title
<title>Visual Studio 7: A Comprehensive Guide</title> Query executed in 1.52 ms.
Quoted text · 2 lines
> > xquery /*/book[@id="bk112"]/title
<title>Visual Studio 7: A Comprehensive Guide</title> Query executed in 1.67 ms.
Quoted text · 1 line
>
They're equally efficient, at least as used above? thanks, Thufir
LQ
Liam R. E. Quin7 Oct 2019 11:25 #
Quoted text · thufir · 4 lines
On Sun, 2019-10-06 at 21:28 -0700, thufir wrote: > Do these have the same meaning? Might there be a subtle distinction, > or > might they be read differently but functionally identical?
Are we doing your homework? :-) :-) //* is the same as /descendant-or-self::* //book means, search the whole database to find "book" elements. /*/book meeans make a list of all children of the top-level node, and find book elements that are children of items in that list.
So, given
  <boy><reading><a><book>
    </book></a></reading></boy>
//book will find one node, and /*/book won't find any.
Quoted text · thufir · 1 line
> They're equally efficient, at least as used above?
They are doing different things. To measure efficiency, use a much larger database than the XQuery use cases example :) You may find Priscilla Walmsley's XQuery book helpful in learning XPath version 3. Best, Liam
-- Liam Quin, https://www.delightfulcomputing.com/ Available for XML/Document/Information Architecture/XSLT/ XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
T
thufir7 Oct 2019 14:34 #
Thanks, Liam. No, not homework, just me futzing about. I'll experiment a bit more -- and thanks for the suggestion. -Thufir
Quoted text · thufir · 31 lines
On 2019-10-07 12:25 a.m., Liam R. E. Quin wrote: > On Sun, 2019-10-06 at 21:28 -0700, thufir wrote: >> Do these have the same meaning? Might there be a subtle distinction, >> or >> might they be read differently but functionally identical? > > Are we doing your homework? :-) :-) > > //* is the same as /descendant-or-self::* > //book means, search the whole database to find "book" elements. > > > /*/book meeans make a list of all children of the top-level node, and > find book elements that are children of items in that list. > > So, given > <boy><reading><a><book> > </book></a></reading></boy> > //book will find one node, and /*/book won't find any. > >> They're equally efficient, at least as used above? > They are doing different things. To measure efficiency, use a much > larger database than the XQuery use cases example :) > > You may find Priscilla Walmsley's XQuery book helpful in learning XPath > version 3. > > Best, > > Liam >

⚡Generated with XQuery