<?vsp 
--  
--  $Id: faq.vsp,v 1.2.2.1 2012/03/08 12:55:05 source Exp $
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2012 OpenLink Software
--  
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--  
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--  
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--  
--  
?>
<HTML>
<BODY TEXT="#000000" LINK="#0000CC" VISITED="#3300CC" BGCOLOR="#EEEEEE" TOPMARGIN=0>
<P><B>Use case 1.6.4.1 have odd results format. Why are the two results separated that way?</B><BR>
It is not a bug, but feature :)
For some sorts of queries, it is possible to build partial results without waiting for the end of processing.
The most common sample is XPATH expression compiled as XQuery expression.
For given XPATH Virtuoso can usually iterate a sequence of matched nodes of the document, not the whole result at once.
E.g. if application knows that there's only one &lt;abstract&gt; tag inside &lt;chapter&gt; tag
then it may fetch the first result of <FONT SIZE="+1" COLOR="#006600"><CODE>$doc/chapter//abstract</CODE></FONT> without the redundant search through the rest of the entity.
Exactly the same functionality is provided for XQuery.
Application may ask either for n-th answer of the sequence or for the whole sequence at once.
To get the whole sequence as one answer, use list() XPATH function.
</P>
<P><B>Some output XMLs contain large number of identical namespace declarations.
Is it possible to make them more readable?</B><BR>
Sometimes it may be done by adding declarations of most &quot;popular&quot;
namespaces into tag of the outermost element of the resulting XML,
but there are no universal methods. Partially, it will not work if
document() XPATH function is used to build some parts of the result.
In real applications, Virtuoso's built-in XSLT processor may be used
to make output XML more readable.
</P>
<P><B>In Virtuoso, XPATH expressions may contain free-text search criteria.
Is this functionality available in XQuery?</B><BR>
Yes, because any free-text search operations may be performed
in PL/SQL procedures called from XQuery.
From other side, XQuery may be called after xcontains() in SELECT statement,
e.g.
<BLOCKQUOTE><FONT SIZE="+1" COLOR="#006600"><CODE>
select<BR>
&nbsp;&nbsp;LIBRARY.ARTICLE_ID as HIT_ID,<BR>
&nbsp;&nbsp;xquery_eval('&lt;hit&gt;{title,authors}&lt;/hit&gt;', FREETEXT_HIT) as HIT_DATA<BR>
from LIBRARY<BR>
where<BR>
&nbsp;&nbsp;xcontains(<BR>
&nbsp;&nbsp;&nbsp;&nbsp;'article[text-contains(abstract,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;''(&quot;search&quot; or &quot;sort*&quot;) and not &quot;bubble* sort*&quot;)'')]',<BR>
&nbsp;&nbsp;&nbsp;&nbsp;ARTICLES.ARTICLE_XML,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;0,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;FREETEXT_HIT<BR>
&nbsp;&nbsp;&nbsp;&nbsp;)<BR>
&nbsp;&nbsp;and<BR>
&nbsp;&nbsp;ARTICLES.ARTICLE_PUBLISHING_DATE >= '2000-01-01'</CODE></FONT></BLOCKQUOTE>
will return title information about all fresh articles related to searching and sorting
except those related to bubble sorting.
</P>
<P><B>Some XPATH functions must process the first node of given node-set,
and XPATH standard says that &quot;first&quot; means &quot;first in document order&quot;.
Why are they process the &quot;first found node&quot; in Virtuoso's XQuery?</B><BR>
The old XPATH rule is senseless if nodes of the node-set are retrieved from more than one document
and/or are created inside the query.
Moreover, sequence of XQuery values may be a mix of nodes and values of other types.
For compartibility, XQuery processor tries to follow old rule while it it cheap in terms of speed and consumed memory;
e.g. it matches old rules for all use cases of this demo.
In real applications, filtering may be
improved in the query in order to get only one node but not the redundant
node-set.
</P>
</BODY>
</HTML>

