<!-- note: need to add all termdefs, otherwise termrefs dont work : but XQ contains dupes of termdefs in intro --><!-- SB 2004-01-28: added entities date.day thru ndash, removed "xpath-backwards-compat", "errors", "XQ" --><spec xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax" id="spec-top" w3c-doctype="wd">
<header>
<title>XQuery 1.0 and XPath 2.0 Full-Text</title>
<w3c-designation>WD-xquery-full-text-20051103</w3c-designation>
<w3c-doctype>W3C Working Draft</w3c-doctype>
<pubdate>
 <day>3</day>
 <month>November</month>
 <year>2005</year>
</pubdate>

<publoc>
   <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/2005/WD-xquery-full-text-20051103/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/2005/WD-xquery-full-text-20051103/</loc>
</publoc>

<altlocs>
   <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/2005/WD-xquery-full-text-20051103/full-text.xml" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">XML</loc>
</altlocs>

<latestloc>
  <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/xquery-full-text/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/xquery-full-text/</loc>
</latestloc>

<prevlocs>
  <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/2005/WD-xquery-full-text-20050915/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/2005/WD-xquery-full-text-20050915/</loc>
  <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/2005/WD-xquery-full-text-20050404/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/2005/WD-xquery-full-text-20050404/</loc>
  <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/2004/WD-xquery-full-text-20040709/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/2004/WD-xquery-full-text-20040709/</loc>
</prevlocs>

<authlist>
<author>
	<name>Sihem Amer-Yahia</name>
	<affiliation>AT&amp;T Labs - Research</affiliation>
	<email xmlns:xlink="http://www.w3.org/1999/xlink" href="mailto:sihem@research.att.com" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">sihem@research.att.com</email>
</author>
<author>
	<name>Chavdar Botev</name>
	<affiliation>Invited Expert</affiliation>
	<email xmlns:xlink="http://www.w3.org/1999/xlink" href="mailto:cbotev@cs.cornell.edu" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">cbotev@cs.cornell.edu</email>
</author>
<author>
	<name>Stephen Buxton</name>
	<affiliation>Oracle Corporation</affiliation>
	<email xmlns:xlink="http://www.w3.org/1999/xlink" href="mailto:stephen.buxton@oracle.com" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">stephen.buxton@oracle.com</email>
</author>
<author>
	<name>Pat Case</name>
	<affiliation>Library of Congress</affiliation>
	<email xmlns:xlink="http://www.w3.org/1999/xlink" href="mailto:pcase@crs.loc.gov" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">pcase@crs.loc.gov</email>
</author>
<author>
        <name>Jochen Doerre</name>
        <affiliation>IBM</affiliation>
        <email xmlns:xlink="http://www.w3.org/1999/xlink" href="mailto:doerre@de.ibm.com" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">doerre@de.ibm.com</email>
</author>
<author>
	<name>Darin McBeath</name>
	<affiliation>Elsevier</affiliation>
	<email xmlns:xlink="http://www.w3.org/1999/xlink" href="mailto:D.McBeath@elsevier.com" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">D.McBeath@elsevier.com</email>
</author>
<author>
	<name>Michael Rys</name>
	<affiliation>Microsoft</affiliation>
	<email xmlns:xlink="http://www.w3.org/1999/xlink" href="mailto:mrys@microsoft.com" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">mrys@microsoft.com</email>
</author>
<author>
	<name>Jayavel Shanmugasundaram</name>
	<affiliation>Invited Expert</affiliation>
	<email xmlns:xlink="http://www.w3.org/1999/xlink" href="mailto:jai@cs.cornell.edu" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">jai@cs.cornell.edu</email>
</author>
</authlist>

<abstract>
<p>This document defines the syntax and formal semantics of XQuery 1.0 and XPath 2.0 Full-Text
which is a language that extends XQuery 1.0 <bibref ref="xquery"/> and XPath 2.0 <bibref ref="xpath20"/> with full-text search capabilities.</p>
</abstract>


<status>
<p><emph>This section describes the status of this document at the
time of its publication. Other documents may supersede this
document. A list of current W3C publications and the latest revision
of this technical report can be found in the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">W3C technical reports index</loc> at
http://www.w3.org/TR/.</emph></p>

<p>This document has been produced
following the procedures set out for the W3C Process. This document
was produced through the efforts of <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/XML/Query" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">XML Query Working Group </loc> and
the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/Style/XSL/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"> XSL Working Group </loc>
(both part of the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/XML/Activity.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"> XML
Activity</loc>). It is designed to be read in conjunction with the
following documents: W3C XQuery and XPath Full-Text Requirements
<bibref ref="xqueryft-requirements"/> and the W3C XQuery Full-Text Use
Cases <bibref ref="xmlquery-full-text-use-cases"/>.</p>

<p>
This is the fourth version of this document. Since the last version
was published, several technical and editorial changes have been made
to all the sections of the document. Among the most significant
changes are: a reformulation of FTIgnore, including alignment of the
specifications in Section 3 and Section 4; a more complete
normalization of the rules for matching, significantly simplifying
the behavior; a thorough pass through the entire document to correct
grammar, spelling, and punctuation, resulting in significantly higher
document quality; the distance between sentences and between
paragraphs has been respecified to align with the distance between
words (that is, adjacent sentences or paragraphs now have a distance
between them of zero sentences or paragraphs, respectively); and the
addition of two new appendices, one summarizing the error codes used
in the Full-Text document and the other summarizing all items
specified in the document to be implementation-defined.</p>

<p>The text of the XQuery functions used to define the semantics have
not been completely syntax checked; that continues to be an on-going activity.
</p>

<p>This is a public W3C Working Draft for review by W3C members and
other interested parties. Publication as a Working Draft does not
imply endorsement by the W3C Membership. This is a draft document and
may be updated, replaced or obsoleted by other documents at any
time. It is inappropriate to cite this document as other than work in
progress.</p>

<!-- 20050905 JM: Removed paragraph re: instability/risk per Paul Cotton review -->
<!-- 20050905 JM: Moved paragraph re: functions/syntax check per Paul Cotton review -->

<p>Public comments on this document and its
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ft-issues" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">open issues</loc> are invited.
Comments should be entered into the
last-call issue tracking system for this specification (instructions
can be found at
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/XML/2005/04/qt-bugzilla" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/XML/2005/04/qt-bugzilla</loc>). 
If access to that system is not feasible, you may send your
comments to the W3C mailing list,
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="mailto:public-qt-comments@w3.org" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">public-qt-comments@w3.org</loc>
(<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Public/public-qt-comments/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
http://lists.w3.org/Archives/Public/public-qt-comments/</loc>) with
"[FT]" at the beginning of the subject field of email messages
involving such comments.</p>

<p>The patent policy for this document is specified in the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/Consortium/Patent-Policy-20040205/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">5 February
2004 W3C Patent Policy</loc>. Patent disclosures
relevant to this specification may be found on the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/2002/08/xmlquery-IPR-statements" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">XML Query
Working Group's patent disclosure page</loc> and the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/Style/XSL/Disclosures" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">XSL Working Group's
patent disclosure page</loc>. An individual who has actual knowledge
of a patent which the individual believes contains Essential Claim(s)
with respect to this specification should disclose the information in
accordance with <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">section
6 of the W3C Patent Policy</loc>.
</p>

</status>

<langusage>
		<language id="EN">English</language>
		<language id="ebnf">EBNF</language>
</langusage>
	
<revisiondesc>

<p>SA January 2004: First version of document before Feb F2F</p>
<p>SA 26 February 2004: Second version of document before Feb F2F
    meetings.</p>

</revisiondesc>

</header><body>
<!-- *********************************************************************
      Section 1. Introduction
     ********************************************************************* -->

<div1 id="introduction">
  <head>Introduction</head>

  <p>This document defines the language and the formal semantics of
  XQuery 1.0 and XPath 2.0 Full-Text. This language is designed to meet the requirements
  identified in W3C XQuery and XPath Full-Text Requirements
  <bibref ref="xqueryft-requirements"/> and to support the queries in
  the W3C XQuery Full-Text Use Cases <bibref ref="xmlquery-full-text-use-cases"/>. </p> 

  <p>XQuery 1.0 and XPath 2.0 Full-Text extends the syntax and semantics of XQuery 1.0 and
  XPath 2.0. </p>

	<div2 id="tq-ftsearch-xml">
		<head>Full-Text Search and XML</head> 

<p>As XML becomes mainstream, users expect to be able to 
search their XML documents. This requires a standard way to do
full-text search, as well as structured searches, against XML
documents.  A similar requirement for full-text search led ISO to
define the <!-- <loc
href="ftp://sqlstandards.org/SC32/WG4/Progression_Documents/CD/cd-fulltext-2001-05.pdf">SQL/MM-FT
standard</loc>.  --> SQL/MM-FT <bibref ref="sqlmm"/> standard.
SQL/MM-FT <bibref ref="sqlmm"/> defines extensions to SQL to express
full-text searches providing similar functionality as does this full-text
language extension to XQuery 1.0 and XPath 2.0.
</p>

<p>XML documents may contain highly-structured data (numbers, dates),
unstructured data (untagged free-flowing text), and semi-structured
data (text with embedded tags). Where a document contains unstructured
or semi-structured data, it is important to be able to search using
Information Retrieval techniques such as scoring and weighting.</p>

<p>Full-text search is different from substring search in many ways:</p>

<olist>
<item><p>A full-text search searches for words and phrases
rather than substrings. A substring search for news items that contain
the string "lease" will return a news item that contains "Foobar
Corporation releases the 20.9 version ...". A full-text search for the
word "lease" will not. </p>
</item>

<item><p>There is an expectation that a full-text search will support
language-based searches which substring search cannot. An
example of a language-based search is "find me all the news items that
contain a word with the same linguistic stem as "mouse" (finds "mouse"
and "mice"). Another example based on word proximity is "find me all
the news items that contain the words "XML" and
"Query" allowing up to 3 intervening words.</p>
</item>

<item>
<p>Full-text search must address the vagaries and nuances of
language. Search results  are often of varying usefulness. When
you search a web site for cameras that cost less than $100, this
is an exact search.  There is a set of cameras that matches this search,
and a set that does not.  Similarly, when you do a string search across
news items for "mouse", there is only 1 expected result set. When you
do a full-text search for all the news items that contain the
word "mouse", you probably expect to find news items containing the word
"mice", and possibly "rodents", or possibly "computers".  Not
all results are equal. Some results are more "mousey" than others.
Because full-text search may be inexact, we have the notion of score
or relevance. We generally expect to see the most relevant results at
the top of the results list.</p>
<p>As XQuery and XPath evolve, they
 may apply the notion of
score to querying structured data. For example, when making travel
plans or shopping for cameras, it is sometimes useful to get an
ordered list of near matches in addition to exact matches. If
 XQuery and XPath define a generalized 
inexact match, we expect XQuery and XPath to utilize the scoring
framework provided by XQuery and XPath Full-Text.
</p>
</item>
</olist>

<p>The following definitions apply to full-text search:</p>

<olist>

<item>
<p>Full-text queries are performed on text which has been tokenized,
i.e., broken into a sequence of words, units of punctuation, and
spaces.
</p>
</item>

<item>
<p>A word is defined as a character, n-gram, or sequence of
characters returned by a tokenizer as a basic unit to be searched. Each
instance of a word consists of one or more consecutive characters.
Beyond that, words are implementation-defined. Note that consecutive
words need not be separated by either punctuation or space, and words
may overlap. A phrase is a sequence of ordered words which may contain
any number of words.
</p>
</item>

<item>
<p>Tokenization enables functions and operators which work with the
relative positions of words (e.g., proximity operators). It also
uniquely identifies sentences and paragraphs in which words appear.
It enables functions and operators which operate on a
part or the root of the word (e.g., wildcards, stemming). Whatever a
tokenizer for a particular language chooses to do, it must preserve
the containment hierarchy: paragraphs contain sentences which contain
words. The tokenizer has to evaluate two equal strings in the same
way, i.e., it should identify the same tokens. Everything else is 
implementation-defined.
</p>
</item>


<item>
<p>
This specification focuses on functionality that serves all
languages. It also selectively includes functionalities useful within
specific families of languages. For example, searching within
sentences and paragraphs is useful to many western languages and to
some non-western languages, so that functionality is incorporated into
this specification.
</p>
</item>

<item>
<p>
Some XML elements represent semantic
markup, e.g., &lt;title&gt;. Others represent formatting markup, e.g.,
&lt;b&gt; to indicate bold.  Semantic markup serves well as token
boundaries, while formatting markup sometimes does not. Implementations
are free to provide implementation-defined ways to differentiate between 
the markup's effect on token boundaries during tokenization.
</p>
</item>


<!--<item>
<p>We use the namespace "ft" (for full-text) that corresponds to the
URL http://www.w3.org/2004/07/xquery-full-text and defines the namespace of
full-text search. We also use "fts" for definitional purposes in <loc
href="#tq-semantics">semantics Section</loc>.
</p>
</item>
-->

</olist>
</div2>

<div2 id="tq-ft-organization">
 <head>Organization of this document</head> 

<p>This document is organized as follows. We first present a <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#tq-extensions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">high level syntax</loc> for the XQuery 1.0 and XPath 2.0 Full-Text
language along with some examples. Then, we present the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselectionsftmatchoptions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">syntax and examples</loc> of the
basic primitives in the XQuery 1.0 and XPath 2.0 Full-Text language. This is followed by the
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#tq-semantics" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">semantics</loc> of the XQuery 1.0 and XPath 2.0 Full-Text
language. The appendix contains a section that provides an <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#id-xpath-grammar" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">EBNF for the XPath 2.0 Grammar with Full-Text
extensions</loc>, an <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#id-grammar" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">EBNF for XQuery 1.0
Grammar with Full-Text extensions</loc>, a list of <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ft-issues" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">issues</loc>, <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ft-acknowledgements" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">acknowledgements</loc> and a <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ft-glossary" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">glossary</loc>.</p>

	</div2>

<div2 id="tq-ft-namespaces">
  <head>A word about namespaces</head>

<p>Certain namespace prefixes are predeclared by XQuery 1.0 and, by implication, by this specification,
and bound to fixed namespace URIs. These namespace prefixes are as follows:
</p>

<ulist>

<item>
<p>
<code>xml = http://www.w3.org/XML/1998/namespace</code>
</p>
</item>

<item>
<p>
<code>xs = http://www.w3.org/2001/XMLSchema</code>
</p>
</item>

<item>
<p>
<code>xsi = http://www.w3.org/2001/XMLSchema-instance</code>
</p>
</item>

<item>
<p>
<code>fn = http://www.w3.org/2005/xpath-functions</code>
</p>
</item>

<item>
<p>
<code>xdt = http://www.w3.org/2005/xpath-datatypes</code>
</p>
</item>

<item>
<p>
<code>local = http://www.w3.org/2005/xquery-local-functions</code>
</p>
</item>

</ulist>

<p>
In addition to the prefixes in the above list, this document uses the prefix
<code>err</code> to represent the namespace URI <code>http://www.w3.org/2005/xqt-errors</code>, 
This namespace prefix is not predeclared and its use in this document is not normative. 
Error codes that are not defined in this document are defined in other XQuery 1.0 and XPath 2.0
specifications, particularly <bibref ref="xpath20"/> and <bibref ref="xpath-functions"/>. 
</p>

<p>
Finally, this document uses the prefix <code>fts</code> to represent a namespace
containing a number of functions used in this document to describe the semantics
of XQuery 1.0 and XPath 2.0 Full-Text functions. There is no
requirement that these functions be implemented, therefore no URI is associated with that prefix. 
</p>

</div2>
  
</div1>



<!--
2. TeXQuery Expressions
2.1.  FTContainsExpr 
2.2.  Scoring
2.3   Extensions to the Static Context

-->
<div1 id="tq-extensions">
   <head>Full-Text Extensions to XQuery and XPath</head>
<p>XQuery 1.0 and XPath 2.0 Full-Text extends the languages of XQuery
1.0 and XPath 2.0 in three ways. It:</p> 

<olist>
  <item><p>Adds a new expression called FTContainsExpr;</p>

  </item>
  <item><p>Enhances the syntax of FLWOR expressions in XQuery 1.0 and
  <code>for</code> expressions in XPath 2.0 with optional score
  variables; and</p>
  </item>

  <item><p>Adds static context declarations for full-text match
  options to the query prolog.</p>
  </item>
</olist>


   <div2 id="tq-ext-contains">
      <head>Expression FTContainsExpr</head>
<p>XQuery 1.0 and XPath 2.0 Full-Text extends the languages of XQuery
1.0 and XPath 2.0 by adding the expression 
FTContainsExpr. An FTContainsExpr is similar to a
comparison expression (see <xspecref spec="XQ" ref="id-general-comparisons"/>).
This grammar rule introduces FTContainsExpr.</p>


   <scrap headstyle="show">
<head/>
<prodrecap ref="ComparisonExpr" id="no-id_ComparisonExpr"/>

</scrap>
<p>An FTContainsExpr may be used anywhere a ComparisonExpr may be
used. FTContainsExprs have higher precedence than comparison
operators,  so the results of FTContainsExpr may be compared without
enclosing them in parentheses.</p>

<div3 id="tq-ext-contains-description">
      <head>FTContainsExpr Description</head>


<scrap headstyle="show">
<head/>
<prodrecap ref="FTContainsExpr" id="FTContainsExpr"/>
</scrap><p>An FTContainsExpr returns a Boolean
value. It returns true, if there is some node in
RangeExpr that matches FTSelection. For the purpose of determining
a match, certain descendants of nodes in RangeExpr
may be ignored, as specified in 
FTIgnoreOption.</p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelections</loc> are
composed of the following ingredients:</p>

<olist>
   <item><p>Words and phrases that are the strings to
   be found as matches;</p>
   </item>
   <item><p>Match options, such as indicators for case sensitivity and 
   stop words;</p> 
   </item>
   <item><p>Boolean operators, that compose an FTSelection from
   simpler FTSelections; and
      </p>
   </item>
   <item><p>Constraints on the positions of matches, such as 
   indicators for distance between words and for the cardinality of
   matches.</p>
   </item>
</olist>

   </div3>
   <div3 id="tq-ext-contains-examples">
   <head>FTContainsExpr Examples</head>

<p>The following example in extended XQuery 1.0 returns the author of
each book with a title containing a word with the same root as
<code>dog</code> and the word 
<code>cat</code>.

		<eg role="xquery" xml:space="preserve">
for $b in /books/book
where $b/title ftcontains ("dog" with stemming) &amp;&amp; "cat" 
return $b/author</eg>
</p>
		<p>The same example in extended XPath 2.0 is written as:

		<eg role="xpath" xml:space="preserve">

/books/book[title ftcontains ("dog" with stemming) &amp;&amp; "cat"]/author</eg>
</p>
   </div3>

	</div2>

	<div2 id="tq-ext-score">
	<head>Score Variables</head>
	<p>Besides specifying a match of a full-text 
        search as a Boolean condition, full-text search applications
        typically also have the ability to associate scores with
        the results. Such scores express the relevance of
        those results to the full-text search conditions.</p>

        <p>XQuery 1.0 and XPath 2.0 Full-Text extends the languages of
        XQuery 1.0 and XPath 2.0 further  by adding optional 
        <code>score</code> variables to the <code>for</code> and
        <code>let</code> clauses of FLWOR expressions.</p>

        <p>The production for the extended <code>for</code> clause follows.


<scrap headstyle="show">
<head/>
<prodrecap ref="ForClause" id="ForClause"/>
<prodrecap ref="FTScoreVar" id="FTScoreVar"/>
</scrap> 
</p>

<p>When a <code>score</code> variable is present in a <code>for</code> 
clause the evaluation of the expression following the <code>in</code>
keyword not only needs to determine the result sequence of the
expression, i.e., the sequence of items which are iteratively
bound to the <code>for</code> variable. It must also determine in each
iteration the relevance "score" value of the current item
and bind the <code>score</code> variable to that value. </p> 

<p>In the following example <code>book</code> elements are determined that satisfy
the condition <code>[content ftcontains "web site" &amp;&amp; "usability" and
.//chapter/title ftcontains "testing"]</code>. The scores assigned to the
<code>book</code> elements are returned.

		<eg role="xquery" xml:space="preserve">
for $b score $s 
    in /books/book[content ftcontains "web site" &amp;&amp; "usability" 
                   and .//chapter/title ftcontains "testing"]
return $s
</eg>
</p>

<p>XPath 2.0 Full-Text extends the language of XPath
2.0 in the <code>for</code> expression in the same 
way: with optional score variables. The example above is
also a legal example of the XPath 2.0 extension.</p>

<p>Scores are typically used to order results, as in the 
following, more complete example.
		<eg role="xquery" xml:space="preserve">
for $b score $s 
    in /books/book[content ftcontains "web site" &amp;&amp; "usability"]
where $s &gt; 0.5
order by $s descending
return &lt;result&gt;  
          &lt;title&gt; {$b//title} &lt;/title&gt; 
          &lt;score&gt; {$s} &lt;/score&gt; 
       &lt;/result&gt;
</eg>
</p>

<p>The <code>score</code> variable is bound to a value which reflects
the relevance of the match criteria in the 
FTSelections to the nodes in the respective RangeExprs. The
calculation of relevance is implementation-dependent, but score
evaluation must follow these rules:</p>

<olist>
<item><p>Score values are of type xs:float in the range
[0, 1].</p></item> 
<item><p>For score values greater than 0, a higher score must imply a
higher degree of relevance </p></item>
</olist>

<p>Similar to their use in a <code>for</code> clause, score variables
may be specified in a <code>let</code> clause. A score variable in a
<code>let</code> clause is also bound to the score of the expression
evaluation, but in the <code>let</code> clause one score is determined
for the complete result. The <code>let</code> variable may be dropped
from the <code>let</code> clause, if the
<code>score</code> variable is present.</p>

<p>The production for the extended <code>let</code> clause follows.


<scrap headstyle="show">
<head/>
<prodrecap ref="LetClause" id="LetClause"/>
</scrap> 
</p>

<p>While the score option in a <code>for</code> clause conveniently
allows to specify that the filtering expression, which drives the
iteration, is at the same time the expression that determines the
scores, it is possible to separate the filtering from the scoring
expression using the <code>let</code> clause syntax. The following is
an example of this.
		<eg role="xquery" xml:space="preserve">
for $b in /books/book[.//chapter/title ftcontains "testing"]
let score $s := $b/content ftcontains "web site" &amp;&amp; "usability" 
order by $s descending
return &lt;result score="{$s}"&gt;{$b}&lt;/result&gt;
</eg>
This example returns <code>book</code> elements with chapter titles that contain "testing". Along with the <code>book</code> elements scores are returned. These scores, however, reflect whether the book content contains "web site" and "usability".</p>

<p>Note that it is not a requirement of the score of an 
FTContainsExpr to be 0, if the expression evaluates to false, nor to
be non-zero, if the expression evaluates to true.
Hence, in the example above it is not possible to infer the Boolean
value of the FTContainsExpr in the <code>let</code> clause from the
calculated score of a returned <code>result</code> element. For instance, an
implementation may want to assign a non-zero score to a book that
contained only "web site", but not "usability", as this may be
considered more relevant than a book that does not contain either of
both.
</p>




<p>The use of <code>score</code> variables introduces a second-order
aspect to the evaluation of expressions which cannot be emulated by
(first-order) XQuery functions. Consider the following replacement of
the clause <code>let score $s := FTContainsExpr</code></p>

		<eg xml:space="preserve">
let $s := score(FTContainsExpr)
</eg>

<p>where a function <code>score</code> is applied to some
FTContainsExpr. If the function <code>score</code> were first-order, it
would only be applied to the result of the evaluation of 
its argument, which is one of the Boolean constants <code>true</code>
or <code>false</code>. Hence, there would be at most two possible
values such a <code>score</code> function would be able to return and
no further differentiation would be possible. </p>


   <div3 id="tq-ext-using-weights">
      <head>Using Weights Within a Scored FTContainsExpr</head>

<p>Scoring may be influenced by adding weight declarations to
individual search words, phrases, and expressions. Weight declarations
are described in detail in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Section 3.1</loc>.
		<eg role="xquery" xml:space="preserve">
for $b in /books/book
let score $s := $b/content ftcontains ("web site" weight 0.2)
                                  &amp;&amp; ("usability" weight 0.8)
return &lt;result score="{$s}"&gt;{$b}&lt;/result&gt;
</eg>
</p>

<p>The effect of weights on the result score is
implementation-dependent. However, weight declarations must follow
these rules:</p> 
<olist>
<item><p>Weights in an FTContainsExpr are significant only in relation
to each other; and</p></item>
<item><p>When no explicit weight is specified, the default weight is 0.5.</p></item>
</olist>

<p>
Weight declarations in an FTContainsExpr for which no scores are
evaluated are ignored. 
</p>

   </div3>
	</div2>


   <div2 id="tq-ext-static-context">
      <head>Extensions to the Static Context</head>
<p>
The XQuery Static Context is extended by a component for each of the
full-text match options. Thus, the default of a match option in a
query may be changed by providing a setting in the static context using the
following declaration syntax.
<scrap headstyle="show"><head/>
	<prodrecap ref="Prolog" id="Prolog"/>
	<prodrecap ref="FTOptionDecl" id="FTOptionDecl"/>
</scrap>
Match options modify the match semantics of full-text
expressions. They are described in detail in  
Section <specref ref="ftmatchoptions"/>. When a match
option is specified explicitly in a query, that
setting overrides the setting of the respective match option in the
static context.
</p>



   </div2>
</div1>


<div1 id="ftselectionsftmatchoptions">
	<head>FTSelections, FTMatchOptions, and FTIgnoreOption</head>
<div2 id="ftselection">
      <head>FTSelection</head> <p>This section describes <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> which contains the full-text
operators in the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#tq-extensions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTContainsExpr</loc>, and
the match options in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftmatchoptions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTMatchOptions</loc>
which modify the matching semantics of the full-text selection
expressions. </p>

<p>The <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> production
specifies the possible full-text search conditions. </p>

<scrap headstyle="show">
<head/>
<prodrecap ref="FTSelection" id="FTSelection"/>
</scrap>

<p>The syntax and semantics of the individual full-text selection
operators follow.</p>

<div3 id="ftselection-example">
	<head>FTSelection Example</head> <p>This XML document fragment
is the source document for examples in this section. </p>
<p>Tokenization is implementation-defined. A sample tokenization is
used for the example sin this section. The results may be different
for other tokenizations.</p> <p>Unless stated otherwise, the results
assume a case-insensitive match.</p>

 <eg xml:space="preserve">&lt;book number="1"&gt;
  &lt;title shortTitle="Improving Web Site Usability"&gt;Improving  
      the Usability of a Web Site Through Expert Reviews and
      Usability Testing&lt;/title&gt;
   &lt;author&gt;Millicent Marigold&lt;/author&gt;
   &lt;author&gt;Montana Marigold&lt;/author&gt;
   &lt;editor&gt;Véra Tudor-Medina&lt;/editor&gt;
   &lt;content&gt;
     &lt;p&gt;The usability of a Web site is how well the  
         site supports the users in achieving specified  
         goals. A Web site should facilitate learning,  
         and enable efficient and effective task  
         completion, while propagating few errors.
     &lt;/p&gt;
     &lt;note&gt;This book has been approved by the Web Site  
         Users Association.
     &lt;/note&gt;
   &lt;/content&gt;
 &lt;/book&gt;</eg>

</div3>

<div3 id="ftwords">
	<head>FTWords</head>

<p> <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwords" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWords</loc> specifies the words and phrases
that are being searched as the left-hand side argument of <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#tq-extensions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTContainsExpr</loc>.</p>

<scrap headstyle="show">
<head/>
<prodrecap ref="FTWords" id="FTWords"/>
</scrap>
	

<p>The right-hand side of the above production must evaluate to a
sequence of string values or nodes of type "xs:string". The result is
then atomized into a sequence of strings which is tokenized into a
sequence of words and phrases. If the atomized sequence is not a
subtype of "xs:string*", an error is raised: <xerrorref spec="XP" class="TY" code="0004" type="type"/>. 
</p>

<p>If the "any" option is specified, a match occurs, if and only if at least
one word or phrase in the sequence has a match in the searched text.</p>

<p>If the "all" option is specified, a match occurs, if and only if
all of the words and phrases in the sequence are matched in the
searched text.</p>

<p>If the "phrase" option is specified, the sequence of words and
phrases is used to create a single phrase by concatenating the words
and phrases and interleaving whitespace. A match occurs, if and only
if the resulting phrase is matched in the searched text.</p>

<p>If the "any word" option is specified, a match occurs, if and only
if at least one word in the sequence of words and phrases is matched
in the searched text.</p>

<p>If the "all word" option is specified, a match occurs, if and only
if all words in the sequence of words and phrases are matched in the
searched text.</p>

<p>If no option is specified, "any" is the default.</p>

<p>If the result is a single string, "any", "all", and "phrase" are
equivalent.</p>

<!-- <p>If Expr results in the empty sequence or the tokenization results
in a zero-length phrase, this is discussed in the issue 
<loc href="#zero-length-phrase">zero-length-phrase (Cluster G, Issue 47)</loc>.</p>
-->

<!-- <p>Note: The results assume a case-insensitive match in the following
expressions.</p>-->


<eg role="xpath" xml:space="preserve">/book[@number="1" and ./title ftcontains "Expert"]</eg>

<p>returns the <code>book</code> element whose <code>number</code> is
1, because its <code>title</code> element contains the word "Expert".</p>

<eg role="xpath" xml:space="preserve">/book[@number="1" and ./title ftcontains "Expert Reviews"]</eg>

<p>returns the <code>book</code> element whose <code>number</code> is
1, because its <code>title</code> element contains the phrase "Expert
Reviews".</p>

<eg role="xpath" xml:space="preserve">/book[@number="1" and ./title ftcontains {"Expert",
"Reviews"} all]</eg>

<p>returns the <code>book</code> element whose <code>number</code> is
1, because its <code>title</code> element contains two words "Expert"
and "Reviews".</p>

 
<eg role="xpath" xml:space="preserve">/book[@number="1"]//p ftcontains "Web Site Usability"</eg> 

<p>returns false, because the <code>p</code> element doesn't contain
the phrase "Web Site Usability" although it contains all of the words
in the phrase.</p>


<eg role="xquery" xml:space="preserve">for $book in /book[.//author ftcontains "Marigold"] 
let score $score := $book/title ftcontains "Web Site Usability" 
where $score &gt; 0.8 
order by $score descending
return $book/@number</eg> 

<p> returns <code>book</code> numbers of <code>book</code> elements by
"Marigold" with a title about "Web Site Usability" sorting them in
descending score order. </p>


</div3>
<div3 id="ftor">
	<head>FTOr</head>

<scrap headstyle="show"><head/>
<prodrecap ref="FTOr" id="FTOr"/>
</scrap>

<p> <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftor" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTOr</loc> finds matches that satisfy at least
one of the selection criteria. </p>

<p> A match must satisfy at least one of the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> criteria. </p>

<eg role="xpath" xml:space="preserve"> /book[.//author ftcontains "Millicent" ||
"Voltaire"] </eg>

<p>returns the <code>book</code> element written by "Millicent".</p>
	
</div3>

<div3 id="ftand">
	<head>FTAnd</head>

<scrap headstyle="show"><head/>
<prodrecap ref="FTAnd" id="FTAnd"/>
</scrap>

<p> <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftand" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTAnd</loc> finds matches that satisfy both of
the selection criteria.  </p>

<p> A match must satisfy all of the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> criteria which are specified by
one or more <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftmildnot" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTMildNot</loc> expressions.</p>

<eg role="xpath" xml:space="preserve">/book[@number="1"]/title ftcontains ("usability" &amp;&amp; "testing")</eg>

<p> returns true, since the <code>book</code> <code>title</code> contains
"usability" and "testing".</p>

<eg role="xpath" xml:space="preserve">/book/author ftcontains "Millicent" &amp;&amp; "Montana"</eg>

<p> returns false, because "Millicent" and "Montana" are not contained
by the same <code>author</code> element in any <code>book</code>
element.</p>

</div3>

<div3 id="ftmildnot">
	<head>FTMildNot</head>

<scrap headstyle="show"><head/>
<prodrecap ref="FTMildnot" id="FTMildnot"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftmildnot" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTMildNot</loc> is a milder form
of &amp;&amp; ! (and not). 'a not in b' matches an expression that
contains "a", but not when it is a part of "b".  For example, a search
for "Mexico" not in "New Mexico" returns, amon others, a document
which is all about "Mexico" but mentions at the end that "New Mexico
was named after Mexico", which would not be returned by an "and not"
search.</p>

<p> A match to <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftmildnot" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTMildNot</loc> must
contain at least one word occurrence that satisfies the first
condition and does not satisfy the second condition. If it contains a
word occurrence that satisfies both the first and the second
condition, the occurrence is not considered as a result.</p>

<eg role="xpath" xml:space="preserve">/book ftcontains "usability" not in "usability
testing"</eg>

<p>returns true, because "usability" appears in the <code>title</code>
and the <code>p</code> elements and the occurrence within the phrase
"Usability Testing" in the <code>title</code> element is not
considered.</p>

<p>The right-hand side of a <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftmildnot" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTMildNot</loc> may not contain an <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> that evaluates to an
<term>AllMatches</term> that contains a <term>StringExclude</term>. Such <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc>s are <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftunarynot" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
FTUnaryNot</loc> and <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#fttimes" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTTimes</loc> with at most,
from-to, and exactly occurrences ranges. </p>

</div3>


<div3 id="ftunarynot">
	<head>FTUnaryNot</head>

<scrap headstyle="show"><head/>
<prodrecap ref="FTUnaryNot" id="FTUnaryNot"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftunarynot" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTUnaryNot</loc> finds matches that do not
satisfy the selection criteria. </p>
	
<eg role="xpath" xml:space="preserve">/book[. ftcontains ! "usability"]</eg>

<p>returns the empty sequence, because all <code>book</code> elements
contain "usability".</p>

<eg role="xpath" xml:space="preserve">/book ftcontains "information" &amp;&amp;
"retrieval" &amp;&amp; ! "information retrieval"</eg>

<p>returns true, because <code>book</code> elements contain
"information" and "retrieval" but not "information retrieval".</p>

<eg role="xpath" xml:space="preserve">/book[. ftcontains "web site usability" &amp;&amp; 
!"usability testing"]</eg>

<p>return <code>book</code> elements containing "web site usability"
but not "usability testing".</p>

</div3>

<div3 id="ftorder">
	<head>FTOrder</head>

<scrap headstyle="show"><head/>
<prodrecap ref="FTOrderedIndicator" id="FTOrderedIndicator"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftorder" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTOrder</loc> controls the order of words and
phrases to be the same as the order in which they are written in the
query.
</p>

<p> The default is unordered. Unordered is in effect when ordered is
not specified in the query. Unordered cannot be written explicitly in
the query.  </p>

<p> <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftorder" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTOrder</loc> finds matches which must
satisfy the nested selection condition and the match must contain the
words in the order specified in the query.</p>

<eg role="xpath" xml:space="preserve">/book/title ftcontains ("web site" &amp;&amp; "usability")
ordered </eg>

<p>returns true, because titles of <code>book</code> elements contain
"web site" and "usability" in the order in which they are written in
the query, i.e., "web site" must precede "usability".</p>

<eg role="xpath" xml:space="preserve">/book[@number="1"]/title ftcontains ("Montana" &amp;&amp;
"Millicent") ordered </eg>

<p>returns false, because although "Montana" and "Millicent" appear in
the <code>title</code> element, they do not appear in the order they
are written in the query. </p>


</div3>
<div3 id="ftscope">
	<head>FTScope</head>

<scrap headstyle="show"><head/>
<prodrecap ref="FTScope" id="FTScope"/>
<prodrecap ref="FTBigUnit" id="FTBigUnit"/>
</scrap>

<p> <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftscope" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTScope</loc> finds words and phrases
contained in the same or a different scope. </p>

<p> Possible scopes are sentences and paragraphs. </p>

<p> By default, there are no restriction on the scope of the
matches. </p>

<p> If two words appear in the same sentence and in different
sentences, then both same sentence and different sentence return
true. The same is true for same paragraph and different paragraph.</p>

<eg role="xpath" xml:space="preserve">/book ftcontains "usability"
&amp;&amp; "Marigold" same sentence</eg>

<p> returns false, because the words "usability" and "Marigold" are not
contained within the same sentence. </p>

<eg role="xpath" xml:space="preserve">/book ftcontains "usability"
&amp;&amp; "Marigold" different sentence</eg>

<p> returns true, because the words "usability" and "Marigold" are
contained within different sentences. </p>

<eg role="xpath" xml:space="preserve">/book[. ftcontains "usability" &amp;&amp; "testing"
same paragraph] </eg>

<p> returns a <code>book</code> element, because it contains
"usability" and "testing" in the same paragraph.</p>

<eg role="xpath" xml:space="preserve">/book[. ftcontains "site" &amp;&amp; "errors"
same sentence] </eg>

<p> returns a <code>book</code> element, because "site" and "errors"
appear in the same sentence. </p>

<p>Some subtle relationships between <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftscope" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTScope</loc> and <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTDistance</loc> will be discussed in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#tq-semantics" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Section 4.</loc> </p>

</div3>

<div3 id="ftdistance">
	<head>FTDistance</head>

<scrap headstyle="show"><head/>
<prodrecap ref="FTDistance" id="FTDistance"/>
<prodrecap ref="FTRange" id="FTRange"/>
<prodrecap ref="FTUnit" id="FTUnit"/>
</scrap>

<p> <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTDistance</loc> finds matches by
specifying the distance between words and phrases in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTUnit</loc> (words, sentences, and
paragraphs). The number of intervening <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTUnit</loc>s is specified in the integer value of
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTRange</loc>. </p>
 
<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTRange</loc> specifies a range of integer
values, providing a minimum and maximum value.  Each <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">UnionExpr</loc> in an <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTRange</loc> must evaluate (after atomization) to
a singleton sequence with an atomic value of type
"xs:integer". Otherwise, an error is raised <xerrorref spec="XP" class="TY" code="0004" type="type"/>. </p>

<p>Let the value of the first (or only) <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">UnionExpr</loc> be M.  If "from" is specified, let
the value of the second <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">UnionExpr</loc> be
N. <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTDistance</loc> may cross element
boundaries when computing distance.</p>

<p>The following rule applies to <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTDistance</loc>:</p>

<ulist>
<item><p> Zero words (sentences, paragraphs) means adjacent words (sentences, paragraphs).</p></item> 
</ulist>

<p>If "exactly" is specified, then the range is the closed interval [M, 
M].  If "at least" is specified, then the range is the half-closed interval 
[M, unbounded).  If "at most" is specified, then the range is the closed 
interval [0, M].  If "from-to" is specified, then the range is the closed 
interval [M, N].  </p>

<p>Here are some examples of  <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTRange</loc>s:</p>

<olist><item><p>'exactly 0' specifies the range [0, 0].</p></item>
    <item><p>'at least 1' specifies the range [1,unbounded].</p></item> 
    <item><p>'at most 1' specifies the range [0, 1]. </p></item>
    <item><p>'from 5 to 10' specifies the range [5, 10].</p></item>
</olist>

<p>The distances computed by FTDistance are not affected by the
presence or absence of element boundaries in the text.  Stop words are
counted in those computations whether they are ignored or not.</p>


<eg role="xpath" xml:space="preserve">/book ftcontains ("information" &amp;&amp;
"retrieval") not in ("information" &amp;&amp; "retrieval" 
distance at least 11 words)
</eg>

<p>returns false, because "information" and "retrieval" are more than
at least 11 words apart. </p>

<eg role="xpath" xml:space="preserve">/book ftcontains "web" &amp;&amp; "site" &amp;&amp;
"usability" distance at most 2 words</eg>

<p>returns true, because "web", "site", and "usability" have at most 2
intervening words between them.</p>

<eg role="xpath" xml:space="preserve">/book[. ftcontains "web site"
&amp;&amp; "usability" distance at most 1 words]/title </eg>

<p>returns the <code>book</code> title. A similar query for the
<code>p</code> element would return false because "web site" and
"usability" have two intervening words between them. </p>

<!-- JD, 2005-08-17: need to revise the foll. 2 examples;
<eg role="xpath">/book[@number="1" and . ftcontains ("web site"
&amp;&amp; "completion" &amp;&amp; !  "learning") distance
exactly 15 words]/title
</eg>

<p>returns the
<code>title</code> element, because the word "learning" not appears
within 15 words of the words "web site" and "completion".</p>

<eg role="xpath">/book[@number="1" and . ftcontains "web site"
&amp;&amp; "completion" distance exactly 15 words same
paragraph]/title </eg>

<p>returns the <code>title</code>
element if the words "web site" and "completion" appear within 15
words of each other and in the same paragraph.</p>
-->

</div3>

<div3 id="ftwindow">
	<head>FTWindow</head>

<scrap headstyle="show"><head/>
	<prodrecap ref="FTWindow" id="FTWindow"/>
</scrap>


<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwindow" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWindow</loc> finds matches within a number
of <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwindow" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTUnit</loc>s (words, paragraphs, and
phrases). The number of <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwindow" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTUnit</loc>s is
specified as an integer.</p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwindow" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWindow</loc> may cross element
boundaries. The size of the window is not affected by the presence or
absence of element boundaries. Stop words are included in those
computations whether they are ignored or not.</p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwindow" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">UnionExpr</loc> must evaluate to an atom of
type "xs:integer".</p>

<p>A match of an <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> is
considered a match within a window, if there exists a window of the
given number of consecutive units (words, sentences, or paragraphs) in
the document within which the match lies.
</p>

<eg role="xpath" xml:space="preserve">/book/title ftcontains "web" &amp;&amp; "site"
&amp;&amp; "usability" window 5 words</eg>

<p>returns true, because "web", "site", and "usability" are within a
window of 5 words in the <code>title</code> element.</p>

<eg role="xpath" xml:space="preserve">/book ftcontains ("web" &amp;&amp; "site" ordered)
&amp;&amp; ("usability" || "testing") window 10 words</eg>

<p>returns true, because "web" and "site" in the order they are
written in the query and either "usability" or "testing" are within a
window of at most 10 words. </p>

<eg role="xpath" xml:space="preserve">/book//title ftcontains "web site" &amp;&amp;
"usability" window 3 words</eg>

<p>returns true, because the <code>title</code> element contains "Web
Site Usability". A similar query on the <code>p</code> element would not 
return true, 
because its occurrences of "web site" and "usability" are not within a
window of 3.</p>

<eg role="xpath" xml:space="preserve">/book[@number="1" and . ftcontains "efficient" 
&amp;&amp; ! "and" window 3 words]</eg>

<p>returns the empty sequence, because in the selected
<code>book</code> element, there is no occurrence of "efficient"
within a window of 3 words which would not also contain an occurrence
of "and".</p>

</div3>

<div3 id="fttimes">
	<head>FTTimes</head>

<scrap headstyle="show"><head/>
			<prodrecap ref="FTTimes" id="FTTimes"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#fttimes" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTTimes</loc> finds matches in which an <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> occurs a specified number of
times. </p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#fttimes" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTTimes</loc> limits the number of different
occurrences of <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc>, within the
specified range.  </p>

<p>In the document fragment "very very big":</p>

<olist>

<item>
<p>
The <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> "very big" has 1
occurrence consisting of the second "very" and "big".
</p>
</item>

<item>
<p>
The <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> "very &amp;&amp; big"
has 2 occurrences; one consisting of the first "very" and "big", and
the other containing the second "very" and "big".
</p>
</item>

<item>
<p>
The <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> "very || big" has 3
occurrences. 
</p>
</item>

<item>
<p>
The <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> ! "small" has 1
occurrence.
</p>
</item>

</olist>

<eg role="xpath" xml:space="preserve">/book[. ftcontains "usability" occurs at least 2 times]/@number</eg>

<p>returns <code>book</code> numbers because <code>book</code>
elements contain 2 or more occurrences of "usability".</p>

<eg role="xpath" xml:space="preserve">/book[@number="1" and title ftcontains "usability" ||
"testing" occurs at most 3 times] </eg>

<p>returns the empty sequence, because there are 4 occurrences of
"usability" || "testing" in the designated <code>title</code>.</p>

<eg role="xpath" xml:space="preserve">/book ftcontains "usability" occurs at least 2 times
</eg>

<p>returns true, because the <code>book</code> element contains 3
occurrences of "usability" in its <code>title</code> element although
its <code>p</code> element contains only 1 occurrence.
</p>


</div3>

<div3 id="ftcontent">
	<head>FTContent</head>

<scrap headstyle="show"><head/>
			<prodrecap ref="FTContent" id="FTContent"/>
</scrap>
 
<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftcontent" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTContent</loc> finds matches in which the
words and phrases are the first, last or all of the words and phrases
in the tokenized string value of the element being
searched.</p>

<p> The "at" "start" option finds matches in which the words or
phrases are the first words or phrases in the tokenized string value
of the element being searched.</p>

<p> The "at" "end" option finds matches in which the words or phrases
are the last words or phrases in the tokenized string value of the
element being searched.</p>
 
<p>The "entire" content" option finds matches in which the words or
phrases are the entire content of the tokenized string value of the
element being searched.</p>
 
<eg role="xpath" xml:space="preserve">/books//title[. ftcontains "improving the usability
of a web site" at start]</eg> 

<p>returns each <code>title</code> element starting with the phrase "improving the
usability of a web site".</p>
 
<eg role="xpath" xml:space="preserve">/books//p[. ftcontains "propagat*" &amp;&amp; "few
errors" distance at most 2 words at end]</eg>

<p>returns each <code>p</code> element ending with the phrase
"propagating few errors".</p>
 
<eg role="xpath" xml:space="preserve">/books//note[. ftcontains "this site has been
approved by the web site users association" entire content]</eg>

<p>returns each <code>note</code> element whose entire content is
"this site has been approved by the web site users association".</p>

</div3>


</div2>


<div2 id="ftmatchoptions">
	<head>FTMatchOptions</head>


<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftmatchoptions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTMatchOptions</loc> modify the
operational semantics of the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc> on which they are applied. </p>

<scrap headstyle="show"><head/>
			<prodrecap ref="FTMatchOption" id="FTMatchOption"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftmatchoptions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTMatchOptions</loc> set 
environments for the matching options of <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftselection" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTSelection</loc>. If a match option isn't
specified explicitly in the query, its value is given by its static
context component. Details about these context components, including
their default values, are given in
Appendix <specref ref="id-xqft-static-context-components"/>.</p>

<p>If no match options declarations are present in the prolog and the implementation does not define any overwriting of the static context components for the match options, the query:</p>

<eg role="xpath" xml:space="preserve">/book/title ftcontains "usability" </eg>

<p>is equivalent to the query </p>

<eg role="xpath" xml:space="preserve">/book/title ftcontains "usability" case insensitive 
    diacritics insensitive 
    without stemming without thesaurus  
    without stop words language "none" without wildcards</eg>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftmatchoptions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTMatchOptions</loc> are applied in the
order in which they are written in the query. More information on
their semantics is given in <specref ref="FTMatchOptionsSec"/>.</p>

<p> We describe each match option in more detail in the following
sections.</p>



<div3 id="ftcaseoption">
	<head>FTCaseOption</head>

<scrap headstyle="show"><head/>
			<prodrecap ref="FTCaseOption" id="FTCaseOption"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftcaseoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTCaseOption</loc> modifies words and
phrases matching by specifying how upper and lower charcters are
considered. </p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftcaseoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTCaseOption</loc> influences the way
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwords" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWords</loc> is applied.</p>

<p>There are four possible character case options:</p>

<olist>
<item><p> The option "uppercase" matches words and phrases with
uppercase characters, regardless of the case of characters of the
words and phrases as they are written in the query.</p></item>

<item><p> The option "lowercase" matches words and phrases with
lowercase characters, regardless of the case of characters of the
words and phrases as they are written in the query.</p></item>

<item><p> The option "case" "insensitive" matches the uppercase and
lowercase characters of words and phrases. The case of characters as
they are written in the query is not considered.</p></item>

<item><p> The option "case" "sensitive" matches the case of the
characters in words and phrases as they are written in the
query.</p></item>

</olist>

<p>The default is "case insensitive". </p>

<p>The following table summarizes the interactions between 
the case match options and the use of the default collations.</p>

<p>
 <table border="1">
      <caption>Case Matrix</caption>
      <thead>
       <tr>
        <td colspan="1" rowspan="1">Default collation options/Case options</td>
        <td colspan="1" rowspan="1">UCC (Unicode Codepoint Collation)</td>
        <td colspan="1" rowspan="1">CCS (some generic case-sensitive collation)</td>
        <td colspan="1" rowspan="1">CCI (some generic case-insensitive collation) </td>
       </tr>
      </thead>
      <tbody>
       <tr>
        <td colspan="1" rowspan="1">insensitive</td>
        <td colspan="1" rowspan="1">compare as if both lower</td>
        <td colspan="1" rowspan="1">case-insensitive variant of CCS if it exists, else error</td>
        <td colspan="1" rowspan="1">CCI</td>
       </tr>
       <tr>
        <td colspan="1" rowspan="1">sensitive</td>
        <td colspan="1" rowspan="1">UCC</td>
        <td colspan="1" rowspan="1">CCS</td>
        <td colspan="1" rowspan="1">case-sensitive variant of CCI if it exists, else error</td>
       </tr>
       <tr>
        <td colspan="1" rowspan="1">uppercase</td>
        <td colspan="1" rowspan="1">uppercase(Expr) + UCC</td>
        <td colspan="1" rowspan="1">uppercase(Expr) + CSS</td>
        <td colspan="1" rowspan="1">CCI</td>
       </tr>
       <tr>
        <td colspan="1" rowspan="1">lowercase</td>
        <td colspan="1" rowspan="1">lowercase(Expr) + UCC</td>
        <td colspan="1" rowspan="1">lowercase(Expr) + CSS</td>
        <td colspan="1" rowspan="1">CCI</td>
       </tr>
      </tbody>
     </table>
</p>

<note><p>In this table, "else error" means "Otherwise, an error
is raised: <xerrorref spec="FO" class="CH" code="0002" type="dynamic"/>". 
The phrase "if it exists" is used, because
the case-sensitive collation CCS does not always have a
case-insensitive variant (and, even if one exists, it may not be
possible to determine it algorithmically), and because the
case-insensitive collation CCI does not always have a case-sensitive
variant (and, even if one exists, it may not be possible to determine
it algorithmically).</p></note>

<eg role="xpath" xml:space="preserve">/book[@number="1"]/title ftcontains "Usability" lowercase </eg>

<p>returns false, because the <code>title</code> element doesn't contain
"usability" in lower-case characters.  </p>

<eg role="xpath" xml:space="preserve">/book[@number="1"]/title ftcontains "usability" 
case insensitive
</eg>

<p>returns true, because the character case is not
considered. </p>


</div3>

<div3 id="ftdiacriticsoption">
	<head>FTDiacriticsOption</head>

<scrap headstyle="show"><head/>
			<prodrecap ref="FTDiacriticsOption" id="FTDiacriticsOption"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdiacriticsoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTDiacriticsOption</loc> modifies
word and phrase matching by specifying how diacritics are considered.</p>

<p>There are four possible diacritics options:</p>

<olist>
<item><p>The option "with" "diacritics" matches words and phrases with
diacritics, regardless of whether the diacritics are written in the
query.</p></item>

<item><p>The option "without" "diacritics" matches words and phrases
without diacritics, regardless of whether the diacritics are written
in the query.</p></item>

<item><p>The option "diacritics" "insensitive" matches words and
phrases with and without diacritics. Whether diacritics are written in
the query or not is not considered.</p></item>

<item><p>The option "diacritics" "sensitive" matches words and phrases only
if they contain the diacritics as they are written in the query.</p></item>

</olist>

<p>The default is "diacritics insensitive". </p>

<p>The following table summarizes the interactions between the
diacritics match options and the use of the default collations.</p>

<p>
    <table border="1">
      <caption>Diacritics Matrix</caption>
      <thead>
       <tr>
        <td colspan="1" rowspan="1">Default collation options/Diacritics options</td>
        <td colspan="1" rowspan="1">UCC (Unicode Codepoint Collation)</td>
        <td colspan="1" rowspan="1">CDS (some generic diacritics-sensitive collation)</td>
        <td colspan="1" rowspan="1">CDI (some generic diacritics-insensitive collation) </td>
       </tr>
      </thead>
      <tbody>
       <tr>
        <td colspan="1" rowspan="1">insensitive</td>
        <td colspan="1" rowspan="1">compare as if with and without</td>
        <td colspan="1" rowspan="1">diacritics-insensitive variant of CDS
                                  if it exists, else error</td>
        <td colspan="1" rowspan="1">CDI</td>
       </tr>
       <tr>
        <td colspan="1" rowspan="1">sensitive</td>
        <td colspan="1" rowspan="1">UCC</td>
        <td colspan="1" rowspan="1">CDS</td>
        <td colspan="1" rowspan="1">diacritics-sensitive variant of CDI if it exists, else error</td>
       </tr>
       <tr>
        <td colspan="1" rowspan="1">with diacritics</td>
        <td colspan="1" rowspan="1">"resume diacritic
              insensitive" not in
              "resume"</td>
        <td colspan="1" rowspan="1">"resume diacritic insensitive" not in
                                  "resume"</td>
        <td colspan="1" rowspan="1">CDI</td>
       </tr>
       <tr>
        <td colspan="1" rowspan="1">without diacritics</td>
        <td colspan="1" rowspan="1">"resume" not in
              "resume diacritic
              sensitive" </td>
        <td colspan="1" rowspan="1">"resume" not in "resume diacritic
                                  sensitive"</td>
        <td colspan="1" rowspan="1">CDI</td>
       </tr>
      </tbody>
     </table>
</p>

<note><p>In this table, "else error" means "Otherwise, an error
is raised: <xerrorref spec="FO" class="CH" code="0002" type="dynamic"/>". 
The phrase "if it exists" is used, because
the diacritics-sensitive collation CDS does not always have a
diacritics-insensitive variant (and, even if one exists, it may not be
possible to determine it algorithmically), and because the
diacritics-insensitive collation CDI does not always have a
diacritics-sensitive variant (and, even if one exists, it may not be
possible to determine it algorithmically).</p></note>

<eg role="xpath" xml:space="preserve">/book[@number="1"]//editor ftcontains "Vera" with diacritics </eg>

<p>returns true, because the <code>editor</code> element 
contains the word "Vera" with an acute accent.</p>

<eg role="xpath" xml:space="preserve">/book[@number="1"]/editors ftcontains "Véra" without diacritics </eg>


<p>returns false, because the <code>editor</code> element does not
contain the word "Vera" without an acute accent.</p>


</div3>
<!--<div3 id="ftspecialcharoption">
	<head>FTSpecialCharOption</head>

<scrap><head></head>
			<prodrecap ref="FTSpecialcharOption"/>
</scrap>

<p><loc href="#ftspecialcharoption">FTSpecialCharOption</loc>
specifies whether special characters such as punctuation should or
should not be ignored. </p>

<p>Influences the way <loc href="#ftwords">FTWords</loc> is
applied. </p>

<p>The option "with special characters" specifies that special
characters such as punctuation must also be matched. The option
"without special characters" specifies that special characters such as
punctuation need not be matched.
</p>

<p>The default is "without special characters". </p>


<eg role="xpath">/book[@number="1"]//editor ftcontains "Tudor Medina" with 
special characters </eg> 

<p>returns true.</p>

<eg role="xpath">/book[@number="1"]/editors ftcontains "Tudor-Medina" without
special characters </eg> 

<p>returns false.</p>


</div3>
-->

<div3 id="ftstemoption">
	<head>FTStemOption</head>

<scrap headstyle="show"><head/>
			<prodrecap ref="FTStemOption" id="FTStemOption"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftstemoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTStemOption</loc> modifies word and
phrase matching by specifying whether stemming is applied or not. </p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftstemoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTStemOption</loc> influences the way
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwords" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWords</loc> is applied. It produces a disjunction
of the query words by expanding the words into the list of words that
share the same stem. By definition, the query words are included in
that disjunction. </p>

<p>The "with stemming" option specifies that matches may contain words
that have the same stem as the words and phrases written in the
query. It is implementation-defined what a stem of a word is. </p>

<p>The "without stemming" option specifies that the words and
phrases are not stemmed. </p>

<p>It is implementation-defined whether the stemming is based on an
algorithm, dictionary, or mixed approach. </p>

<p>The default is "without stemming". </p>


<eg role="xpath" xml:space="preserve">/book[@number="1"]/title ftcontains "improve" with stemming </eg>

<p>returns true, because the <code>title</code> of the spekcified
<code>book</code> contains "improving" which has the same stem as
"improve".  </p>


</div3>
<div3 id="ftthesaurusoption">
	<head>FTThesaurusOption</head>

<scrap headstyle="show"><head/>
	<prodrecap ref="FTThesaurusOption" id="FTThesaurusOption"/>
	<prodrecap ref="FTThesaurusID" id="FTThesaurusID"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftthesaurusoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTThesaurusOption</loc> modifies
word and phrase matching by specifying whether a thesaurus is used or
not. If thesauri are used, it locates the thesauri by default or URI
reference. It also states the relationship to be applied and how many
levels within the thesaurus to be traversed.. </p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftthesaurusoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTThesaurusOption</loc> influences
the way <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwords" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWords</loc> is applied.</p>

<p>The <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftthesaurusoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">StringLiteral</loc> following
the keyword <code>at</code> in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftthesaurusoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTThesaurusID</loc> is of the form of a URI
Reference.</p>

<p>Thesauri add related words and phrases to the search.  Thus, the
user may narrow, broaden, or otherwise modify the search using
synonyms, hypernyms (more generic terms), etc. The search is performed
as though the user has specified all related search words and phrases
in a disjunction (FTOr). </p>


<note><p>A thesaurus may be standards-based or locally-defined. It may be a
traditional thesaurus, or a taxonomy, soundex, ontology, or topic
map. How the thesaurus is represented is implementation-dependent.</p>
</note> 

<p>FTThesaurusID specifies the relationship sought between words and
phrases written in the query and terms in the thesaurus and the number
of levels to be queried in hierarchical relationships by including an
FTRange "levels". If no levels are specified, the default is to query
all levels in hierarchical relationships.</p>

<p>Relationships include, but are not limited to, the relationships
and their abbreviations presented in <bibref ref="iso-2788"/> and
their equivalents in other languages:</p>
<olist>
<item><p> <emph>equivalence relationships (synoymns):</emph> PREFERRED TERM (USE), 
NONPREFERRED USED FOR TERM (UF);</p></item>
<item><p> <emph>hierarchical relationships:</emph> BROADER TERM (BT), 
NARROWER TERM (NT),  BROADER TERM GENERIC (BTG), NARROWER TERM GENERIC (NTG), 
BROADER TERM PARTITIVE (BTP), NARROWER TERM PARTITIVE (NTP), 
TOP Terms (TT); and</p></item> 
<item><p> <emph>associative relationships:</emph> RELATED TERM (RT).</p></item>
</olist>

<p>The "with thesaurus" option specifies that string matches include
words that can be found in one of the specified thesauri. </p>

<p>The "without thesaurus" option specifies that no thesaurus will be
used. </p>

<p>The "with default thesaurus" option specifies that a system-defined
default thesaurus with a system-defined relationship is used. The
default thesaurus may be used in combination with other explicitly
specified thesauri.</p>

<p>The default is "without thesaurus". </p>

<eg role="xpath" xml:space="preserve">count(.//book/content ftcontains "duties" with
thesaurus at "http://bstore1.example.com/UsabilityThesaurus.xml"
relationship "synonyms")&gt;0</eg>

<p>returns true, because it finds a <code>content</code> element
containing "tasks" which the thesaurus identified as a synonym for
"duties".</p>

<eg role="xpath" xml:space="preserve">doc("http://bstore1.example.com/full-text.xml")
/books/book[count(./content ftcontains "web site components" with
thesaurus at "http://bstore1.example.com/UsabilityThesaurus.xml"
relationship "narrower terms" at most 2 levels)&gt;0]</eg>

<p>returns <code>book</code> elements, because it finds a
<code>content</code> element containing "web site components", and
narrower terms "navigation" and "layout".</p>

<eg role="xpath" xml:space="preserve">doc("http://bstore1.example.com/full-text.xml")
/books/book[count(. ftcontains "Merrygould" with thesaurus at
"http://bstore1.example.com/UsabilitySoundex.xml" relationship
"sounds like")&gt;0]</eg>

<p>returns a <code>book</code> element containing "Marigold which
sounds which sound like "Merrygould".</p>


<!--
<eg role="xpath">/book[@number="1"]//p ftcontains "buttress" with
thesaurus "Synonyms"</eg>

<p>returns the true if "Synonyms" is a thesaurus for synonyms in the
English language.</p>
-->


</div3>
<div3 id="ftstopwordoption">
	<head>FTStopwordOption</head>

<scrap headstyle="show"><head/>
	<prodrecap ref="FTStopwordOption" id="FTStopwordOption"/>
	<prodrecap ref="FTRefOrList" id="FTRefOrList"/>
	<prodrecap ref="FTInclExclStringLiteral" id="FTInclExclStringLiteral"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftstopwordoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTStopWordOption</loc> controls word
matching by specifying whether stop words are used or not. </p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftstopwordoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTStopWordOption</loc> influences the way <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwords" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWords</loc> is
applied. </p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftstopwordoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTRefOrList</loc> specifies the list
of stop words either explicitly as a comma-separated list of string
literals, or by a URI following the keyword <code>at</code>. If a URI
is used, it must point to a sequence of string atoms or nodes of type
"xs:string". In both cases, no tokenization is performed on the
strings: they are used as they occur in the sequence. </p>

<p>The "with stop words" option specifies that if a word is within the
specified collection of stop words, it is removed from the search and
any word may be substituted for it. Stop words retain their position
numbers and are counted in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdistance" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTDistance</loc>
and <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwindow" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWindow</loc> searches.</p>

<p>Stop word lists can be combined using the usual semantics of
"except" and "union".</p>

<p>The "with default stop words" option specifies that an
implementation-defined collection of stop words is used. </p>

<p>The "without stop words" option specifies that no stop words are
used. This is equivalent to specifying an empty list of stop
words.</p>

<p>The default is "without stop words". </p>


<eg role="xpath" xml:space="preserve">/book[@number="1"]//p ftcontains "propagation of errors"
with stemming with stop words ("a", "the", "of") </eg>

<p>returns true, because the document contains the phrase "propagating
few errors". </p>

<p>Note the asymmetry in the stop word semantics: the property of
being a stop word is only relevant to query terms, not to document
terms. Hence, it is irrelevant for the above-mentioned match whether
"few" is a stop word or not, and on the other hand we do not want the
query above to match "propagation" followed by 2 stop words, or even a
sequence of 3 stop words in the document.</p>

<eg role="xpath" xml:space="preserve">/book[@number="1"]//p ftcontains "propagation of errors" 
with stemming without stop words</eg> 

<p>returns false, because "of" is not in the <code>p</code> element
between "propagating" and "errors". </p>

<eg role="xpath" xml:space="preserve">
doc("http://bstore1.example.com/full-text.xml")
/books/book[count(.//content ftcontains "planning then 
conducting" with stop words at 
"http://bstore1.example.com/StopWordList.xml")&gt;0]
</eg>

<p>uses the stop words list specified at the URL. Assuming that the
specified stop word list contains the word "then", this query is
reduced to a query on the phrase "planning X conducting", allowing any
word as a substitute for X.  It returns a <code>book</code> element,
because its <code>content</code> element contains "planning then
conducting". It would have also returned the <code>book</code> if the
phrases "planning and conducting" and "planning before conducting" if
they had been in its <code>content</code>.</p>


<eg role="xpath" xml:space="preserve">
doc("http://bstore1.example.com/full-text.xml")
/books/book[count(.//content ftcontains "planning then conducting"
with stop words at "http://bstore1.example.com/StopWordList.xml"
except ("the then"))&gt;0]
</eg>

<p>returns <code>book</code>s containing "planning then conducting",
but not does not return <code>book</code>s containing "planning and
conducting", since it is exempting "then" from being a stop word. </p>


</div3>

<div3 id="ftlanguageoption">
	<head>FTLanguageOption</head>

<scrap headstyle="show"><head/>
	<prodrecap ref="FTLanguageOption" id="FTLanguageOption"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftlanguageoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTLanguageOption</loc> modifies word
matching by specifying the language of search words and phrases. </p>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftlanguageoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTLanguageOption</loc> influences the way <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwords" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWords</loc> is applied.  </p>

<p>The StringLiteral following the keyword <code>language</code>
designates one language. It must either be castable to "xs:language",
or be the value "none". Otherwise, an error is raised: <xerrorref spec="XP" class="TY" code="0004" type="type"/>. </p>

<p>The "language" option influences tokenization, stemming, and stop
words.</p>

<p>If the <code>language "none"</code> option is specified, no
language selected.</p>

<p> The set of valid language identifiers is
implementation-defined.</p>

<p>By default, there is no language selected. </p>


<eg role="xpath" xml:space="preserve">/book[@number="1"]//editor ftcontains "salon de the"
with default stop words language "fr"</eg> <p>This is an example where
the language option is used to select the appropriate stop word list. </p>


</div3>



<div3 id="ftwildcardoption">
	<head>FTWildCardOption</head>

<scrap headstyle="show"><head/>
	<prodrecap ref="FTWildCardOption" id="FTWildCardOption"/>
</scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwildcardoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWildCardOption</loc> modifies word and phrase matching by specifying whether wildcards are used or not.</p>
 
<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwildcardoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWildCardOption</loc> influences the
way FTWords is applied.</p>

<p>In addition to specifying the "with wildcards"' option, indicators
(represented by periods (.)) and qualifiers are appended to or
inserted into words being searched. Zero or more characters replace
each indicator and qualifier.</p>

 
<p>Indicators are mandatory. When the "with wildcards"' option is
present, one or more periods (.) must be appended at the beginning or
end of words or inserted into words. If the period is at the beginning
of a word, the wildcard is a prefix wildcard. If the period is at the
end of a word, it is a suffix wildcard. If the period is inserted into
a word, it is an infix wildcard.</p>
 

<p>When the "with wildcards" option and one or more periods (.)
appended to or inserted into words are present, characters are
appended or inserted at each of the periods. Any characters may be
appended or inserted except newline characters (#xA), return
characters (#xD), and tab characters (#x9). The number of characters
depends on the qualifier.  Qualifiers available are none, question
mark, asterisk, plus sign, and two numbers separated by a comma, both
enclosed by curly braces.</p>
 
<olist>

<item> 
<p>If a period is present, but no qualifiers, one character is
appended or inserted. </p>
</item> 
 
<item> 
<p>If a period is followed by a question mark (.?), zero or one
characters are appended or inserted. </p>
</item> 

 
<item> 
<p>If a period is followed by an asterisk (.*), zero or more
characters are appended or inserted.</p>
</item> 

 
<item> 
<p>If a period is followed by a plus sign (.+), one or more characters
are appended or inserted. </p>
</item> 
 
 
<item> 
<p>If a period is followed by two numbers separated by a comma, both
enclosed by curly braces (.{n,m}), a specified range of characters is
appended or inserted. </p>
</item> 

</olist>

 
<p>The "without wildcards" option finds words without recognizing
wildcard indicators and qualifiers. Periods, question marks,
asterisks, plus signs, and two numbers separated by a comma, both
enclosed by curly braces recognized as regular characters.</p>
 

<p>The default is "without wildcards".</p>

 
<eg role="xpath" xml:space="preserve">/book[@number="1"]/title ftcontains "improv.*" with
wildcards</eg> <p>returns true, because the <code>title</code> element
contains "improving".</p>

 
<eg role="xpath" xml:space="preserve">/book[@number="1"]/title ftcontains ".?site" with
wildcards</eg> <p>returns true, because the <code>title</code> element
contains "site".</p>

 
<eg role="xpath" xml:space="preserve">/book[@number="1"]/p ftcontains "w.ll" with
wildcards</eg> <p>returns true, because the <code>p</code> element
contains "well".</p>



</div3>

</div2>
<div2 id="ftignoreoption">
        <head>FTIgnoreOption</head>

<scrap headstyle="show"><head/>
                        <prodrecap ref="FTIgnoreOption" id="FTIgnoreOption"/>
                </scrap>

<p><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftignoreoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTIgnoreOption</loc> specifies a set of
element nodes whose content are ignored. Ignored nodes are identified
by the XQuery expression UnionExpr. Let <code>N1, N2, ..., Nk</code>
be the sequence of nodes of the search context. The expression
UnionExpr is evaluated in the context of each node <code>Ni</code> being
searched. That is, the search context expression of the <code>ftcontains</code>
predicate creates a new focus for the evaluation of the UnionExpr
given with <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftignoreoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTIgnoreOption</loc>, similar
to the creation of the dynamic context of a path expression
<code>E1/E2</code> or a filter expression <code>E1[E2]</code> 
(see <xspecref spec="XQ" ref="eval_context"/>).</p>

<p>Now, let <code>I1, I2, ..., In</code> be the sequence of items that
UnionExpr evaluates to. For each <code>Ni (i=1..k)</code> a copy is
made that omits each node <code>Ij (j=1..n)</code> that is not
<code>Ni</code>. Those copies form the new search context. If
UnionExpr evaluates to an empty sequence no nodes are omitted.</p>

<p>In the following fragment, if <code>.//annotation</code> is ignored,
"Web Usability" will be found 2 times: once in the <code>title</code>
element and once in the <code>editor</code> element. The 2 occurrences
in the 2 <code>annotation</code> elements are ignored. On the other
hand, "expert" will not be found, as it appears only in an
<code>annotation</code> element.</p> 


 <eg xml:space="preserve">&lt;book&gt;
   &lt;title&gt;Web Usability and Practice&lt;/title&gt;
   &lt;author&gt;Montana &lt;annotation&gt; this author is an expert in Web Usability&lt;/annotation&gt; 
           Marigold
   &lt;/author&gt;
   &lt;editor&gt;Véra Tudor-Medina on Web &lt;annotation&gt; best editor on Web Usability&lt;/annotation&gt;
           Usability
   &lt;/editor&gt;
 &lt;/book&gt;</eg>

<p>By default, no element content is ignored. </p>

</div2>

</div1>


<div1 id="tq-semantics">
    <head>Semantics</head>
    
    <div2 role="xquery" id="SemanticsIntroSec">
        <head>Introduction</head>
    
        <p>This section describes the formal semantics of XQuery 1.0 and XPath 2.0 Full-Text.
        The figure below shows how XQuery 1.0 and XPath 2.0 Full-Text integrates with XQuery 1.0
        and XPath 2.0.</p>
		
		<p>The following diagram represents the interaction of XQuery 1.0 and
		XPath 2.0 Full-Text with the rest of XQuery 1.0 and XPath 2.0 languages.
		It specifies how full-text expression can be nested within XQuery 1.0
		and XPath 2.0 expressions and vice versa. </p>
    
        <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/Composability.png" alt="Composability diagram" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
    
		<ulist>
       	<item><p>Arrow 1 represents the composability of the XQuery 1.0
        and XPath 2.0 expressions  by showing that XQuery 1.0 expressions are 
		nested inside <term>FTSelection</term>s and evaluated to a sequence of items. </p></item>
		
		<item><p>Arrow 2 shows how Regular XQuery expressions can be nested inside
        <term>FTSelection</term>s  by evaluating them to a sequence of
        items and then converting them to a tokenized text.	The
        process is described in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#NestedXQuerySec" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Nested
        XQuery and XPath Expressions</loc>. </p></item>
		
		<item><p>Arrow 3 represents the composability of <term>FTSelection</term>s. 
        The composability is achived by evaluating the <term>FTSelection</term>s to
        <term>AllMatches</term>. Each <term>FTSelection</term> operates on zero or more
        <term>AllMatches</term> and returns <term>AllMatches</term>. The process is
        described in the <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#FTSelectionEvalSec" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Evaluation 
        of FTSelections</loc> section. </p>	</item>
		
		<item><p>
		Arrow 4 shows how the result of the evaluation of XQuery 1.0 and XPath 2.0 Full-Text and scoring
        expressions needs to be integrated in the XPath and XQuery
        model. The section <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#FullTextExprSec" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">XQuery 1.0 and XPath 2.0 Full-Text and scoring
        expressions</loc> describes how this is achieved.</p></item>
		</ulist>
		
		<p>The functions and schemas defined in this section are
		considered to be within the fts: namespace. These functions and schemas
		are used only for describing the semantics. There is no requirement that 
		these functions and schemas be implemented, so there is  no URI is 
		associated with the fts: prefix. </p>
    
    </div2>

    <div2 role="xquery" id="NestedXQuerySec">
        <head>Nested XQuery 1.0 and XPath 2.0 Expressions</head>
    
        <p>XQuery 1.0 and XPath 2.0 expressions can be nested inside 
		<term>FTContainsExpr</term>s. </p>
    
        <p>Nested XQuery 1.0 and XPath 2.0
        expressions are evaluated to a sequence of items before the
        evaluation of <term>FTContainsExpr</term>. The sequence of items must
        satisfy certain constraints depending on the context in which
        it is used. These constraints are described below. </p>
        
        <div3 role="xquery" id="tq-ft-lefthand">
            <head>Left-hand Side of a FTContainsExpr</head>
            
            <p>Full-text queries are performed on text which has been tokenized,
            i.e., broken into a sequence of words, units of punctuation, and
            spaces. The <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#TokenizationSec" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">tokenization</loc> is applied on
            the string value of the evaluation of the left-hand side of the <term>FTContainsExpr</term> 
            expression.
            </p>
            
        </div3>
        
        <div3 role="xquery" id="tq-ft-FTWords">
            <head>FTWords</head>
            
            <p>The XQuery 1.0 and XPath 2.0 expression nested inside an <term>FTWords</term> must
            evaluate to a sequence of string values after applying
            atomization. Otherwise, an error is raised:
            <xerrorref spec="XP" class="TY" code="0004" type="type"/>.  
 			      Then, <term>FTWords</term> performs <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#TokenizationSec" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">tokenization</loc> on the string
            values from the sequence.
            </p>
            
        </div3>
        
        <div3 role="xquery" id="tq-ft-FTRangeSpec">
            <head>FTRangeSpec</head>
            
            <p>The XQuery 1.0 and XPath 2.0 expression, or expressions in the 
			case of a "from-to" range must evaluate to a singleton sequence of
            integers after applying atomization. Otherwise, an error is raised:
            <xerrorref spec="XP" class="TY" code="0004" type="type"/>.  
            The resulting integer values are treated as
            boundaries for the range.</p>
            
        </div3>
        
        <div3 role="xquery" id="semantics-ftstopwordoption">
            <head>FTStopWordOption</head>
            
            <p>The XQuery 1.0 and XPath 2.0 expression. Otherwise, an error is raised:
            <xerrorref spec="XP" class="TY" code="0004" type="type"/>.  
            The resulting string values are treated as
            stop words for which any word may substituted during string
            matching.</p>
            
        </div3>
        
        <div3 role="xquery" id="tq-ft-FTThesaurusOption">
            <head>FTThesaurusOption</head>
            
            <p>The XQuery 1.0 and XPath 2.0 expression must evaluate to a sequence
            of string values after applying atomization. Otherwise, an error is raised:
            <xerrorref spec="XP" class="TY" code="0004" type="type"/>.  
            The resulting string values are treated as 
            names of thesauri to use during string matching.</p>
            
        </div3>
        
        <div3 role="xquery" id="tq-ft-FTLanguageOption">
            <head>FTLanguageOption</head>
            
            <p>The XQuery 1.0 and XPath 2.0 expression must evaluate to either an
            empty sequence or a singleton sequence of a string value
            or an empty sequence after applying atomization. Otherwise, an error is raised:
            <xerrorref spec="XP" class="TY" code="0004" type="type"/>.  
            The resulting string value
            is treated as a language identifier. It specifies the
            language of the words and phrases in the query. </p>
            
        </div3>
        
<!--         <div3 role="xquery" id="tq-ft-FTIgnoreOption">
            <head>FTIgnoreOption</head>
            
            <p>The XQuery sub-expression must evaluate to a sequence of element
            nodes (otherwise the entire &FTSelection; returns an error). The
            resulting element nodes define the nodes whose element tags/content
            must be ignored.</p>
 -->
<!-- Clarification proposals are being added as indicated in
http://lists.w3.org/Archives/Member/member-query-fttf/2004Dec/0072.html-->
<!--
        </div3>
-->
 
        
    <!-- **************************************************************
         *                            Tokenization                       *
         ************************************************************** -->
    <div3 role="xquery" id="TokenizationSec">
        <head>Tokenization</head>
        
        <p><termdef id="TokenizationDef" term="Tokenization"><term>Tokenization</term> is the process of converting
        a string to a sequence of <term>TokenInfo</term>s.</termdef></p>
        
        <p>A <termdef id="TokenInfoDef" term="TokenInfo"><term>TokenInfo</term> is
        the identity of a word occurrence inside an XML document. </termdef>
        Each <term>TokenInfo</term> is
        associated with:</p>
        
        <ulist>
            <item>
                <p>the word it identifies: <code>word</code>
                </p>
            </item>
            <item>
                <p>the unique identifier that captures the relative position of 
                the word in the document order: <code>pos</code></p>
            </item>
            <item>
                <p>the relative position of the sentence containing the word: 
                <code>sentence</code></p>
            </item>
            <item>
                <p>the relative position of the paragraph containing the word: 
                <code>para</code></p>
            </item>
        </ulist>
        
        <p>The tokenization is performed by the formal semantics functions.</p>
        
        <eg role="parse-text" xml:space="preserve">
function fts:getTokenInfo(
             $searchContext as node(),   
             $matchOptions as fts:FTMatchOptions, 
             $searchToken as fts:TokenInfo) 
             as fts:Tokeninfo*
            </eg>
            
        <p>The above function returns the <term>TokenInfo</term>s in nodes in
        <code>$searchContext</code> that match the search string in <code>
        $searchToken</code> when using the match options in <code>$matchOptions
        </code>. The match options that occur at the beginning of the list
        should be applied before match options that occur later in the list.</p>
            
        
        <eg role="parse-text" xml:space="preserve">
function fts:getSearchTokenInfo(
             $searchString as xs:string,
             $matchOptions as fts:FTMatchOptions) 
             as fts:Tokeninfo*
            </eg>
            
        <p>The above function tokenizes the search string <code>$searchString
        </code> and returns a sequence of <term>TokenInfo</term>s that describes the sequence
        of tokens in the search string. If <code>$searchString</code>
        is the empty string, the function is required to return the
        empty sequence. </p>

		<p>This document fragment is the source document for examples in this 
		section. Tokenization is implementation-defined. A sample tokenization 
		is used for the examples in this section. The results might be different 
		for other tokenizations.</p>

		<p>Unless stated otherwise, the results assume a case-insensitive match.</p>
	        
        <eg role="parse-text" xml:space="preserve">
&lt;offers&gt;
    &lt;offer id="1000" price="10000"&gt;
        Ford Mustang 2000, 65K, excellent condition, runs 
        great, AC, CC, power all
    &lt;/offer&gt;
    &lt;offer id="1001" price="8000"&gt;
        Honda Accord 1999, 78K, A/C, cruise control, runs 
        and looks great, excellent condition
    &lt;/offer&gt;
    &lt;offer id="1005" price="5500"&gt;
        Ford Mustang, 1995, 150K highway mileage, no rust, 
        excellent condition
    &lt;/offer&gt;
&lt;/offers&gt;
        </eg>
        
        <p>In this sample tokenization, words are delimited by punctuation and 
		whitespace symbols. The relative position numbers of the <term>TokenInfo</term>s 
		are shown below in parenthesis. </p>

		<ulist>
		
		<item><p>The word "Ford" will be assigned a <term>TokenInfo</term> with 
		relative position of 1.</p></item>

		<item><p>The word "Mustang" will be assigned a <term>TokenInfo</term> with 
		relative position of 2.</p></item>

		<item><p>The word "2000" will be assigned a <term>TokenInfo</term> with a 
		relative position of 3.</p></item>

		<item><p>Relative position numbers are assigned sequentially through the 
		end of the document.</p></item> 

		</ulist>

		<p>The relative positions of the <term>TokenInfo</term>s are shown below in 
		parentheses.</p>
        
        <eg role="parse-text" id="SampleTokenizedDoc" xml:space="preserve">
&lt;offers&gt;
    &lt;offer id="1000" price="10000"&gt;
        Ford(1) Mustang(2) 2000(3), 65K(4), excellent(5)
        condition(6), runs(7) great(8), AC(9), CC(10), 
        power(11) all(12)
    &lt;/offer&gt;
    &lt;offer id="1001" price="8000"&gt;
        Honda(13) Accord(14) 1999(15), 78K(16), A(17)/C(18),
        cruise(19) control(20), runs(21) and(22) looks(23)
        great(24), excellent(25) condition(26)
    &lt;/offer&gt;
    &lt;offer id="1005" price="5500"&gt;
        Ford(27) Mustang(28), 1995(29), 150K(30) highway(31)
        mileage(32), little(33)  rust(34), excellent(35) 
        condition(36)
    &lt;/offer&gt;
&lt;/offers&gt;
        </eg>
        
        <p>The relative positions of paragraphs are determined similarly. In
		this sample tokenization, the paragraph delimiters are start tags, end 
		tags, and end of line characters.</p>
		
		<ulist>
		
		<item><p>The words in the first element will be assigned relative 
		paragraph number 1.</p></item>
		
		<item><p>The words from the next element will be assigned relative  
		paragraph number 2.</p></item>
		
		<item><p>Relative paragraph numbers are assigned sequentially through 
		the end of the document.</p></item>
		
		</ulist>
        
        <p>The relative positions of sentences are determined similarly using 
        sentence delimiters.</p>
        
    </div3>
    </div2>

    
    <!-- ***********************************************
         ***               AllMatches                ***
         *********************************************** -->
    <div2 role="xquery" id="FTSelectionEvalSec">
        <head>Evaluation of FTSelections</head>
        
        <p>The "sequence of nodes" in the XQuery 1.0 and XPath 2.0 Data Model is
        inadequate to support fully composable <term>FTSelection</term>. 
        Full-text operations, such as <term>FTSelection</term>s, operate on linguistic
        units, such as positions of words, and which are not captured
        in the XQuery 1.0 and XPath 2.0 Data Model (XDM). </p>
		
		<p>XQuery 1.0 and XPath 2.0 Full-Text adds relative word, sentence, and 
		paragraph position numbers via <term>AllMatches</term>. <term>AllMatches</term> make 
		<term>FTSelection</term>s fully composable.</p>
        
        <!-- **********************************************************************
         *                            AllMatches                              *
         ********************************************************************** -->
        <div3 role="xquery" id="AllMatchesSec">
            <head>AllMatches</head>

            <div4 role="xquery" id="tq-ft-formalmodel">
                <head>Formal Model</head>
                
                <p>An <termdef id="AllMatchesDef" term="AllMatches"><term>AllMatches</term>
                describes the possible results of an <term>FTSelection</term>.</termdef>
                The UML Static Class diagram of <term>AllMatches</term> is shown
                on the diagram given below.</p>
            
                <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/AllMatchesClassDiagram.png" alt="AllMatches class diagram" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                
                <p>The <term>AllMatches</term> object contains zero or more <term>Match</term>es. </p>
				<p>Each <termdef id="MatchDef" term="Match">
                <term>Match</term> describes one result to the <term>FTSelection</term>.</termdef>
				The result is described in terms of zero or more <term>StringInclude</term>s and zero
                or more <term>StringExclude</term>s</p>
				
                <p><termdef id="StringMatchDef" term="StringMatch"><term>StringInclude</term>s
				and <term>StringExclude</term>s are known collectively as <term>StringMatch</term>,
				which describes a possible match of a search token with a word
				in a document.</termdef> The <term>queryString</term> attribute 
				of <term>StringMatch</term> stores the search token. The <term>queryPos</term> 
				attribute specifies the position of this search token in the 
				query. This attribute is needed for <term>FTOrder</term>s. The matched
				document word is described in the <term>TokenInfo</term> associated with
				the <term>StringMatch</term>.</p>
				
				
				<p><termdef id="StringIncludeDef" term="StringInclude">A <term>StringInclude</term>
				is a <term>StringMatch</term> that describes a <term>TokenInfo</term> that must be
				contained in the document.</termdef></p>
				
				
				<p><termdef id="StringExcludeDef" term="StringExclude">A <term>StringExclude</term>
				is a <term>StringMatch</term> that describes a <term>TokenInfo</term> that must not be
				contained in the document.</termdef></p>
                
                <p>Intuitively, <term>AllMatches</term> specifies the <term>TokenInfo</term>s that a
                node contains and does not contains to satisfy an <term>FTSelection</term>.</p>
                
                <p>The <term>AllMatches</term> structure resembles the Disjunctive Normal
                Form (DNF) in propositional and first-order logic. The
                <term>AllMatches</term> is a disjunction of <term>Match</term>es. Each <term>Match</term> is a
                conjunction of <term>StringInclude</term>s, and <term>StringExclude</term>s. </p>
                
            </div4>

            <div4 role="xquery" id="tq-ft-AllMatches-examples">
                <head>Examples</head>
                
                <p>The simplest example of an <term>FTSelection</term> is an <term>FTWords</term> such 
				as  <code>"Mustang"</code>. The
                <term>AllMatches</term> corresponding to this <term>FTWords</term> is given below. </p>
                
                <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/SampleAllMatches1.jpg" alt="Sample AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                
                <p>As shown, the <term>AllMatches</term> consists of two <term>Match</term>es. Each
                <term>Match</term> represents one possible result of the <term>FTWords</term>
                <code>"Mustang"</code>. The result represented by the first
                <term>Match</term>,represented as <term>StringInclude</term>, contains the word
                "Mustang" at position 2. The result described by the second <term>Match</term>
                contains the word "Mustang" at position 28. </p>
                
                <p>A more complex example of an <term>FTSelection</term> is an <term>FTWords</term> 
				such as <code>"Ford Mustang"</code>. The <term>AllMatches</term> for this 
				<term>FTWords</term> is given below.</p>
                
                <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/SampleAllMatches2.jpg" alt="Sample AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                
                <p>There are two possible results for this <term>FTWords</term>, and
                these are represented by the two <term>Match</term>es. Each of the
                <term>Match</term>es requires two words to be matched. The first <term>Match</term> is 
				obtained by matching "Ford" at position 1 and matching "Mustang" at position 2.
                Similarly, the second <term>Match</term> is obtained by
                matching "Ford" at position 27 and "Mustang" at position 28.</p>
                
                <p>An even more complex example of an <term>FTSelection</term> is an 
				<term>FTSelection</term> such as <code>"Mustang"
                &amp;&amp; ! "rust"</code> that searches for 
                "Mustang" but not "rust". The <term>AllMatches</term> for this
                <term>FTSelection</term> is given below.</p>
                
                <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/SampleAllMatches3.jpg" alt="Sample AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>

                <p>This example introduces <term>StringExclude</term>. <term>StringExclude</term> 
				corresponds to negation in DNF. It specifies that the 
                result described by the corresponding <term>Match</term> must not match the word at 
                the specified position. In this example, the first <term>Match</term> specifies 
                that "Mustang" is matched at position 2, and that the word "rust" 
                at position 34 is not matched .</p>
                
            </div4>
            
        
        <!-- **********************************************************************
             *                            XML Representation                      *
             ********************************************************************** -->
             <div4 id="tq-ft-XML-representation">
                <head>XML representation</head>
            
                <p> <term>AllMatches</term> has a well-defined hierarchical
                structure. Therefore, the <term>AllMatches</term> can be easily
                modeled in XML. 
                This XML representation and those which follow formally describe the
                semantics of <term>FTSelection</term>s. For example, 
                the XML representation of <term>AllMatches</term> formally
                specifies how an <term>FTSelection</term> operates on zero or more
                <term>AllMatches</term> to produce a resulting <term>AllMatches</term>. </p>
                
                <p>The XML schema for representing <term>AllMatches</term> is
                given below.</p>
            
                <eg role="parse-text" xml:space="preserve">
&lt;xs:schema 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     elementFormDefault="qualified" 
     attributeFormDefault="unqualified"&gt;
  &lt;xs:complexType name="AllMatches"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="match" 
                  type="fts:Match" 
                  minOccurs="0" 
                  maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="stokenNum" type="xs:string" use="required" /&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="Match"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="stringInclude" 
                  type="fts:StringMatch" 
                  minOccurs="0" 
                  maxOccurs="unbounded"/&gt;
      &lt;xs:element name="stringExclude" 
                  type="fts:StringMatch" 
                  minOccurs="0" 
                  maxOccurs="unbounded"/&gt;
   &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="StringMatch"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="tokenInfo" type="fts:TokenInfo"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="queryString" 
                  type="xs:string" 
                  use="required"/&gt;
    &lt;xs:attribute name="queryPos" 
                  type="xs:integer" 
                  use="required"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="TokenInfo"&gt;
    &lt;xs:attribute name="word" 
                  type="xs:string" 
                  use="required"/&gt;
    &lt;xs:attribute name="pos" 
                  type="xs:integer" 
                  use="required"/&gt;
    &lt;xs:attribute name="para" 
                  type="xs:integer" 
                  use="required"/&gt;
    &lt;xs:attribute name="sentence" 
                  type="xs:integer" 
                  use="required"/&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:schema&gt;
                </eg>
		
	<p>The <code>stokenNum</code> attribute in 
	<term>AllMatches</term>. is related to the representation of the semantics as XQuery functions. 
	Therefore, it is not considered part of the <term>AllMatches</term> model.
	The <code>stokenNum</code> attribute stores
	the number of search tokens used when evaluating the <term>AllMatches</term>. This 
	value is used to compute the correct value for the <code>queryPos</code>
	attribute in new <term>StringMatch</term>es. </p> 
		
            </div4>
  
			<div4 role="xquery" id="MatchNormalizationSec">
				<head>Match and AllMatches Normal Form</head>
				
				<p><termdef id="MatchNFDEf" term="MatchNormalForm">A <term>Match</term> 
				M is in <term>Match Normal Form</term> if and only if it satisfies the 
				following properties</termdef> </p>
				
				<ulist>
				
				<item><p><termdef id="MatchMinDef" term="MatchMinimality">(<term>Match 
				minimality</term>) M does not contain any duplicate <term>StringInclude</term>s or 
				duplicate <term>StringExclude</term>s. 
				</termdef>, and</p></item>
				
				<item><p><termdef id="MatchNonContraDef" term="MatchNonContra">
            (<term>Match non-contradiction</term>) 
				M does not contain a <term>StringInclude</term> and a 
				<term>StringExclude</term> containing the same <term>TokenInfo</term>
				</termdef></p></item>
				
				</ulist>
				
				<p>Note: two <term>StringMatch</term>es are duplicates of each other, if 
				they have the same <code>queryPos</code> attribute value and 
				their <term>TokenInfo</term>s have the same <code>pos</code> attribute 
				value. Testing for these attributes is sufficient, since all 
				attributes in a <term>TokenInfo</term> are functionally dependent on the 
				<code>pos</code> attribute and <code>queryString</code> depends 
				on <code>queryPos</code>.</p> 

				<p><termdef id="MatchSubsumptionDef" term="MatchSubsumption">
				(<term>Match subsumption</term>) We say that a <term>Match</term> M1 subsumes a
				<term>Match</term> object M2 if the following hold. </termdef></p>
				
				<ulist>
				
				<item><p>The set of <term>StringInclude</term>s in M2 is a subset of the 
				set of <term>StringInclude</term>s in M1, and</p></item>
				
				<item><p>The set of <term>StringExclude</term>s in M2 is a subset of the 
				set of <term>StringExclude</term>s in M1.</p></item>
				
				</ulist>

				<p><termdef id="AllMatchesNFDef" term="AllMatchesNormalForm">
				An <term>AllMatches</term> object A is in <term>AllMatches Normal Form</term> if and 
				only if it satisfies the following properties.
				</termdef></p>
				
				<ulist>
				
				<item><p>Every <term>Match</term> M in A is in Match Normal Form, and </p></item>
				
				<item><p>No <term>Match</term> M contained in A is subsumed by another 
				<term>Match</term> M' contained in A.</p></item>
				
				</ulist>
				
				<p>In other words, in normal-form <term>AllMatches</term> the representations
				of the contained <term>Match</term>es can be viewed as sets, as opposed to
				multi-sets, of <term>StringInclude</term>s and <term>StringExclude</term>s. The
				representations of such <term>AllMatches</term> themselves can be considered
				as sets of alternatives of <term>Match</term>es, where <term>Match</term>es that are
				subsumed by others need not be represented, because such
				subsumed <term>Match</term>es only embody stronger conditions.</p>
				
			</div4>
			
			<div4 id="AMNormallizeFuncSec">
				<head>The <function>normalizeAllMatches</function> function</head>

				<p>The helper function <function>fts:normalizeAllMatches()</function> 
                is used to transform an
				<term>AllMatches</term> object into <term>AllMatches</term> Normal Form. The denotational
				semantics of <term>FTSelection</term>s defined below assures as an invariant
				that any <term>AllMatches</term> produced as a result for an <term>FTSelection</term> is
				in <term>AllMatches</term> Normal Form.</p>

				<p>The normalization of a <term>AllMatches</term> is conducted by normalizing
				each contained <term>Match</term> and then eliminating any <term>Match</term> 
				subsumptions.</p>

				<eg role="parse-text" xml:space="preserve">

declare function fts:normalizeAllMatches(
                    $allMatches as fts:AllMatches) 
                    as element(allMatches, fts:AllMatches) {
   let $mSeq1 := for $m in $allMatches/match 
                 return fts:normalizeMatch($m)
   let $mSeq2 := fts:eliminateMatchSubsumption($mSeq1)
   return &lt;allMatches stokenNum="${$allMatches/@stokenNum}"&gt; 
            {$mSeq2} 
          &lt;/allMatches&gt;
};			
				</eg>
				
				<p>The normalization of a <term>Match</term> is conducted by eliminating
				the duplicate <term>StringMatch</term>es and then eliminating contradictory
				<term>Match</term>es. </p>

				<eg role="parse-text" xml:space="preserve">
declare function fts:normalizeMatch(
                    $match as fts:Match) 
                    as element(match, fts:Match) {
   let $m1 := &lt;match&gt;
                {fts:eliminateStrMatchDupl($match/*, ())}
              &lt;/match&gt;
   return if fts:isMatchContradictory($m1) then ()
          else $m1
};

declare function fts:eliminateStrMatchDupl(
                    $smSeq as fts:StringMatch*, 
                    $resultSoFar as fts:StringMatch*) 
                    as fts:StringMatch* {
   if (fn:count($smSeq) eq 0) then $resultSoFar
   else if (fts:containsStrMatch($resultSoFar, $smSeq[1]) 
         then eliminateStrMatchDupl($smSeq[position() ge 2], 
                                    $resultSoFar)
          else eliminateStrMatchDupl($smSeq[position() ge 2], 
                                     ($resultSoFar, $smSeq[1]))
};

declare function fts:containsStrMatch(
                    $smSeq as fts:StringMatch*, 
                    $strMatch as fts:StringMatch) 
                    as xs:boolean {
   if (fn:count($smSeq) eq 0) then fn:false()
   else if (($smSeq[1] instance of element(stringInclude)) 
            eq ($strMatch instance of element(stringInclude))
            and $smSeq[1]/tokenInfo/@pos 
                 eq $strMatch/tokenInfo/@pos
            and $smSeq[1]/@queryPos 
                eq $strMatch/@queryPos) 
        then fn:true()
        else containsStrMatch($smSeq[position() ge 2], 
                              $strMatch)
};


declare function fts:isMatchContradictory(
                    $match as fts:Match)
                    as xs:boolean {
   some $si in $match/stringInclude 
   satisfies
      let $se := &lt;stringExclude queryPos="{$si/@queryPos}" 
                                queryString="{$si/@queryString}"&gt;
                    {$si/tokenInfo}
                 &lt;/stringExclude&gt;
      return fts:containsStrMatch($match/stringExclude, 
                                  $se)
};

				</eg>

				
				<p>The elimination of <term>Match</term> subsumption is defined as follows.</p>

				<eg role="parse-text" xml:space="preserve">
declare function fts:eliminateMatchSubsumption(
                    $matches as fts:Match*)
                    as fts:Match* {
   for $m at $p in $matches
   let $isNotMin := 
      some $m1 in $matches/match[position() ne $p] 
      satisfies fts:isStrMatchSubset($m1/*, $m/*)
   where fn:not($isNotMin)
   return $m
};

declare function fts:isStrMatchSubset(
                    $smSeq1 as fts:StringMatch*, 
                    $smSeq2 as fts:StringMatch*) 
                    as xs:boolean{
   if (fn:count($smSeq1) eq 0) then fn:true()
   else if (fts:containsStrMatch($smSeq2, $smSeq1[1])) 
        then fts:isStrMatchSubset($smSeq1[position() ge 2], 
                                  $smSeq2)
        else fn:false()
};
				</eg>


			</div4>
			
        </div3>

        
        
    <!-- *************************************************************
         ***                       FTSelections                    ***
         ************************************************************* -->
    <div3 role="xquery" id="FTSelectionsSec">
        <head>FTSelections</head>
        
        <p><term>FTSelection</term>s are fully composable and may be nested arbitrarily under
        other <term>FTSelection</term>s. Each <term>FTSelection</term> may be associated with
        match options (such as stemming and stop words) and score weights.
        Since score weights are solely interpreted by the formal semantics
        scoring function, they do not influence the semantics of
        <term>FTSelection</term>s. Therefore, score weights are not considered in
        the formal semantics.</p>

        <div4 role="xquery" id="FTSelectionsXMLSec">
            <head>XML Representation</head>
            
            <p>The XML representation of the
            <term>FTSelection</term>s used in the 
            <function>fts:evaluate</function> function 
	    closely follows the grammar of the language. It can be viewed as
	    an XML representation of an abstract syntax tree (AST) of a
	    parsed full-text query. Every <term>FTSelection</term>
	    is represented as an XML element. Every nested <term>FTSelection</term> is
	    represented as a nested descendant element. 
	    For binary <term>FTSelection</term>s, e.g. <term>FTAnd</term>, the nested <term>FTSelection</term>s
	    are represented in <code>&lt;left&gt;</code> and <code>&lt;right&gt;
	    </code> descendant elements. For unary <term>FTSelection</term>s, a 
	    <code>&lt;selection&gt;</code> descendant element is used. Additional
	    characteristics of <term>FTSelection</term>s, e.g., the distance unit for
	    <term>FTDistance</term>, are stored in attributes. </p>
            
            <eg role="parse-text" xml:space="preserve">
&lt;xs:schema
     elementFormDefault="qualified" 
     attributeFormDefault="unqualified"&gt;
           
  &lt;xs:include schemaLocation="AllMatches.xsd" /&gt;
  &lt;xs:include schemaLocation="MatchOptions.xsd" /&gt;
           
  &lt;xs:complexType name="FTSelection"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:choice&gt;
        &lt;xs:element name="FTWords" type="fts:FTWords"/&gt;
        &lt;xs:element name="FTAnd" type="fts:FTAnd"/&gt;
        &lt;xs:element name="FTOr" type="fts:FTOr"/&gt;
        &lt;xs:element name="FTUnaryNot" type="fts:FTUnaryNot"/&gt;
        &lt;xs:element name="FTMildNot" type="fts:FTMildNot"/&gt;
        &lt;xs:element name="FTOrder" type="fts:FTOrder"/&gt;
        &lt;xs:element name="FTScope" type="fts:FTScope"/&gt;
        &lt;xs:element name="FTContent" type="fts:FTContent"/&gt;
        &lt;xs:element name="FTDistance" type="fts:FTDistance"/&gt;
        &lt;xs:element name="FTWindow" type="fts:FTWindow"/&gt;
        &lt;xs:element name="FTTimes" type="fts:FTTimes"/&gt;
      &lt;/xs:choice&gt;
      &lt;xs:element name="matchOption" 
                  type="fts:FTMatchOption" 
                  minOccurs="0"/&gt;
      &lt;xs:element name="weight" 
                  type="xs:float" 
                  minOccurs="0"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTWords"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="searchToken" 
                  type="fts:TokenInfo" 
                  minOccurs="0" 
                  maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="type" 
                  type="fts:FTWordsType" 
                  use="required"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTAnd"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="left" type="fts:FTSelection"/&gt;
      &lt;xs:element name="right" type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTOr"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="left" type="fts:FTSelection"/&gt;
      &lt;xs:element name="right" type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTUnaryNot"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="selection" type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTMildNot"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="selection" type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTOrder"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="selection" type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTScope"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="selection" type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="type" 
                  type="fts:ScopeType" 
                  use="required"/&gt;
    &lt;xs:attribute name="scope" 
                  type="fts:ScopeSelector" 
                  use="required"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTContent"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="selection" type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="type" 
                  type="fts:ContentMatchType" 
                  use="required"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTDistance"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="range" type="fts:FTRangeSpec"/&gt;
      &lt;xs:element name="selection" type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="type" 
                  type="fts:DistanceType" 
                  use="required"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTWindow"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="selection" type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="size" 
                  type="xs:integer" 
                  use="required"/&gt;
    &lt;xs:attribute name="type" 
                  type="fts:DistanceType" 
                  use="required"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTTimes"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="range" type="fts:FTRangeSpec"/&gt;
            &lt;xs:element name="selection" 
                        type="fts:FTSelection"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
    
  &lt;xs:complexType name="FTCaseOption"&gt;
    &lt;xs:attribute name="value" use="required"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="lowercase"/&gt;
          &lt;xs:enumeration value="uppercase"/&gt;
          &lt;xs:enumeration value="case insensitive"/&gt;
          &lt;xs:enumeration value="case sensitive"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTRangeSpec"&gt;
    &lt;xs:attribute name="type" 
                  type="fts:RangeSpecType" 
                  use="required"/&gt;
    &lt;xs:attribute name="m" 
                  type="xs:integer"/&gt;
    &lt;xs:attribute name="n" 
                  type="xs:integer" 
                  use="required"/&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:simpleType name="FTWordsType"&gt;
    &lt;xs:restriction base="xs:string"&gt;
      &lt;xs:enumeration value="any"/&gt;
      &lt;xs:enumeration value="all"/&gt;
      &lt;xs:enumeration value="phrase"/&gt;
      &lt;xs:enumeration value="any word"/&gt;
      &lt;xs:enumeration value="all word"/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="ScopeType"&gt;
    &lt;xs:restriction base="xs:string"&gt;
      &lt;xs:enumeration value="same"/&gt;
      &lt;xs:enumeration value="different"/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="ScopeSelector"&gt;
    &lt;xs:restriction base="xs:string"&gt;
      &lt;xs:enumeration value="paragraph"/&gt;
      &lt;xs:enumeration value="sentence"/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="RangeSpecType"&gt;
    &lt;xs:restriction base="xs:string"&gt;
      &lt;xs:enumeration value="exactly"/&gt;
      &lt;xs:enumeration value="at least"/&gt;
      &lt;xs:enumeration value="at most"/&gt;
      &lt;xs:enumeration value="from to"/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="DistanceType"&gt;
    &lt;xs:restriction base="xs:string"&gt;
      &lt;xs:enumeration value="paragraph"/&gt;
      &lt;xs:enumeration value="sentence"/&gt;
      &lt;xs:enumeration value="word"/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  
  &lt;xs:simpleType name="ContentMatchType"&gt;
    &lt;xs:restriction base="xs:string"&gt;
      &lt;xs:enumeration value="at start"/&gt;
      &lt;xs:enumeration value="at end"/&gt;
      &lt;xs:enumeration value="entire content"/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
&lt;/xs:schema&gt;
            </eg>
        
        </div4>


        
        <!-- **********************************************************************
             *                       The evaluate function                        *
             ********************************************************************** -->
        <div4 role="xquery" id="tq-ft-evaluate-function">
            <head>The <function>evaluate</function> function</head>
            
            <p>The denotational semantics for the evaluation of
            <term>FTSelection</term>s is defined using the <function>fts:evaluate</function> 
			function. The function takes in three
            parameters: (1) an <term>FTSelection</term>, 2) a search
            context node, and 3) the default set of match options
            that apply to the evaluation of the <term>FTSelection</term>.</p>
			<p>The <function>fts:evaluate</function> function returns the
            <term>AllMatches</term> that is the result of evaluating the
            <term>FTSelection</term>. When <function>fts:evaluate</function> is applied to some
            <term>FTSelection</term> X, it calls the function
            <function>fts:ApplyX</function> to build the resulting <term>AllMatches</term>.
            If X is applied on nested <term>FTSelection</term>s, the 
            <function>fts:evaluate</function> function is recursively called on these nested
            <term>FTSelection</term>s and the returned <term>AllMatches</term> are used in the evaluation of
            <function>fts:ApplyX</function>.
            </p>
            
            <p>The <function>fts:evaluate</function> function is defined below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function evaluate($ftSelect as element(*, fts:FTSelection), 
                  $searchContext as node(),
                  $matchOptions as FTMatchOptions,
                  $searchTokenNum as xs:integer)
                  as AllMatches
{
 if (fn:count($ftSelect/FTMatchOption) &gt; 0) then 
   (: First we deal with all match options that the    :)
   (: FTSelection might bear: we add the match options :)
   (: in front of the current match options sequence   :)
   (: and pass the new sequence to the recursive call  :)
   let $newFTSelection := 
       $ftSelect/*[!(. instance of element(FTMatchOption))]
   return fts:evaluate($newFTSelection, 
                       $searchContext, 
                       ($ftSelect/matchOption, 
                        $matchOptions),
                       $searchTokenNum)
 else if (fn:count($ftSelect/weight) &gt; 0) then
   (: Weight has no bearing on semantics – just :)
   (: call "evaluate" on nested FTSelection     :)
   let $newFTSelection := $ftSelect/*[! (. instance of 
                                         element(weight)]
   return fts:evaluate($newFTSelection, 
                       $searchContext, 
                       $matchOptions,
                       $searchTokenNum)
 else
   typeswitch ($ftSelect) 
        case ($nftSelection as element(FTWords)) 
             (: Apply the FTWords in the search context :)
             return ApplyFTWords($searchContext,
                                $matchOptions,
                                $nftSelection/searchToken,
                                $searchTokenNum + 1);
        case ($nftSelection as element(FTAnd))
             return let $left = 
                        fts:evaluate($nftSelection/left,
                                     $searchContext,
                                     $matchOptions,
                                     $searchTokenNum)
                    let $newSearchTokenNum = 
                        $left/@stokenNum
                    let $right = 
                        fts:evaluate($nftSelection/right,
                                     $searchContext,
                                     $matchOptions,
                                     $newSearchTokenNum)
                    return ApplyFTAnd($left, $right)
        case ($nftSelection as element(FTOr))
             return let $left = 
                        fts:evaluate($nftSelection/left,
                                     $searchContext,
                                     $matchOptions,
                                     $searchTokenNum)
                    let $newSearchTokenNum = 
                        $left/@stokenNum
                    let $right = 
                        fts:evaluate($nftSelection/right,
                                     $searchContext,
                                     $matchOptions,
                                     $newSarchTokenNum)
                    return ApplyFTOr($left, $right)
        case ($nftSelection as element(FTUnaryNot))
             return applyFTUnaryNot($nftSelection/selection)
        case ($ftSelection as element(FTMildNot))
             return let $left = 
                        fts:evaluate($nftSelection/left,
                                     $searchContext,
                                     $matchOptions,
                                     $searchTokenNum)
                    let $newSearchTokenNum = 
                        $left/@stokenNum
                    let $right = 
                        fts:evaluate($nftSelection/right,
                                     $searchContext,
                                     $matchOptions,
                                     $newSearchTokenNum)
                    return ApplyFTMildNot($left, $right)
        case ($nftSelection as element(FTOrder))
             let $nested := 
                 fts:evaluate($nftSelection/selection,
                              $searchContext,
                              $matchOptions,
                              $searchTokenNum)
             return ApplyFTOrder($nested)
        case ($nftSelection as element(FTScope))
             let $nested := 
                 fts:evaluate($nftSelection/selection,
                              $searchContext,
                              $matchOptions,
                              $searchTokenNum)
             return ApplyFTScope($nftSelection/@type, 
                                 $nftSelection/@scope,
                                 $nested)
        case ($nftSelection as element(FTContent))
             let $nested := 
                 fts:evaluate($nftSelection/selection,
                              $searchContext,
                              $matchOptions,
                              $searchTokenNum)
             return ApplyFTContent($searchContext,
                                   $nftSelection/@type, 
                                   $nested)
        case ($nftSelection as element(FTDistance))
             let $nested := 
                 fts:evaluate($nftSelection/selection,
                              $searchContext,
                              $matchOptions,
                              $searchTokenNum)
             return ApplyFTDistance($matchOptions,
                                    $nftSelection/@type,
                                    $nftSelection/range,
                                    $nested)
        case ($nftSelection as element(FTWindow))
             let $nested := 
                 fts:evaluate($nftSelection/selection,
                              $searchContext,
                              $matchOptions,
                              $searchTokenNum)
             return ApplyFTWindow($matchOptions,
                                  $nftSelection/@type,
                                  $nftSelection/@size,
                                  $nested)
        case ($nftSelection as element(FTTimes))
             let $nested := 
                 fts:evaluate($nftSelection/selection,
                              $searchContext,
                              $matchOptions,
                              $searchTokenNum)
             return ApplyFTTimes($nftSelection/range,
                                     $nested)
}
            </eg>
            
            <p>For
            concreteness, assume that the <term>FTSelection</term> was
            invoked inside an <code>ftcontains</code> expression such
            as <code>searchContext ftcontains ftselection</code>. In order to 
	    determine the
            <term>AllMatches</term> result of <code>ftselection</code>, the
            <function>fts:evaluate</function> function is invoked as
            follows: <code>fts:evaluate($ftselection,
            $searchContext, $matchOptions, 0)</code>, where
            <code>$ftselection</code> is the XML representation of the
            <code>ftselection</code> and
            <code>$searchContext</code> is bound to the result of
            the evaluation of the XQuery expression
            <code>searchContext</code>. </p>
            
            <p>Initially, the
            <code>$searchTokensNum</code> is 0, i.e., no
            search tokens have been processed.</p>
            
            <p>The variable <code>$matchOptions</code> is bound to the 
            list of match options as defined in the static context (see
            Appendix <specref ref="id-xqft-static-context-components"/>).
			Match options embedded in
            <code>ftselection</code> modify the match options collection as
            evaluation proceeds. </p>
			<p>Match options are applied to an <term>FTSelection</term>, 
            organized in a stack. </p>
			
			<ulist>
			
			<item><p>The top match option in the stack is 
            applied first. </p></item>
			<item><p>The second match option is applied next. </p></item> 
			<item><p>Match 
			options are applied sequentially down to the bottom of the stack. 
			</p></item>
			
			</ulist>
			
			<p>Ordering among match options is necessary because match
            options are not always commutative. For example,
            synonym(stem(word)) is not always the same as stem(synonym(word)).
            Naturally, match options may be reordered when they commute, but
            this is an optimization issue and is beyond the scope of this
            document.</p>
			
            <p>Given the invocation of: <code>fts:evaluate($ftselection,
            $searchContext, $matchOptions)</code>, evaluation proceeds as
            follows. First, <code>$ftselection</code> is checked to see whether
            a match option is applied 1) on a nested <term>FTSelection</term>, 2) on a
            weight specification, 3) on an <term>FTWords</term>, or 4) on some other
            <term>FTSelection</term> (case 4). </p>
            
			<olist>
			
			<item>
            <p>If <code>$ftselection</code> contains a match option,
            then it modifies the context for the nested <term>FTSelection</term>.
            Consequently, a new match option element is created and pushed onto
            the top of the stack of match options. The
            <function>createOptionElement</function> function used to create a
            stack element corresponding to the match option creates a
            data structure that stores the type of match option, such as
            stemming, thesaurus,  and the details
            relating to the match option, such as the name of the thesaurus, the
            stop words for which other words may be substituted. The context 
			match option created is added to
            the top of the stack because, in the <term>FTSelection</term>, it was applied
            before the other match options in the current match options stack.
            The <function>evaluate</function> function is then invoked on the
            nested <term>FTSelection</term> with the new match options stack. When the
            function returns, the match option is popped from the stack, and the
            result of the nested <function>evaluate</function> function is
            returned. The match option is popped because the match options
            do not apply to <term>FTSelection</term>s outside its scope. </p></item>
            
            <item><p>If <code>$ftselection</code> contains a weight
            specification, then the specification is ignored because it
            does not alter the semantics. The <function>evaluate</function>
            function is recursively called on the nested <term>FTSelection</term> and the
            resulting <term>AllMatches</term> is returned. </p></item>
            
            <item><p>If <code>$ftselection</code> is an <term>FTWords</term>, then 
			it does
            not have any nested <term>FTSelection</term>s. Consequently, this is the base
            of the recursive call, and the <term>AllMatches</term> result of the <term>FTWords</term>
            is computed and returned. The <term>AllMatches</term> is computed by invoking
            the <function>ApplyFTWords</function> function with the current
            search context and other necessary information. </p></item>
            
            <item><p>If <code>$ftselection</code> contains neither a match
            option nor a weight specification and is not an <term>FTWords</term>, the
            <term>FTSelection</term> performs a full-text operation, such as
            <code>&amp;&amp;</code>, <code>||</code>, <code>window</code>.
            These operations are fully-compositional and may be
            invoked on nested <term>FTSelection</term>s. Consequently, evaluation proceeds
            as follows. </p>
				<ulist>
				<item><p>First, the <function>evaluate</function> function is
            recursively invoked on each nested <term>FTSelection</term>.
				The result of
            evaluating each nested <term>FTSelection</term> is an <term>AllMatches</term>. </p></item>
			<item><p>The <term>AllMatches</term> are transformed into the resulting 
			<term>AllMatches</term> by applying the full-text operation corresponding to 
			<code>FTSelection1</code> which is
            generically named <function>applyX</function> for some type of
            <term>FTSelection</term> X in the code.  </p></item>
				</ulist>
				<p>For example, let
            <code>FTSelection1</code> be <code>FTSelection2 &amp;&amp;
            FTSelection3 </code>. Here <code>FTSelection2</code> and
            <code>FTSelection3</code> may themselves be arbitrarily nested
            <term>FTSelection</term>s. Thus, <function> evaluate</function> is invoked on
            <code>FTSelection2</code> and <code> FTSelection3</code>, and the
            resulting <term>AllMatches</term> are transformed to the final <term>AllMatches</term>
            using the <function> ApplyFTAnd</function> function corresponding to
            <code>&amp;&amp; </code>.</p>
			</item>
            </olist>
            
            <p>The semantics of the <function>ApplyX</function> function for
            each <term>FTSelection</term> kind X are given below.</p>
        </div4>
        
        
        
        <!-- **********************************************************************
             *                     Formal semantics functions                     *
             ********************************************************************** -->
        <div4 role="xquery" id="tq-ft-formal-semantics-functions">
            <head>Formal semantics functions</head>
            
            <p>The formal semantics of the <function>applyX</function>
            functions for each <term>FTSelection</term> kind X are specified in by
            six functions. How these six functions are computed is
            implementation-dependent, but the functions must satisfy some
            well-defined properties. </p>
            
            <p>The <function>getTokenInfo</function> function is
            described in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#TokenizationSec" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">in Section 4.2.7 
			Tokenization</loc>.</p>
            
            <p>The <function>wordDistance</function> function returns the
            number of words that occur between the positions of the
            <term>TokenInfo</term>s <code>$tokenInfo1</code> and
            <code>$tokenInfo2</code>. For example, two consecutive
            words have a distance of 0 words. </p>
            
            <eg role="parse-text" xml:space="preserve">
function fts:wordDistance(
             $tokenInfo1 as fts:TokenInfo,
             $tokenInfo2 as fts:TokenInfo,
             $matchOptions as fts:FTMatchOptions) 
             as xs:integer
            </eg>
            
            <p>The <function>getParaDistance</function> function returns the number of
            paragraphs between the <term>TokenInfo</term>s
            <code>$tokenInfo1</code> and <code>$tokenInfo2</code>.</p>
            
            <eg role="parse-text" xml:space="preserve">
function fts:paraDistance(
             $tokenInfo1 as fts:TokenInfo,
             $tokenInfo2 as fts:TokenInfo,
             $matchOptions as fts:FTMatchOptions) 
             as xs:integer
            </eg>
            
            <p>The <function>sentenceDistance</function> function 
            returns the number of sentences between the
            <term>TokenInfo</term>s <code>$tokenInfo1</code> and
            <code>$tokenInfo2</code>. </p>
            
            <eg role="parse-text" xml:space="preserve">
function fts:sentenceDistance(
             $tokenInfo1 as fts:TokenInfo,
             $tokenInfo2 as fts:TokenInfo,
             $matchOptions as fts:FTMatchOptions) 
             as xs:integer
            </eg>

            <p>The <function>isStartToken</function> function
            returns true if the <term>TokenInfo</term> <code>$tokenInfo</code> 
            describes the first token of the node <code>$searchContext</code>. </p>

            <eg role="parse-text" xml:space="preserve">
function fts:isStartToken(
             $searchContext as node(),
             $tokenInfo as fts:TokenInfo) 
             as xs:boolean
            </eg>

            <p>The <function>isEndToken</function> function
            returns true if the <term>TokenInfo</term> <code>$tokenInfo</code> 
            describes the last words or phrases of the node <code>$searchContext</code>. </p>

            <eg role="parse-text" xml:space="preserve">
function fts:isEndToken(
             $searchContext as node(),
             $tokenInfo as fts:TokenInfo) 
             as xs:boolean
            </eg>
            
        </div4>
        
        
        <!-- **********************************************************************
             *                            FTWords                       *
             ********************************************************************** -->
        <div4 role="xquery" id="tq-ft-fs-FTWords">
            <head>FTWords</head>
            
            <p>If an <term>FTWords</term> consists of a single
            search string, the parameters of the
            <function>applySingleSearchToken </function> function are a) the
            search context, 2) the list of match options, 3) the search
            <term>TokenInfo</term>, and 4) the position where the latter occurs in the query.
            </p>
            
            <p>If after the application of all the match options, the sequence 
			of search tokens returned for an <term>FTWords</term> is empty, an empty
            <term>AllMatches</term> is returned. </p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:applySingleSearchToken(
         $searchContext as node(), 
         $matchOptions as fts:FTMatchOptions, 
         $searchToken as fts:TokenInfo,
         $queryPos as xs:integer) 
         as element(allMatches, fts:AllMatches) 
{
 let $res :=
    &lt;allMatches stokenNum="{$queryPos}"&gt;
       {
        let $token_pos := fts:getTokenInfo($searchContext,
                                           $matchOptions,
                                           $searchToken)
        for $pos in $token_pos
        return 
          &lt;match&gt; 
            &lt;stringInclude queryPos="{$queryPos}" 
                           queryString="{$searchToken/@word}" &gt; 
              {$pos} 
            &lt;/stringInclude&gt;
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>

            <p>The <term>AllMatches</term> corresponding to an
            <term>FTWords</term> corresponds to a set of <term>Match</term>es. Each of <term>Match</term>es
            is associated with a position where the corresponding
            search token was found. For example, the <term>AllMatches</term>
            result for the <term>FTWords</term> "Mustang" is given below. </p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTWordEx.jpg" alt="FTWords example" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
        
			<p>There are five variations of <term>FTWords</term> depending on how the 
			words and phrases in the nested XQuery 1.0 and XPath 2.0 
			expression are matched. </p>
			
			<ulist>
			<item><p>When <code>any word</code> is specified, at 
			least one word in the tokenization of the nested expeession must be 
			matched. </p></item>
			<item><p>When <code>all word</code> is specified, all 
			words in the tokenization of the nested expression must be 
			matched.</p></item>
			<item><p>When <code>phrase</code> is specified, all 
			words in the tokenization of the nested expression must be 
			matched as a phrase.</p></item>
			<item><p>When <code>any</code> is specified, at least one 
			string atomic value in the nested expression must be 
			matched as a phrase.</p></item>
			<item><p>When <code>all</code> is specified, all 
			string atomic values in the nested expression must be 
			matched as a phrase.</p></item>
			</ulist>
           
            <p>The semantics for <term>FTWords</term> when <code>any word</code> is specified 
			are given below. Since <term>FTWords</term>
            does not have nested <term>FTSelection</term>s, the
            <function>ApplyFTWords</function> function does not take 
            <term>AllMatches</term> parameters corresponding to nested
            <term>FTSelection</term> results.</p>

            <eg role="parse-text" xml:space="preserve">
declare function 
fts:MakeDisjunction($curRes as element(allMatches, 
                                       fts:AllMatches),
                    $rest as element(allMatches, 
                                     fts:AllMatches)*) 
                    as element(allMatches, 
                               fts:AllMatches) 
{
 if (fn:count($rest) = 0)
 then $curRes
 else let $firstAllMatches := $rest[1]
      let $restAllMatches := fn-subsequence($rest, 2)
      let $newCurRes := fts:ApplyFTOr($curRes, 
                                      $firstAllMatches)
      return fts:MakeDisjunction($newCurRes, 
                                 $restAllMatches)
}

declare function fts:ApplyFTWordsAnyWord(
         $searchContext as node(), 
         $matchOptions as fts:FTMatchOptions, 
         $searchStrings as xs:string*,
         $queryPos as xs:integer) 
         as element(allMatches, fts:AllMatches) 
{
  let $searchTokens := 
    for $searchString in $searchStrings
    return fts:getSearchTokenInfo($searchString,
                                  $matchOptions)
  return 
    if (fn:count($searchTokens) eq 0) then &lt;allMatches stokenNum="0" /&gt;
    else
      let $allAllMatches = 
        for $searchToken at $pos in $searchTokens
        return fts:applySingleSearchToken(
                   $searchContext,
                   $matchOptions,
                   $searchToken,
                   $queryPos + $pos - 1)
      let $firstAllMatches := $allAllMatches[1]
      let $restAllMatches := fn:subsequence($allAllMatches, 2)
      return fts:MakeDisjunction($firstAllMatches, $restAllMatches)
}
</eg>

            <p>The search strings are tokenized and a single sequence
            that consists of all <term>TokenInfo</term>s is constructed. For each of these,
            the result of <term>FTWords</term> is computed using
            <function>ApplySingleSearchSelection</function>. Finally, the
            conjunction of all resulting <term>AllMatches</term> is computed.</p>
            
            <p>The semantics for <term>FTWords</term> when <code>all word</code> is specified 
			are given below.</p>

            <eg role="parse-text" xml:space="preserve">
declare function 
fts:MakeConjunction($curRes as element(allMatches, 
                                       fts:AllMatches),
                    $rest as element(allMatches, 
                                     fts:AllMatches)*) 
                    as element(allMatches, 
                               fts:AllMatches) 
{
 if (fn:count($rest) = 0)
 then $curRes
 else let $firstAllMatches := $rest[1]
      let $restAllMatches := fn-subsequence($rest, 2)
      let $newCurRes := fts:ApplyFTAnd($curRes, 
                                       $firstAllMatches)
      return fts:MakeConjunction($newCurRes, 
                                 $restAllMatches)
}

declare function fts:ApplyFTWordsAllWord(
         $searchContext as node(), 
         $matchOptions as fts:FTMatchOptions, 
         $searchStrings as xs:string*,
         $queryPos as xs:integer) 
         as element(allMatches, fts:AllMatches) 
{
  let $searchTokens := 
    for $searchString in $searchStrings
    return fts:getSearchTokenInfo($searchString,
                                  $matchOptions)
  return
    if (fn:count($searchTokens) eq 0) then &lt;allMatches stokenNum="0" /&gt;
    else
      let $allAllMatches = 
        for $searchToken at $pos in $searchTokens
        return fts:applySingleSearchToken(
                   $searchContext,
                   $matchOptions,
                   $searchToken,
                   $queryPos + $pos - 1)
      let $firstAllMatches := $allAllMatches[1]
      let $restAllMatches := fn:subsequence($allAllMatches, 2)
      return fts:MakeConjunction($firstAllMatches, $restAllMatches)
}
</eg>

            <p>The semantics for <term>FTWords</term> if <code>phrase</code> is specified 
			are given below.</p>

            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTWordsPhrase(
         $searchContext as node(), 
         $matchOptions as fts:FTMatchOptions, 
         $searchStrings as xs:string*,
         $queryPos as xs:integer) 
         as element(allMatches, fts:AllMatches) 
{
    let $conj := fts:ApplyFTWordsAllWord($searchContext,
                                         $matchOptions,
                                         $searchStrings,
                                         $queryPos)
    let $ordered := fts:ApplyFTOrder($conj)
    let $distance1 := 
        fts:ApplyFTDistance($matchOptions,
                            $ordered,
                            &lt;fts:range type="exactly" n="0"&gt;)
    return $distance1
}
</eg>
            
            <p>The <function>ApplyFTWordsPhrase</function> function is similar 
			to the <function>ApplyFTWordsAllWord</function> function in the case of
            <code>all word</code>. The only differences are that the
            additional <term>FTSelection</term>s <code>ordered</code> and
            <code>distance 0 words</code> are applied.</p>

            <p>The semantics for <term>FTWords</term> when <code>any</code> is specified are 
			given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTWordsAny(
         $searchContext as node(), 
         $matchOptions as fts:FTMatchOptions, 
         $searchStrings as xs:string*,
         $queryPos as xs:integer) 
         as element(allMatches, fts:AllMatches) 
{
 if (fn:count($searchTokens) eq 0) 
 then &lt;allMatches stokenNum="0" /&gt;
 else let $firstSearchString := $searchStrings[1]
      let $restSearchString := fn:subsequence($searchStrings, 2)
      let $firstAllMatches := 
        fts:ApplyFTWordsPhrase($searchContext,
                              $matchOptions,
                              $firstSearchString,
                              $queryPos)
      let $newQueryPos := fn:max($firstAllMatches//@queyrPos) + 1
      let $restAllMatches :=
        fts:ApplyFTWordsAny($searchContext,
                           $matchOptions,
                           $restSearchString,
                           $newQueryPos)
      return fts:ApplyFTOr($firstAllMatches, $resAllMatches)
}
</eg>

            <p>The <term>FTWords</term> with <code>any</code>
            specified forms the disjunction of the <term>AllMatches</term> that
            are the result of the matching of each search token as a phrase.</p>
            
            <p>The semantics for <term>FTWords</term> when <code>all </code> is specified 
			are given below.</p>
			
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTWordsAll(
         $searchContext as node(), 
         $matchOptions as fts:FTMatchOptions, 
         $searchStrings as xs:string*,
         $queryPos as xs:integer) 
         as element(allMatches, fts:AllMatches) 
{
 if (fn:count($searchTokens) = 0) 
 then &lt;allMatches stokenNum="0" /&gt;
 else let $firstSearchString := $searchStrings[1]
      let $restSearchString := fn:subsequence($searchStrings, 2)
      let $firstAllMatches := 
        fts:ApplyFTWordsPhrase($searchContext,
                              $matchOptions,
                              $firstSearchString,
                              $queryPos)
      let $newQueryPos := fn:max($firstAllMatches//@quetyPos) + 1
      let $restAllMatches :=
        fts:ApplyFTWordsAll($searchContext,
                           $matchOptions,
                           $searchStrings,
                           $newQueryPos)
      return fts:ApplyFTAnd($firstAllMatches, $resAllMatches)
}
</eg>

            <p>The difference between <code>all</code> and 
            <code>any</code> is the use of conjunction instead of
            disjunction.</p>
            
            <p>The <function>ApplyFTWords</function> the function that combines
            all of these functions.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function 
  fts:ApplyFTWords($searchContext as Node*, 
                  $matchOptions as fts:FTMatchOptions,
                  $type as element(type, fts:FTWordsType),
                  $searchTokens as xs:string*,
                  $queryPos as xs:integer)
                  as element(allMatches, fts:AllMatches) {
  if ($type eq "any word")
  then fts:ApplyFTWordsAnyWord($searchContext,
                              $matchOptions,
                              $searchTokens,
                              $queryPos)
  else if ($type eq "all word")
  then fts:ApplyFTWordsAllWord($searchContext,
                              $matchOptions,
                              $searchTokens,
                              $queryPos)
  else if ($type eq "phrase")
  then fts:ApplyFTWordsPhrase($searchContext,
                             $matchOptions,
                             $searchTokens,
                             $queryPos)
  else if ($type eq "any")
  then fts:ApplyFTWordsAny($searchContext,
                          $matchOptions,
                          $searchTokens,
                          $queryPos)
  else fts:ApplyFTWordsAll($searchContext,
                          $matchOptions,
                          $searchTokens,
                          $queryPos)
}
                </eg>
        </div4>
        
        
        
        <div4 role="xquery" id="tq-ft-fs-FTOr">
            <!-- **********************************************************************
             *                            FTOr                          *
             ********************************************************************** -->
            <head>FTOr</head>
            <p>The parameters of the <function>ApplyFTOr</function> 
            function are the two <term>AllMatches</term> parameters 
            corresponding to the results of the two nested 
            <term>FTSelection</term>s. The search context and the match
            options stack are not used by this function. The semantics are given 
			below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function 
  fts:ApplyFTOr($allMatches1 as element(allMatches, 
                                        fts:AllMatches),
                $allMatches2 as element(allMatches, 
                                        fts:AllMatches)) 
                as element(allMatches, fts:AllMatches) {
    let res :=
       &lt;allMatches stokenNum="{fn:max(($allMatches1/@stokenNum, 
                                       $allMatches2/@stokenNum))}"&gt;
         ($allMatches1/match 
          $allMatches2/match)
       &lt;/allMatches&gt;
    return fts:normalizeAllMatches($res)
  }
            </eg>
            
            <p>The <function>ApplyFTOr</function> function creates a new <term>AllMatches</term> 
			in which 
            <term>Match</term>es are the union of those found 
            in the input <term>AllMatches</term>. 
			Each <term>Match</term> represents one possible result of the corresponding 
            <term>FTSelection</term>. Thus, a <term>Match</term> from either 
            of the <term>AllMatches</term> is a resukt. </p>
			
            <p>For example, consider the <term>FTSelection</term>
            <code>"Mustang" || "Honda"</code>. The 
			<term>AllMatches</term> corresponding to 
            "Mustang" and "Honda" are given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTOrEx1.jpg" alt="FTOr input AllMatches 1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTOrEx2.jpg" alt="FTOr input AllMatches 2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            
            <p>The <term>AllMatches</term> produced by <function>
            ApplyFTOr</function> is given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTOrEx3.jpg" alt="FTOr result AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
        </div4>
        
        
        
        <div4 role="xquery" id="tq-ft-fs-FTAnd">
            <!-- **********************************************************************
             *                            FTAnd                         *
             ********************************************************************** -->
            <head>FTAnd</head>
            <p>The parameters of the <function>ApplyFTAnd</function> 
            function are the two <term>AllMatches</term>  
            corresponding to the results of the two nested 
            <term>FTSelection</term>s. The search context and the match 
            options are not used by this function. The semantics are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function 
  fts:ApplyFTAnd ($allMatches1 as element(allMatches, 
                                          fts:AllMatches),
                  $allMatches2 as element(allMatches, 
                                          fts:AllMatches)) 
                  as element(allMatches, fts:AllMatches) {
  let res:=
    &lt;allMatches stokenNum="{fn:max(($allMatches1/@stokenNum, 
    				    $allMatches2/@stokenNum))}" &gt;
      {for $sm1 in $allMatches1/match
       for $sm2 in $allMatches2/match
       return &lt;match&gt;
                {$sm1/* $sm2/*}
              &lt;/match&gt;
      }
    &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
} 
            </eg>
            
            <p>The result of the conjunction is a new 
            <term>AllMatches</term> that contains the "Cartesian 
            product" of the matches of the participating 
            <term>FTSelection</term>s. Every resulting <term>Match</term> 
            is formed by the combination of the <term>StringInclude</term> components 
            and <term>StringExclude</term> from the 
            <term>AllMatches</term> of the nested <term>FTSelection</term> 
            . Thus every match contains the positions 
            to satisfy a <term>Match</term> from both original 
            <term>FTSelection</term>s and excludes the positions that 
            violate the same <term>Match</term>es. </p>
            <p>For example, consider the <term>FTSelection</term>
            <code>"Mustang" &amp;&amp; "rust"</code>. The 
			source <term>AllMatches</term> are give below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTAndEx1.jpg" alt="FTAnd input AllMatches 1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTAndEx2.jpg" alt="FTAnd input AllMatches 2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            
            <p>The <term>AllMatches</term> produced by <function>ApplyFTAnd</function> is
			given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTAndEx3.jpg" alt="FTAnd result AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
        </div4>
        
        
        
        <div4 role="xquery" id="tq-ft-fs-FTUnaryNot">
        <!-- **************************************************
             *                  FTUnaryNot                    *
             ************************************************** --> 
        <head>FTUnaryNot</head> 
        
        <p>The parameters of the <function>ApplyFTUnaryNot</function>
        function are 1) the search context, 2) the list of match
        options, and 3) one <term>AllMatches</term> parameter corresponding to the
        result of the nested <term>FTSelection</term> to be negated. The
        search context and the match options are not used by this function. The 
		semantics are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:InvertStringMatch($strm) {
  if ($strm instanceof element(stringExclude)) then
    &lt;stringInclude queryPos="{$strm/@queryPos}"
                   queryString="{$strm/@queryString}"&gt;
      {$strm/docPos}
    &lt;/stringInclude&gt;
  else
    &lt;stringExclude queryPos="{$strm/@queryPos}"
                   queryString="{$strm/@queryString}"&gt;
      {$strm/docPos}
    &lt;/stringInclude&gt;
  }

declare function fts:UnaryNotHelper($sms) {
  let $res :=
     &lt;allMatches stokenNum="{$stokenNum}"&gt;
       {
        for $sm in $sms/match[1]/child::element()
        for $rest in fts:UnaryNotHelper(
                         fn:subsequence($sms/match, 2)/match
        return 
          &lt;match&gt;
            (fts:InvertStringMatch($sm)
             $rest/*)
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}

declare function 
  fts:ApplyFTUnaryNot($allMatches as 
                      element(allMatches, fts:AllMatches))
                      as element(allMatches, 
                                 fts:AllMatches) {
  if ($allMatches/match) then
    {fts:UnaryNotHelper($allMatches)}
  else
    &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
        &lt;match /&gt;
    &lt;/allMatches&gt;
}
            </eg>
            
            <p>The generation of the resulting
            <term>AllMatches</term> of an <term>FTUnaryNot</term> resembles the transformation
            of a negation of prepositional formula in DNF back to DNF.
            The negation of <term>AllMatches</term> requires
            the inversion of all the conditions on the nodes encoded
            by the <term>AllMatches</term> .</p>
            
            <p>In the <function>InvertStringMatch</function> function  above, 
			this inversion occurs as follows. </p>
			<olist>
			
			<item><p>The function <function>fts:invertStringMatch</function>
			inverts a <term>stringInclude </term> into a <term>stringExclude</term> and
			vice versa. </p></item>
			
			<item><p>The function <function>fts:neg_helper</function> transforms
			the source <term>Match</term>es into the resulting <term>Match</term>es by combining a the
			inversions of a <term>StringInclude</term> or <term>StringExclude</term>
			component from every source <term>Match</term> into a new <term>Match</term>.</p></item>
			
            </olist>
			
            <p>For example, consider the <term>FTSelection</term>
            <code>! ("Mustang" || "Honda")</code>. The 
			source <term>AllMatches</term> is given below:</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTNegationEx1.jpg" alt="FTUnaryNot input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                     
            <p>The <term>FTUnaryNot</term> transforms the <term>StringInclude</term>s to 
			<term>StringExclude</term>s as illustrated below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTNegationEx2.jpg" alt="FTUnaryNot result AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
        </div4>
        
        
        
        <!-- **********************************************************************
             *                            FTMildNot                          *
             ********************************************************************** -->
        <div4 role="xquery" id="tq-ft-fs-FTMildNot">
            <head>FTMildNot</head>
            
            <p>The parameters of the <function>ApplyFTMildNot</function>
            function are the two <term>AllMatches</term> parameters corresponding
            to the results of the two nested <term>FTSelection</term>s. The
            search context and the match options stack are not
            used by this function. The semantics are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function 
  fts:ApplyFTMildNot($allMatches1 as 
                       element(allMatches, fts:AllMatches),
                     $allMatches2 as 
                       element(allMatches, fts:AllMatches)) 
                     as element(allMatches, fts:AllMatches){
    if (fn:count($allMatches2//stringExclude) gt 0) then
      fn:error("Invalid expression on the right-hand side of a not-in")
    else
      let res :=
          &lt;allMatches stokenNum="{$allMatches1/@stokenNum}"&gt;
           {let $posSet2 = $allMatches2/match/stringInclude/pos
            return 
              $allMatch1/match[every $pos1 in ./stringInclude/pos,
                                     $pos2 in $posSet2
                               satisfies $pos1 ne $pos2]
           }
          &lt;/allMatches&gt;
      return fts:normalizeAllMatches($res)
  }
            </eg>
            
            <p>The resulting <term>AllMatches</term> contains <term>Match</term>es
            of the first operand that do not mention in their
            <term>stringInclude</term> components positions in a <term>StringInclude</term> component 
			in the <term>AllMatches</term> of the second operand.</p> 
            
            <p>For example, consider the <term>FTSelection</term>
            <code>("Ford" mildnot "Ford
            Mustang")</code>. The
            source <term>AllMatches</term> for the left-hand side argument is given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTMildNegationEx1.jpg" alt="FTMildnot input AllMatches 1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
			<p>The
            source <term>AllMatches</term> for the right-hand side argument is given below.</p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTMildNegationEx2.jpg" alt="FTMildnot input AllMatches 2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                     
            <p>The <term>FTMildNot</term> will transform these to an empty
            <term>AllMatches</term> because both position 1 and position 27 from
            the first <term>AllMatches</term> contain only <term>TokenInfo</term>s from
            <term>stringInclude</term> components of the second
            <term>AllMatches</term>.</p>
            
        </div4>
        
        
        
        <!-- **********************************************************************
             *                                FTOrder                             *
             ********************************************************************** -->
        <div4 role="xquery" id="tq-ft-fs-FTOrder">
            <head>FTOrder</head>
            
            <p>The parameters of the <function>ApplyFTOrder</function>
            function are 1) the search context, 2) the list of match
            options, and 3) one <term>AllMatches</term> parameter corresponding to
            the result of the nested <term>FTSelection</term>s. The evaluation
            context and the match options are not used by this function.
            The semantics are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function 
  fts:ApplyFTOrder($allMatches as element(allMatches, 
                                          fts:AllMatches))
                  as element(allMatches, fts:AllMatches) {
  let $res :=
    &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
      {
       for $match in $allMatches/match
       where every $stringInclude1 in $match,
                   $stringInclude2 in $match    
             satisfies (($stringInclude1/tokenInfo/@pos &lt;= 
                         $stringInclude2/tokenInfo/@pos)
                        and
                        ($stringInclude1/@queryPos &lt;= 
                         $stringInclude2/@queryPos))
                       or
                        (($stringInclude1/tokenInfo/@pos&gt;= 
                          $stringInclude2/tokenInfo/@pos)
                         and
                         ($stringInclude1/@queryPos &gt;= 
                          $stringInclude2/@queryPos))
       return 
         &lt;match&gt;
           {$match/stringInclude}
           {
            for $stringExcl in $match/stringExclude
            where every $stringIncl in $match/stringInclude
                  satisfies (($stringExcl/tokenInfo/@pos &lt;= 
                              $stringIncl/tokenInfo/@pos)
                             and
                              ($stringExcl/@queryPos &lt;= 
                               $stringIncl/@queryPos))
                            or
                             (($stringExcl/tokenInfo/@pos &gt;= 
                               $stringIncl/tokenInfo/@pos)
                              and
                              ($stringExcl/@queryPos &gt;= 
                               $stringIncl/@queryPos))
           }
         &lt;/match&gt;
      }         
    &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
            </eg>
            
            <p>The resulting <term>AllMatches</term> contains the <term>Match</term>es of for which positions 
			in the <term>StringInclude</term> elements are in the order of the
            query positions of their query strings.  
			<term>StringExclude</term>s that preserve the order are also retained.</p>
            
            <p>For example, consider the <term>FTSelection</term>
            <code>("great" &amp;&amp; "condition")
            ordered</code>. The source <term>AllMatches</term> is given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTOrderEx1.jpg" alt="FTOrder input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTOrderEx2.jpg" alt="FTOrder input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTOrderEx3.jpg" alt="FTOrder input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                     
            <p>The <term>AllMatches</term> for <term>FTOrder</term> are given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTOrderEx4.jpg" alt="FTOrder result AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTOrderEx5.jpg" alt="FTOrder result AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
        </div4>
        
        
        
        <!-- **********************************************************************
             *                            FTScope                        *
             ********************************************************************** -->
        <div4 role="xquery" id="tq-ft-fs-FTScope">
            <head>FTScope</head>
            
            <p>The parameters of the <function>ApplyFTScope</function>
            function are 1) the search context, 2) the list of match
            options, 3) the type of the scope (same or different), 4) the
            linguistic unit (sentence or paragraph), and 5) one
            <term>AllMatches</term> parameter corresponding to the result of the
            nested <term>FTSelection</term>s. The search context and the
            match options are not used by this function. The function
            definitions depend on the type of the scope (paragraph,
            sentence) and the scope predicate (same, different).</p>
            
            <p>The semantics of <code>same sentence</code> are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTScopeSameSentence(
      $allMatches as element(allMatches, fts:AllMatches)
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
        {
         for $match in $allMatches/match
         where every $stringInclude1 in $match,
                     $stringInclude2 in $match 
               satisfies $stringInclude1/tokenInfo/@sentence = 
                         $stringInclude2/tokenInfo/@sentence
         return 
           &lt;match&gt;
             {$match/stringInclude}
             {
              for $stringExcl in $match/stringExclude
              where every $stringIncl in $match/stringInclude
                    satisfies $stringIncl/tokenInfo/@sentence = 
                              $stringExcl/tokenInfo/@sentence
             }
           &lt;/match&gt;
        }
     &lt;/allMatches&gt;
   return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>different sentence
            </code> are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTScopeDifferentSentence(
      $allMatches as element(allMatches, fts:AllMatches)
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        where every $stringInclude1 in $match,
                    $stringInclude2 in $match  
              satisfies $stringInclude1 = $stringInclude2 or
                        $stringInclude1/tokenInfo/@sentence != 
                        $stringInclude2/tokenInfo/@sentence
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where every $stringIncl in $match/stringInclude
                   satisfies $stringIncl/tokenInfo/@sentence != 
                             $stringExcl/tokenInfo/@sentence
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>same paragraph</code>, the semantics 
            are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTScopeSameParagraph(
      $allMatches as element(allMatches, fts:AllMatches)
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        where every $stringInclude1 in $match,
                    $stringInclude2 in $match  
              satisfies $stringInclude1/tokenInfo/@para = 
                        $stringInclude2/tokenInfo/@para
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where every $stringIncl in $match/stringInclude
                   satisfies $stringIncl/tokenInfo/@para = 
                             $stringExcl/tokenInfo/@para
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>different paragraph</code> 
            are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTScopeDifferentParagraph(
      $type
      $allMatches as element(allMatches, fts:AllMatches)
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        where every $stringInclude1 in $match,
                    $stringInclude2 in $match  
              satisfies $stringInclude1 = $stringInclude2 or
                        $stringInclude1/tokenInfo/@para != 
                        $stringInclude2/tokenInfo/@para
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where every $stringIncl in $match/stringInclude
                   satisfies $stringIncl/tokenInfo/@para != 
                             $stringExcl/tokenInfo/@para
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of the scope <code>same sentence</code> is for 
			every <term>Match</term> from the <term>AllMatches</term> of the operand, those that 
			contain <term>StringMatch</term>es from
            <term>StringInclude</term> only in the same element
            sentence are filtered out. Those  <term>StringExclude</term>s
            that refer to the same node are retained.</p> 
			<p>The semantics for scope type <code>same paragraph</code> are 
			analogous.</p>
            
            <p>The semantics for the general case are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTScope(
      $type as fts:ScopeType,
      $selector fts:ScopeSelector, 
      $allMatches as element(allMatches, fts:AllMatches)
      ) as element(allMatches, fts:AllMatches) {
  if ($type eq "same" and $selector eq "sentence")
  then fts:ApplyFTScopeSameSentence($allMatches)
  else if ($type eq "different" and $selector eq "sentence")
       then fts:ApplyFTScopeDifferentSentence($allMatches)
  else if ($type eq "same" and $selector eq "paragraph")
       then fts:ApplyFTScopeSameParagraph($allMatches)
  else fts:ApplyFTScopeDifferentParagraph($allMatches)
}
</eg>
            
            <p>For example, consider the <term>FTSelection</term>
            <code>("Mustang" &amp;&amp; "Honda") same 
            paragraph</code>. The source <term>AllMatches</term> is given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTScopeEx.jpg" alt="FTScope input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                     
            <p>The <term>FTScope</term> returns an empty <term>AllMatches</term> because neither 
			<term>Match</term> contains <term>TokenInfo</term>s from a single sentence.</p>
            
        </div4>
        
        
        
        <!-- ***************************************************************
             *                            FTContent                        *
             *************************************************************** -->
        <div4 role="xquery" id="tq-ft-fs-FTContent">
            <head>FTContent</head>
            
            <p>The parameters of the <function>ApplyFTContent</function>
            function are 1) the search context, 2) the match options,
            3) the type of the content
            match at the start of the current node, at the end of it,
            or its entire content, and 4) one
            <term>AllMatches</term> parameter corresponding to the result of the
            nested <term>FTSelection</term>s. The semantics are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTContent(
      $searchContext as node(),
      $matchOptions as element(matchOptions, fts:FTMatchOptions),
      $type as fts:ContentMatchType,
      $allMatches as element(allMatches, fts:AllMatches)
      ) as element(allMatches, fts:AllMatches) {
  if ($type eq "entire content") then
       let $temp1 := fts:ApplyFTWordDistanceExactly(
                        $matchOptions,
                        $allMatches,
                        1)
       let $temp2 := fts:ApplyFTContent(
                        $searchContext,
                        $matchOptions,
                        $temp1,
                        "at start")
       let $temp3 := fts:ApplyFTContent(
                        $searchContext,
                        $matchOptions,
                        $temp2,
                        "at end")
       return $temp3
  else
      let $res :=
         &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
            {
             for $match in $allMatches/match
             where if ($type eq "at start") then
                      some $si in $math/stringInclude
                      satisfies fts:isStartToken($searchContext,
                                                 $si/tokenInfo)
                   else (: $type eq "at end" :) then
                      some $si in $math/stringInclude
                      satisfies fts:isEndToken($searchContext,
                                               $si/tokenInfo)
                   else 
             return {$match}
         &lt;/allMatches&gt;
      return fts:normalizeAllMatches($res)
}
</eg>
            
        <p>The evaluation of scope functions depends on 
        the type of the content match.</p>
		<ulist>
		
		<item><p><code>entire match</code> is evaluated as
		<code>distance exactly 0 words at start at end</code>, i.e. all the
		<term>StringInclude</term>s must match every token in the content of the current
		search context node.</p></item>
		
		
		<item><p><code>at start</code> retains only 
        <term>Match</term>es that contain a <term>StringInclude</term> that matches the 
        first token. This is checked using the semantic function
        <code>fts:isStartToken</code>.</p></item> 
		
		<item><p><code>at end</code> retains the 
        <term>Match</term>es that contain a <term>StringInclude</term> that matches the 
        last token. This is checked using the semantic function
        <code>fts:isEndToken</code>.</p></item>
		
		</ulist>
        </div4>
        
        
        <!-- **********************************************************************
             *                            FTDistance                     *
             ********************************************************************** -->
        <div4 role="xquery" id="tq-ft-fs-FTDistance">
            <head>FTDistance</head>
            
            <p>The parameters of the
            <function>ApplyFTDistance</function> function are 1) the
            search context, 2) the list of match options, 3) one
            <term>AllMatches</term> parameter corresponding to the result of the
            nested <term>FTSelection</term>s, 4) the unit of the distance (words,
            sentences, paragraphs), and 5) the range specified.
            The search context is not used by this function. The
            function definitions depend on the distance units and the range 
			specifications.</p>
            
            <p>The semantics of case <code>word distance exactly N</code> 
			are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTWordDistanceExactly(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer)
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@pos ascending
                      return $si
        where every $idx in (1 to fn:count($sorted) - 1)
              satisfies fts:wordDistance(
                            $sorted[$idx]/tokenInfo,
                            $sorted[$idx+1]/tokenInfo,
                            $matchOptions) = $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:wordDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) = $n
           return $stringExcl
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>word distance at least N</code> are given 
			below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFWordDistanceAtLeast(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@pos ascending
                      return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:wordDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &gt;= $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:wordDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &gt;= $n
           return $stringExcl
            }
          &lt;/match&gt;
       }           
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>word distance at most N</code> are given 
			below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFWordDistanceAtMost(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@Identifier ascending
                      return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:wordDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &lt;= $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:wordDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &lt;= $n
           return $stringExclude
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>word distance from M to N</code> are given 
			below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFWordDistanceFromTo(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $m as xs:integer,
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                     order by $si/tokenInfo/@pos ascending
                     return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:wordDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &gt;= $m 
                        and
                        fts:wordDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &lt;= $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:wordDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &gt;= $m
                             and
                             fts:wordDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &lt;= $n
           return $stringExcl
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
   return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The the semantics of <code>sentence distance exactly N</code> 
			are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFSentenceDistanceExactly(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@pos ascending
                      return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:sentenceDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) = $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:sentenceDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) = $n
           return $stringExcl
            }
          &lt;/match&gt;
       }           
     &lt;/allMatches&gt;
   return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>sentence distance at least N</code> 
			are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFSentenceDistanceAtLeast(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@pos ascending
                      return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:sentenceDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &gt;= $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:sentenceDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &gt;= $n
           return $stringExcl
            }
          &lt;/match&gt;
       }           
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>sentence distance at most N</code> are 
			given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFSentenceDistanceAtMost(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@pos ascending
                      return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:sentenceDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &lt;= $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:sentenceDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &lt;= $n
           return $stringExcl
            }
          &lt;/match&gt;
       }           
     &lt;/allMatches&gt;
   return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of  <code>sentence distance from M to N</code> are 
			given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFSentenceDistanceFromTo(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $m as xs:integer,
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@pos ascending
                     return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:sentenceDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &gt;= $m 
                        and
                        fts:sentenceDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &lt;= $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:sentenceDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &gt;= $m
                             and
                             fts:sentenceDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &lt;= $n
           return $stringExcl
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
   return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>paragraph distance exactly N</code> 
			are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTParagraphDistanceExactly(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@pos ascending
                      return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:paraDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) = $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:paraDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) = $n
           return $stringExcl
            }
          &lt;/match&gt;
       }           
     &lt;/allMatches&gt;
   return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>paragraph distance at least N</code> are 
			given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTParagraphDistanceAtLeast(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@pos ascending
                      return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:paraDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &gt;= $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:paraDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &gt;= $n
           return $stringExcl
            }
          &lt;/match&gt;
       }           
     &lt;/allMatches&gt;
   return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>paragraph distance at most N</code> are 
			given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTParagraphDistanceAtMost(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $si/tokenInfo/@pos ascending
                      return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:paraDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &lt;= $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:paraDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &lt;= $n
           return $stringExcl
            }
          &lt;/match&gt;
       }           
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>paragraph distance from M to N</code> are 
			given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTParagraphDistanceFromTo(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $m as xs:integer,
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt;
       {
        for $match in $allMatches/match
        let $sorted = for $si in $match/stringInclude          
                      order by $sitokenInfo/@pos ascending
                      return $si
        where every $index in in (1 to fn:count($sorted) - 1)
              satisfies fts:paraDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &gt;= $m 
                        and
                        fts:paraDistance(
                            $sorted[$index]/tokenInfo,
                            $sorted[$index+1]/tokenInfo,
                            $matchOptions) &lt;= $n 
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExcl in $match/stringExclude
             where some $stringIncl in $match/stringInclude
                   satisfies fts:paraDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &gt;= $m
                             and
                             fts:paraDistance(
                                 $stringIncl/tokenInfo,
                                 $stringExcl/tokenInfo,
                                 $matchOptions) &lt;= $n
           return $stringExcl
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
   return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The resulting <term>AllMatches</term> contains 
            <term>Match</term>es of the operand that satisfy the condition that
            the distance (measured in words, sentences, or paragraphs)
            for every pair of consecutive positions in
            <term>StringInclude</term>s is within the specified interval.
			<termdef id="ConsecutivePosDef" term="ConsecutivePos"><term>Consecutive 
			Positions</term> in a <term>Match</term> are two positions from the same 
			<term>Match</term> with no intervening <term>StringInclude</term>s.</termdef>
            </p>
            
            <p>In the general case, the semantics are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTDistance(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $type as fts:DistanceType,
      $range as element(range, fts:FTRangeSpec),
      $allMatches as element(allMatches, fts:AllMatches)
      ) as element(allMatches, fts:AllMatches) {
  if ($type eq "word") then
    if ($range/@type eq "exactly") then
      fts:ApplyFTWordDistanceExactly($matchOptions, 
                                     $allMatches, 
                                     $range/@n)
    else if ($range/@type eq "at least") then 
      fts:ApplyFTWordDistanceAtLeast($matchOptions, 
                                     $allMatches, 
                                     $range/@n)
    else if ($range/@type eq "at most") then
      fts:ApplyFTWordDistanceAtMost($matchOptions, 
                                    $allMatches, $
                                    range/@n)
    else fts:ApplyFTWordDistanceFromTo($matchOptions, 
                                       $allMatches, 
                                       $range/@m,
                                       $range/@n)
 else if ($type eq "sentence") then
    if ($range/@type eq "exactly") then
      fts:ApplyFTSentenceDistanceExactly($matchOptions, 
                                         $allMatches, 
                                         $range/@n)
    else if ($range/@type eq "at least") then
      fts:ApplyFTSentenceDistanceAtLeast($matchOptions, 
                                         $allMatches, 
                                         $range/@n)
    else if ($range/@type eq "at most") then
      fts:ApplyFTSentenceDistanceAtMost($matchOptions, 
                                        $allMatches, 
                                        $range/@n)
    else fts:ApplyFTSentenceDistanceFromTo($matchOptions, 
                                           $allMatches, 
                                           $range/@m,
                                           $range/@n)
 else 
    if ($range/@type eq "exactly") then
      fts:ApplyFTParagraphDistanceExactly($matchOptions, 
                                          $allMatches, 
                                          $range/@n)
    else if ($range/@type eq "at least") then
      fts:ApplyFTParagraphDistanceAtLeast($matchOptions, 
                                          $allMatches, 
                                          $range/@n)
    else if ($range/@type eq "at most") then
      fts:ApplyFTParagraphDistanceAtMost($matchOptions, 
                                         $allMatches, 
                                         $range/@n)
    else fts:ApplyFTParagraphDistanceFromTo($matchOptions, 
                                            $allMatches, 
                                            $range/@m,
                                            $range/@n)
}
</eg>
            
            <p>For example, consider the <term>FTDistance</term> selection
            <code>("Ford Mustang" &amp;&amp;
            "excellent") word distance at most 3</code>.
            The <term>Match</term>es of the source <term>AllMatches</term> for
            <code>("Ford Mustang" &amp;&amp;
            "excellent")</code> are given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTDistanceEx1.jpg" alt="FTDistance input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTDistanceEx2.jpg" alt="FTDistance input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTDistanceEx3.jpg" alt="FTDistance input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTDistanceEx4.jpg" alt="FTDistance input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTDistanceEx5.jpg" alt="FTDistance input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTDistanceEx6.jpg" alt="FTDistance input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>

            <p>The result for the <term>FTDistance</term> selection
            consists of only the first <term>Match</term> because the
            distance between consecuive <term>TokenInfo</term>s (distance 1 and
            distance 3) is less than or equal to 3.</p>
            
        </div4>
        
        
        
        <!-- **********************************************************************
             *                            FTWindow                       *
             ********************************************************************** -->
        <div4 role="xquery" id="tq-ft-fs-FTWindow">
            <head>FTWindow</head>
            
            <p>The parameters of the
            <function>ApplyFTWindow</function> function are 1) the
            search context, 2) the list of match options, 3) the unit of
            type <code>fts:DistanceType</code>, 4) a size, and 5) one
            <term>AllMatches</term> parameter 
            corresponding to the result of the nested <term>FTSelection</term>s.
            The search context is not used by this function. For each unit 
			type a function is defined as follows.</p>
            
            <p>The semantics of <code>window N words </code> is given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
define function fts:ApplyFTWordWindow(
      $matchOptions as element(matchOptions, fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches&gt;
      {
       for $match in $allMatches/match
       let $minpos := fn:min($match/*/tokenInfo/@pos),
           $maxpos := fn:max($match/*/tokenInfo/@pos)
        for $windowStartPos in ($minpos to $maxpos-n+1)
        let $windowEndPos := $windowStartPos+n-1
        where fn:min($match/stringInclude/tokenInfo/@pos) &gt;= $windowStartPos
              and fn:max($match/stringInclude/tokenInfo/@pos) &lt;= $windowEndPos
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExclude in $match/stringExclude
             where $stringExclude/tokenInfo/@pos &gt;= $windowStartPos
                   and $stringExclude/tokenInfo/@pos &lt;= $windowEndPos
             return $stringExclude
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>window N sentences</code> is given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
define function fts:ApplyFTSentenceWindow(
      $matchOptions as element(matchOptions, fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches&gt;
      {
       for $match in $allMatches/match
       let $minpos := fn:min($match/*/tokenInfo/@sentence),
           $maxpos := fn:max($match/*/tokenInfo/@sentence)
        for $windowStartPos in ($minpos to $maxpos-n+1)
        let $windowEndPos := $windowStartPos+n-1
        where fn:min($match/stringInclude/tokenInfo/@sentence) &gt;= $windowStartPos
              and fn:max($match/stringInclude/tokenInfo/@sentence) &lt;= $windowEndPos
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExclude in $match/stringExclude
             where $stringExclude/tokenInfo/@sentence &gt;= $windowStartPos
                   and $stringExclude/tokenInfo/@sentence &lt;= $windowEndPos
             return $stringExclude
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>word N paragraphs </code> is given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
define function fts:ApplyFTParagraphWindow(
      $matchOptions as element(matchOptions, fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches&gt;
      {
       for $match in $allMatches/match
       let $minpos := fn:min($match/*/tokenInfo/@para),
           $maxpos := fn:max($match/*/tokenInfo/@para)
        for $windowStartPos in ($minpos to $maxpos-n+1)
        let $windowEndPos := $windowStartPos+n-1
        where fn:min($match/stringInclude/tokenInfo/@para) &gt;= $windowStartPos
              and fn:max($match/stringInclude/tokenInfo/@para) &lt;= $windowEndPos
        return 
          &lt;match&gt;
            {$match/stringInclude}
            {
             for $stringExclude in $match/stringExclude
             where $stringExclude/tokenInfo/@para &gt;= $windowStartPos
                   and $stringExclude/tokenInfo/@para &lt;= $windowEndPos
             return $stringExclude
            }
          &lt;/match&gt;
       }
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The resulting <term>AllMatches</term> contains 
            <term>Match</term>es of the operand that satisfy the condition that
            there exists a sequence of the specified number of
            consecutive (word, sentence, or paragraph) positions, such
            that all <term>StringInclude</term>s are within that window, and the
            <term>StringExclude</term>s retained are also within that window. </p>
            
            <p>The semantics for the general function  are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTWindow(
      $matchOptions as element(matchOptions, 
                               fts:FTMatchOptions),
      $type as fts:DistanceType,
      $size as xs:integer,
      $allMatches as element(allMatches, fts:AllMatches),
      ) as element(allMatches, fts:AllMatches) {
  if ($type eq "word") then
    fts:ApplyFTWordWindow($matchOptions, 
                          $allMatches, 
                          $size)
  else if ($type eq "sentence") then 
    fts:ApplyFTSentenceWindow($matchOptions, 
                              $allMatches, 
                              $size)
  else
    fts:ApplyFTParagraphWindow($matchOptions, 
                               $allMatches, 
                               $size)
}
</eg>
            
            <p>For example, consider the <term>FTWindow</term> selection
            <code>("Ford Mustang" &amp;&amp;
            "excellent") window 10 words</code>.
            The <term>Match</term>es of the source <term>AllMatches</term> for
            <code>("Ford Mustang" &amp;&amp;
            "excellent")</code> are given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTWindowEx1.jpg" alt="FTWindow AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTWindowEx2.jpg" alt="FTWindow AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTWindowEx3.jpg" alt="FTWindow AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTWindowEx4.jpg" alt="FTWindow AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTWindowEx5.jpg" alt="FTWindow AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTWindowEx6.jpg" alt="FTWindow AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                     
            <p>The result for the <term>FTWindow</term> selection 
            consists of only the first, the fifth, and the sixth
            <term>Match</term>es because their respective window sizes are 5, 4,
            and 9.</p>
            
        </div4>
        
        
        
        <!-- *************************************************************
             *                            FTTimes                        *
             ************************************************************* -->
        <div4 role="xquery" id="tq-ft-fs-FTTimes">
            <head>FTTimes</head>
            
            <p>The parameters of the <function>ApplyFTTimes</function>
            function are 1) the search context, 2) the list of match
            options, 3) one <term>AllMatches</term> a range specification, and 4)
            parameter corresponding to the result of the nested
            <term>FTSelection</term>. The search context and the match
            options stack are not used by this function. </p>
            
            <p>The function definitions depend on the range
            specification <term>FTRange</term> to limit the number of
            occurrences.</p>
			
			<p>The general semantics are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:FormCombinations($sms, $times) {
  if (fn:count($sms) lt $times) then ()
  else  if (fn:count($sms) eq $times) then 
      &lt;match&gt; {$sms/*} &lt;/match&gt;
  else 
      {
       fts:FormCombination(fn:subsequence($sms, 2), $times)
       &lt;match&gt;
         {$sms[1]/*}
         {fts:FormCombinations(fn:subsequence($sms, 2),
                               $times-1)/*}
       &lt;/match&gt;
      }
  }

declare function fts::FormRange($sms, $l, $u, $stokenNum) {
   if ($l &gt; $u) then ()
   else 
      let $am1 := fts:normalizeAllMatches(
                     &lt;allMatches stokenNum="{$stokenNum}"&gt;
                      {fts:FormCombinations($sms, $l)}
                     &lt;/allMatches&gt;)
      let $am2 := fts:normalizeAllMatches(
                         &lt;allMatches&gt;
                         {fts:FormCombinations($sms, 
                                               $u+1)}
                         &lt;/allMatches&gt;)
      fts:ApplyFTAnd($am1,
                     fts::ApplyFTUnaryNot($am2)
  }
            </eg>
            
            <p>The semantics of <code>exactly N occurrences</code> are given 
			below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTTimesExactly(
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  fts:FormRange($allMatches/match, $n, $n, $allMatches/@stokenNum)      
}
</eg>
            
            <p>The semantics of <code>at least N occurrences</code> are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTTimesAtLeast(
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  let $res :=
     &lt;allMatches stokenNum="{$allMatches/@stokenNum}"&gt; 
       {fts:formCombinations($allMatches/match, $n)} 
     &lt;/allMatches&gt;
  return fts:normalizeAllMatches($res)
}
</eg>
            
            <p>The semantics of <code>at most N occurrences</code> are given
			below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTTimesAtMost(
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  fts:formRange($allMatches/match, 0, $n, $allMatches/@stokenNum)
}
</eg>
            
            <p>The semantics of <code>from M to N occurrences</code> are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTTimesFromTo(
      $allMatches as element(allMatches, fts:AllMatches),
      $m as xs:integer,
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  fts:formRange($allMatches/match, $m, $n, $allMatches/@stokenNum)  
}
</eg>
            
            <p>The way to ensure that
            there are at least <term>N</term> different matches of an
            <term>FTSelection</term> is to ensure that at least <term>N</term> of
            its <term>Match</term>es occur simultaneously. This is similar to
            forming their conjunction by combining <term>N</term> distinct
            <term>Match</term>es into one simple match. Therefore, the <term>AllMatches</term>
            for the selection condition specifying the range qualifier
            <code>at least N </code> contains the possible
            combinations of <term>N</term> simple matches of the
            operand and one <term>Match</term> for each combination
            negating the rest of the simple matches. This operations
            is performed in the function <function>
            fts:FormCombinations</function>.</p>
            
			<p>The range [l, u] is represented by the condition 
			<code>at least l and not at least l+1</code>.This transformation
            is performed in the function
            <function>fts:FormRange</function>.</p>
            
            <p>The semantics for the general case are given below.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTTimes(
      $range as element(range, fts:FTRangeSpec),
      $allMatches as element(allMatches, fts:AllMatches),
      ) as element(allMatches, fts:AllMatches) {
  if ($range/@type eq "exactly") then
    fts:ApplyFTTimesExactly($allMatches, $range/@n)
  else if ($range/@type eq "at least") then 
    fts:ApplyFTTimesAtLeast($allMatches, $range/@n)
  else if ($range/@type eq "at most") then
    fts:ApplyFTTimesAtMost($allMatches, $range/@n)
  else fts:ApplyFTTimesFromTo($allMatches, 
                              $range/@m, 
                              $range/@n)
}
</eg>
            
            <p>For example, consider the <term>FTTimes</term> selection
            <code>"Mustang" at least 2 occurrences</code>. The source 
			<term>AllMatches</term> of the <term>FTWords</term>
            selection <code>"Mustang"</code> is given below.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTTimesEx1.jpg" alt="FTTimes input AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                     
            <p>The result consists of the pairs of the <term>Match</term>es.</p>
            
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/FTTimesEx2.jpg" alt="FTTimes result AllMatches" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
                     
        </div4>
    </div3>

    
    
    
    <!-- *************************************************************
         ***                  Match Options Semantics              ***
         ************************************************************* -->
    <div3 role="xquery" id="FTMatchOptionsSec">
        <head>Match Options Semantics</head>
        <div4 role="xquery" id="tq-ft-matchopt-types">
            <head>Types</head>
            <p>XQuery 1.0 functions are used to 
            define the semantics of <term>FTMatchOption</term>s. These functions 
            operate on an XML representation of the <term>FTMatchOption</term>s. 
            The representation closely follows the 
            <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftmatchoptions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">syntax</loc>. Each <term>FTMatchOption</term> is 
	    represented by an XML element. Additional characteristics of the match 
	    option are represented as attributes.
	    The schema is given below.</p>
            
            <eg xml:space="preserve">
&lt;xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified"&gt;

  &lt;xs:complexType name="FTMatchOptions"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="matchOption" 
                  type="fts:FTMatchOption"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  
  &lt;xs:complexType name="FTMatchOption"&gt; 
    &lt;xs:choice&gt; 
     &lt;xs:element name="case" 
                 type="fts:FTCaseOption" /&gt;
     &lt;xs:element name="diacritics" 
                 type="fts:FTDiacriticsOption" /&gt;
     &lt;xs:element name="thesaurus" 
                 type="fts:FTThesaurusOption" /&gt;
     &lt;xs:element name="stem" 
                 type="fts:FTStemOption" /&gt;
     &lt;xs:element name="wildcard" 
                 type="fts:FTWildCardOption" /&gt;
     &lt;xs:element name="language" 
                 type="fts:FTLanguageOption" /&gt;
     &lt;xs:element name="stopWord" 
                 type="fts:FTStopwordOption" /&gt; 
    &lt;/xs:choice&gt;
  &lt;/xs:complexType&gt; 
 
 &lt;xs:complexType name="FTCaseOption"&gt;
   &lt;xs:attribute name="caseIndicator"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="insensitive"/&gt;
          &lt;xs:enumeration value="sensitive"/&gt;
          &lt;xs:enumeration value="lowercase"/&gt;
          &lt;xs:enumeration value="uppercase"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;
    &lt;xs:attribute name="caseLanguage" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;

  &lt;xs:complexType name="FTDiacriticsOption"&gt;
    &lt;xs:attribute name="diacriticsIndicator"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="insensitive"/&gt;
          &lt;xs:enumeration value="sensitive"/&gt;
          &lt;xs:enumeration value="with"/&gt;
          &lt;xs:enumeration value="without"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;
    &lt;xs:attribute name="language" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;
           
  &lt;xs:complexType name="FTThesaurusOption"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="thesaurusName" type="xs:string" 
                  minOccurs="0" maxOccurs="1"/&gt;
      &lt;xs:element name="relationship" type="xs:string" 
                  minOccurs="0" maxOccurs="1"/&gt;
      &lt;xs:element name="range" type="fts:FTRangeSpec" 
                  minOccurs="0" maxOccurs="1"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="thesaurusIndicator"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="with"/&gt;
          &lt;xs:enumeration value="without"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;
    &lt;xs:attribute name="language" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;
 
  &lt;xs:complexType name="FTStemOption"&gt;
    &lt;xs:attribute name="stemIndicator"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="with"/&gt;
          &lt;xs:enumeration value="without"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;
    &lt;xs:attribute name="language" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;
 
  &lt;xs:complexType name="FTWildCardOption"&gt;
    &lt;xs:attribute name="wildcardIndicator"&gt;
      &lt;xs:simpleType&gt;
        &lt;xs:restriction base="xs:string"&gt;
          &lt;xs:enumeration value="with"/&gt;
          &lt;xs:enumeration value="without"/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
    &lt;/xs:attribute&gt;
    &lt;xs:attribute name="language" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;
 
  &lt;xs:complexType name="FTLanguageOption"&gt;
    &lt;xs:attribute name="languageName" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;

  &lt;xs:complexType name="FTStopwordOption"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:choice&gt;
        &lt;xs:element name="default-stopwords"&gt;
            &lt;xs:complexType /&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="stop-word" type="xs:string" /&gt;
        &lt;xs:element name="uri" type="xs:anyURI" /&gt;
      &lt;/xs:choice&gt;
      &lt;xs:element name="oper" minOccurs="0" maxOccurs="unbounded"&gt;
        &lt;xs:choice&gt;
            &lt;xs:element name="stop-word" type="xs:string" /&gt;
            &lt;xs:element name="uri" type="xs:anyURI" /&gt;
        &lt;/xs:choice&gt;
        &lt;xs:attribute name="type"&gt;
          &lt;xs:simpleType&gt;
            &lt;xs:restriction base="xs:string"&gt;
              &lt;xs:enumeration value="union"/&gt;
              &lt;xs:enumeration value="except"/&gt;
            &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
        &lt;/xs:attribute&gt;
      &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
 
&lt;/xs:schema&gt;            
</eg>

    <p>An additional schema supports the explicit representation of the concept
    of a phrase. We need this representation to support thesauri lookups. Each
    lookup produces a sequence of phrases. Each phrase is one possible
    alternative for the search string. </p>
	
	<p>The schema for phrases is given below.</p>
	
            <eg xml:space="preserve">
&lt;xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified"&gt;
 
  &lt;xs:complexType name="TokenPhrase"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="token" type="xs:string"  
                  minOccurs="1" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:schema&gt;            
</eg>
        </div4>
        
        <div4 role="xquery" id="tq-ft-matchopt-highlevel">
            <head>High-Level Semantics</head>
            
            <p>The previous section described FTSelections as if no 
            <term>FTMatchOption</term>s were present in the language. In this section, 
			the semantics are extended to support 
            <term>FTMatchOption</term>s.</p> 
            
            <p>The extension is achieved by modifying the existing 
            functions of <term>FTSelection</term>s and adding 
            functions that are specific to the
            <term>FTMatchOption</term>s.</p>
            
			<p><emph>Modifications in the semantics of existing functions</emph></p>
			
            <p>The semantics of most of the
            <term>FTSelection</term>s remains unmodified. The modifications are
            to the method for matching search tokens. </p>

            <p>1. The modifications are to the semantics of <term>FTWords</term> because it
            is most influenced by the <term>FTMatchOption</term>s. Under the
            extended semantics, search tokens are modified
            depending on the <term>FTMatchOption</term>s. For example, in the presence of
            <term>FTThesaurusOption</term> search tokens may be expanded by
            related tokens from a thesaurus lookup.</p>
			
            <eg xml:space="preserve">

declare function fts:applySingleSearchToken(
      $searchContext as node(), 
      $matchOptions as fts:FTMatchOptions,  
      $searchToken as fts:TokenInfo, 
      $queryPos as xs:integer) 
      as element(allMatches, fts:AllMatches) 
{  
   let $withDiacriticsOption :=
       $matchOptions[(fn:local-name(.) eq "diacritics") and
                     (./@type eq "with")][1]
   return 
        if ($withDiacriticsOption) then
              let $newOption1 := &lt;diacritics type="insensitive" /&gt;
              let $newOption2 := &lt;diacritics type="without" /&gt;
              let $lhs := fts:applySingleSearchToken(
                                    $searchContext,
                                    ($newOption1, $matchOptions),
                                    $searchToken,
                                    $queryPos)
              let $rhs := fts:applySingleSearchToken(
                                    $searchContext,
                                    ($newOption2, $matchOptions),
                                    $searchToken,
                                    $queryPos)
              return fts:ApplyMildNot($lhs, $rhs)
        else
           let $thesaurusOption :=
               $matchOptions[(fn:local-name(.) eq "thesaurus") and
                             (./@type eq "with")][1]
           return
           if ($thesaurusOption) then
                let $noThesaurusOption := (&lt;theasurus 
                                           thesaurusIndicator="without" /&gt;,
                                           $matchOptions)
                let $lookupRes := fts:applyThesaurusOption(
                                                $thesaurusOption,
                                                $searchStrings)            
               return fts:ApplyPhraseAlternatives($searchContext,
                                                  $noThesaurusOptions,
                                                  $lookupRes,
                                                  $queryPos)
          else
             let $res :=
                &lt;allMatches stokenNum="{$queryPos}"&gt; 
                  {let $searchTokens :=
                     if ($matchOptions//wildcard) then
                       fts:applyWildCardOption($searchContext,
                                               $matchOptions,
                                               $searchToken)
                     else
                       $searchToken
                   let $effectiveOptions := $matchOptions except 
                                            $matchOptions[self::wildcard]
                   let $token_pos := fts:matchStr($searchContext,
                                                  $effectiveOptions, 
                                                  $searchTokens) 
                   for $pos in $token_pos 
                    return  
                      &lt;match&gt;  
                       &lt;stringInclude queryPos="{$queryPos}" 
                                    queryString="{$searchToken/@word}" &gt; 
                         &lt;tokenInfo&gt;{$pos}&lt;/tokenInfo&gt; 
                       &lt;/stringInclude&gt; 
                     &lt;/match&gt;} 
                 &lt;/allMatches&gt; 
             return fts:normalizeAllMatches($res)
};

declare function fts:ApplyPhraseAlternatives(
         $searchContext as node(), 
         $matchOptions as fts:FTMatchOptions, 
         $searchPhrases as fts:TokenPhrase*,
         $queryPos as xs:integer) 
         as element(allMatches, fts:AllMatches) 
{
 if (fn:count($searchPhrases) eq 0) 
 then &lt;allMatches stokenNum="0" /&gt;
 else let $firstSearchPhrase := $searchPhrase[1]
      let $restSearchPhrases := fn:subsequence($searchPhrases, 2)
      let $firstAllMatches := 
        fts:ApplyFTWordsPhrase($searchContext,
                              $matchOptions,
                              $firstSearchPhrase/word,
                              $queryPos)
      let $newQueryPos :=  fn:max($firstAllMatches//@queyrPos) + 1
      let $restAllMatches :=
        fts:ApplyPhraseAlternatives($searchContext,
                                    $matchOptions,
                                    $restSearchPhrases,
                                    $newQueryPos)
      return fts:ApplyFTOr($firstAllMatches, $resAllMatches)
};
</eg>

    <p>There are several major modifications to the semantics of
    the single-token search with the addition of match option processing. </p>
	
	<p>Three <term>FTMatchOption</term>s are
    processed differently than the rest of the <term>FTMatchOption</term>s. </p>
	
	<ulist>
	
	<item><p>The
    <term>FTDiacriticsOption</term> with type <code>with diacritics</code> is processed as 
	though
    the query is <code>$searchToken/@word diacratics insensitive
    not in $searchToken/@word without diacritics</code>. 
    The desired <term>Match</term>es contain any version of the
    search token except the ones without any diacritics. </p>
	</item>
	
    <item><p>The semantics of the
    <term>FTThesaurusOption</term> cannot
    be represented simply in terms of search token expansion. Since
    the result of a thesaurus lookup is a sequence of alternatives, 
    there must be a higher level of processing. The 
    alternatives are connected in a disjunction using
    the <code>fts:ApplyPhraseAlternatives</code>. The latter function
    is almost identical to <code>fts:ApplyFTWordsAny</code> but
    takes into consideration the specific representation of
    the search tokens in <code>$searchPhrases</code>. 
    The matching of the alternatives is performed with
    <term>FTThesaurusOption</term> turned off to avoid double expansions,
    i.e., expansion of an already expanded token.</p></item>
    
    <item><p><term>FTWildCardOption</term> commutes with all other options and therefore
    it is possible to ignore its position within the <term>FTMatchOption</term>s 
    stack. </p></item>
	
	</ulist>
	
    <p>The remaining <term>FTMatchOption</term>s are processed in the 
    <code>MatchStr</code> function.</p>
	
	<p>The semantics are given below. </p>
    
<eg role="parse-text" xml:space="preserve">
declare function fts:matchStr(
      $searchContext as node(), 
      $matchOptionss as fts:FTMatchOptions,
      $searchToken as fts:TokenInfo)
      as element(tokenInfo, fts:TokenInfo)*
{
   let $nonexpOptions := $matchOptions[self::language or
                                       self::ignore]
   let $expOptions := $matchOptions except $nonexpOptions
   let $searchTokens := applyMatchOptions($matchOptions,
                                         $searchTokens),
                                         $searchTokens
   
   return getTokenInfo($searchContext, 
                       $nonexpOptions, 
                       $searchToken)
}
</eg>

<p>The <function>MatchStr</function> function rewrites search tokens based on
applied <term>FTMatchOption</term>s to obtain the resulting sequence
of <term>TokenInfo</term>s that match the search tokens. <term>FTThesaurusOption</term>s are removed
to avoid repeated theasurus expansion if the <term>FTThesaurusOption</term>s have already 
been applied to the search tokens. </p>

<p>Other <term>FTMatchOption</term>s 
transform the search tokens using the <code>fts:applyMatchOption</code> function. 
Its structure is similar to the <code>fts:evaluate</code> function structure. It 
inspects the supplied <term>FTMatchOption</term>s and applies
them using <term>FTMatchOption</term> functions much like the 
<term>FTSelection</term> functions. These will be discussed later.</p>

<p>One last modification to search token matching is to treat phrases as search
tokens when they are being processed against a thesaurus. This allows phrases as
well as words to be modified using a thesaurus. The semantics to support
multi-token thesaurus lookups are given below.</p>

<eg role="parse-text" xml:space="preserve">
declare function fts:ApplyFTWordsPhrase(
         $searchContext as node(), 
         $matchOptions as fts:FTMatchOptions, 
         $searchStrings as xs:string*,
         $queryPos as xs:integer) 
         as element(allMatches, fts:AllMatches) 
{
   let $thesaurusOption := $matchOptions[fn:local-name(.) eq "thesaurus"][1]
   return if ($thesaurusOption and $thesaurusOption/@type eq "with") then
       let $noThesaurusOptions := $matchOptions[fn:local-name(.) ne "thesaurus"]
       let $lookupRes := fts:applyThesaurusOption($thesaurusOption,
                                                  $searchStrings)
       return fts:ApplyPhraseAlternatives($searchContext,
                                          $noThesaurusOptions,
                                          $lookupRes,
                                          $queryPos)
   else
        let $conj := fts:ApplyFTWordsAllWord($searchContext,
                                             $matchOptions,
                                             $searchStrings,
                                             $queryPos)
        let $ordered := fts:ApplyFTOrder($conj)
        let $distance1 := 
            fts:ApplyFTDistance($matchOptions,
                                $ordered,
                                &lt;fts:range type="exactly" n="0"&gt;)
        return $distance1 
};
</eg>

    <p>Before, the <code>fts:ApplyFTWordsPhrase</code> fucntion is processed 
	an explicit check is conducted for the presence of
    a <term>FTThesaurusOption</term> is done. If a phrase is processed by an 
	<term>FTThesaurusOption</term>, it is processed as in <code>fts:ApplySingleSearchToken</code>.
    </p>

            
	<p><emph>Semantics of new <term>FTMatchOption</term>s functions </emph></p>
	
    <p>The expansion of <term>FTSelection</term>s also includes adding additional functions
    that are specific to the <term>FTMatchOption</term>s. </p>
    
<eg role="parse-text" xml:space="preserve">
declare function fts:applyMatchOption(
      $matchOptions as fts:FTMatchOption*,  
      $searchTokens as fts:TokenInfo*
      ) as element(tokenInfo, fts:TokenInfo)*
{
   if ($matchOptions) then
       let $firstOption := $matchOptions[1]
       let $firstOptionType := fn:local-name($firstOption)
       let $restOptions := $matchOptions[fn:local-name(.) ne $firstOptionType]
       let $applyFirst := fts:applyMatchOption($firstOption, $searchTokens)
       return fts:applyMatchOptions($restOptions, $$applyFirst)
   else $searchTokens
};

declare function fts:applyMatchOption(
      $matchOption as fts:FTMatchOption,  
      $searchTokens as fts:TokenInfo*
      ) as element(tokenInfo, fts:TokenInfo)*
{
   if (fn:local-name($matchOption) eq "stopWord") then
         fts::applyStopWordOption($matchOptions, $searchTokens)
   else if (fn:local-name($matchOption) eq "case")
      return applyCaseOption($matchOption,$searchTokens)
   else if (fn:local-name($matchOption) eq "diacritics")
       return fts:applyDiacriticsOption($matchOption, $searchTokens)
   else if (fn:local-name($matchOption) eq "stem")
       return fts:applyStemOption($matchOption, $searchTokens)
};
</eg>

    <p>The <code>fts:ApplyMatchOptions</code> function
    expands search tokens by the consecutive application of
    the specified <term>FTMatchOption</term>. Once a <term>FTMatchOption</term> of a particular
    type has been applied, other options of the same type are 
    ignored since the former overrides them. </p>
    
    <p>The application of <term>FTMatchOption</term>s is performed by the
    dispatcher function <code>fts:ApplyMatchOption</code> which 
    invokes the respective function implementing the semantics of
    the match option.</p>
        
        </div4>
        
        
        <div4 role="xquery" id="options-sem-functions">
            <head>Formal Semantics Functions</head>
            
            <p><term>FTMatchOption</term> functions which are necessary to support match
            option processing are given below.</p>
			
            <eg xml:space="preserve">
function fts:lowerCase($token as fts:TokenInfo,
                       $caseLanguage as xs:string) 
                       as fts:TokenInfo
            </eg>
            <eg xml:space="preserve">
function fts:upperCase($token as fts:TokenInfo,
                       $caseLanguage as xs:string) 
                       as fts:TokenInfo
            </eg>
            <eg xml:space="preserve">
function fts:insensitiveCase($token as fts:TokenInfo,
                             $caseLanguage as xs:string) 
                             as fts:TokenInfo
            </eg>
            
            <p>These character case functions convert the
            token in a <term>TokenInfo</term> to lowercase, uppercase,
            or case-insensitive form.</p>
            
            <eg xml:space="preserve">
function fts:removeDiacritics(
             $token as fts:TokenInfo,
             $diacriticsLanguage as xs:string) 
             as fts:TokenInfo
            </eg>
            <eg xml:space="preserve">
function fts:insensitiveDiacritics(
             $token as fts:TokenInfo,
             $diacriticsLanguage as xs:string) 
             as fts:TokenInfo
            </eg>
            
            <p>These diacritics functions  convert the
            token in a <term>TokenInfo</term> to a form without diacritics
            or to a diacritics-insensitive form.</p>
            
            <eg xml:space="preserve">
function fts:lookupThesaurus($tokens as fts:TokenInfo*,
                             $thesaurusName as xs:string, 
                             $thesaurusLanguage as xs:string,
                             $relationship as xs:string,
                             $range as fts:FTRanceSpec?) 
                             as element(tokenPhrase, 
                                        fts:TokenPhrase)*
            </eg>
            <p>The thesaurus function finds all words related to 
            <code>$tokens</code>
            in the thesaurus <code>$thesaurusName</code> for the language
            <code>$thesaurusLanguage</code> using the relationship 
            <code>$relationship</code> within the optional number of levels
            <code>$range</code>. If <code>$tokens</code> consists of 
            more than one <term>TokenInfo</term>s, it is regarded as a phrase.
            </p>
            
           <p>The thesaurus function returns a sequence of expansion
           alternatives. Each alternative is regarded as a new search
           phrase and is represented as a tokenized phrase.
           Alternatives are treated as though they are connected with
           a disjunction (<term>FTOr</term>). </p>
          
            <eg xml:space="preserve">
function fts:stemmedForm($word as fts:TokenInfo,
                         $stemLanguage as xs:string) 
                         as fts:TokenInfo
            </eg>
            
            <p>The stemming function converts the
            token in a <term>TokenInfo</term> object to a form that represents
            its stem.</p>
            
            <eg xml:space="preserve">
function fts:wildcardForm($word as fts:TokenInfo,
                       $wildcardLanguage as xs:string) 
                       as fts:TokenInfo*
            </eg>
            
            <p>The wildcard function converts the
            token in a <term>TokenInfo</term> object to a sequence of forms that
            can be used by the tokenizer to match document tokens.</p>
        
        </div4>
        
        <div4 role="xquery" id="tq-ft-matchopt-FTCaseOption">
            <head>FTCaseOption</head>
			
			<p>The semantics for the <term>FTCaseOption</term> are given below.</p>
			
            <eg xml:space="preserve">
declare function 
  fts:applyCaseOption($matchOption as fts:FTMatchOption,  
                      $searchTokens as fts:TokenInfo*) 
                      as fts:TokenInfo*
{
    let $searchToken := $searchTokens[1]
    let $nextTokens := $searchTokens[position() ge 2]

    let $returnedTokens := 
        if ($matchOption/@caseIndicator = "lowercase") then
           (fts:lowerCase($searchToken/@word, $matchOption/@language),
            applyCaseOption($matchOption, $nextTokens))
        else
        if ($matchOption/@caseIndicator = "uppercase") then 
            (fts:upperCase($searchToken, $matchOption/@language),
             applyCaseOption($matchOption, $nextTokens))
        else
        if ($matchOption/@caseIndicator = "insensitive") then
            (insensitiveCase($searchToken, $matchOption/@language),
             applyCaseOption($matchOption, $nextTokens))
        else $searchTokens
   return $returnedTokens
}
            </eg>
        
        </div4>
        
        <div4 role="xquery" id="tq-ft-matchopt-FTDiacriticsOption">
            <head>FTDiacriticsOption</head>
			
			<p>The semantics for the <term>FTDiacriticsOption</term> are given below.</p>
            
            <eg xml:space="preserve">
declare function fts:applyDiacriticsOption(
                     $matchOption as fts:FTMatchOption,  
                     $searchTokens as fts:TokenInfo*) 
                     as fts:TokenInfo*
{
    let $searchToken := $searchTokens[1]
    let $nextTokens := $searchTokens[position() ge 2]
    let $indicator := $matchOption/@diacriticsIndicator
    let $returnedTokens := 
        if ($indicator eq "with") then
            (addDiacritics($searchToken, $matchOption/@language),
             applyDiacriticsOption($matchOption, $nextTokens))
        else if ($indicator eq "without") then
            (removeDiacritics($searchToken, $matchOption/@language),
             applyDiacriticsOption($matchOption, $nextTokens))
        else if ($indicator eq "insensitive") then
            (insensitiveDiacritics($searchToken, $matchOption/@language),
              applyDiacriticsOption($matchOption, $nextTokens))
        else (: $indicator eq "sensitive" :)
            $searchTokens
      return $returnedTokens
}
            </eg>
        
        </div4>        
        
        <div4 role="xquery" id="tq-ft-matchopt-FTStemOption">
            <head>FTStemOption</head>
			
			<p>The semantics for the <term>FTStemOption</term> are given below.</p>
            
            <eg xml:space="preserve">
declare function 
  fts:applyStemOption($matchOption as fts:FTMatchOption,  
                      $searchTokens as fts:TokenInfo*) 
                      as fts:TokenInfo*
{
    if ($matchOption/@stemIndicator = "with") then
      let $searchToken := $searchTokens[1]
      let $nextTokens := $searchTokens[position() ge 2]
      return 
          (stemmedForm($searchToken, $matchOption/@language),
           applyStemOption($matchOption, $nextTokens)
    else if ($matchOption/@stemIndicator = "without") then
           $returnedTokens
         else ()
}
            </eg>
        </div4>

        <div4 role="xquery" id="tq-ft-matchopt-FTStopWordOption">
            <head>FTStopWordOption</head>
			
			<p>Stop-words interact with <term>FTDistance</term> and
			<term>FTWindow</term>. The semantics for the <term>FTStopWordOption</term> are
			given below.</p>
            
            <eg xml:space="preserve">

declare function 
  fts:applyStopwordOption($matchOption as fts:FTMatchOption,  
                          $searchTokens as fts:TokenInfo*) 
                           as fts:TokenInfo*
{
    let $rootElem := fn:local-name($matchOption/element()[1])
    let $rootWords := $matchOption/element()[1]/text()
    let $swords := if ($rootElem eq "stop-word") then
                      $rootWords
                   else
                      fts:resolveStopwordsUri($rootWords)
    let $tokenizedSwords := for $sw in $swords
                            return &lt;tokenInfo word="{$sw}" 
                                              pos="0"
                                              sentence="0"
                                              para="0" /&gt;
    let $restOpers := $matchOption/element()[position() ge 2]
    let $effectiveStopwords := fts:calcStopwords($tokenizedSwords, 
                                                 $resOpers)
    return fts:replaceStopwords($searchTokens, $stopWords)
};

declare function fts:replaceStopwords(
         $searchTokens as fts:TokenInfo*,
         $stopWords as fts:TokenInfo*)
         as fts:TokenInfo* {
   for $stoken in $searchTokens
   let $replace := some $sw in $stopWords 
                   satisfies $stoken/@word eq $stoken/@word
   return if ($replace) then 
             let $newTI := &lt;tokenInfo word=".*"
                                      pos="{$stoken/@pos}"
                                      para="{$stoken/@para}"
                                      sentence="{$stoken/@sentence}"
                           /&gt;
             let $wcOption := &lt;wildcard wildcardIndicator="with" /&gt;
             return fts:applyWildCardOption($wcOption,
                                            $newTI)
          else $stoken
};

declare function fts:addStopwords($stopWords as fts:TokenInfo*, 
                                  $newStopwords as fts:TokenInfo*)
                                  as fts:TokenInfo*
{
    if ($newStopwords) then
        let $firstStopword := $newStopwords[1]
        let $restStopwords := $newStopwords[position() ge 2]
        let $temp :=
            if ($stopWords[@word eq $firstStopword/@word]) then $stopWords
            else ($stopWords, $firstStopword)
        return addStopwords($temp, $restStopwords)
    else $stopWords
};
            
declare function fts:remStopwords($stopWords as fts:TokenInfo*, 
                                  $remStopwords as fts:TokenInfo*)
                                  as fts:TokenInfo*
{
    if ($newStopwords) then
        let $firstStopword := $newStopwords[1]
        let $restStopwords := $newStopwords[position() ge 2]
        let $temp :=
            if ($stopWords[@word eq $firstStopword/@word]) then 
                $stopWords[@word ne $firstStopword]
            else $stopWords
        return remStopwords($temp, $restStopwords)
    else $stopWords
};

declare function fts:calcStopwords($stopWords as fts:TokenInfo*,
                                   $opers)
                                   as fts:TokenInfo*
{
    if ($opers) then
        let $firstOper := $opers[1]
        let $restOpers := $opers[position() ge 2]
        let $operType := $firstOper/@type
        let $operElem := fn:local-name($firstOper/element())
        let $operWords := $firstOper/element()/text()
        let $swords := if ($operElem eq "stop-word") then
                          $operWords
                       else
                          fts:resolveStopwordsUri($operWords)
        return
            if ($operType eq "union") then
                  calcStopwords(fts:addStopword($stopWords, $swords,
                                $restOpers)
            else
                  calcStopwords(fts:remStopword($stopWords, $swords),
                                $restOpers)
    else $stopWords
};
            </eg>
            <p>The stop words set is computed using the
            <code>fts:calcStopwords</code> function. The function uses
            the function <code>fts:resoleStopwordsUri</code> to resolve any URI
            to a sequence of strings. Then, the stop words are
            removed from the set of search tokens. </p>
        </div4>

        <div4 role="xquery" id="tq-ft-matchopt-FTLanguageOption">
            <head>FTLanguageOption</head>
			
		<p>The semantics of <term>FTLanguageOption</term> are not yet finalized.</p>
        
        </div4>

        <div4 role="xquery" id="tq-ft-matchopt-FTWildCardOption">
            <head>FTWildCardOption</head>
			
			<p>The semantics for the <term>FTWildCardOption</term> are given below.</p>
			
            <eg xml:space="preserve">
declare function 
  fts:applyWildCardOption($matchOption as fts:FTMatchOption,  
                          $searchTokens as fts:TokenInfo*) 
                          as xs:TokenInfo*
{
    if ($matchOption/@wildcardIndicator = "with") {
      let $searchToken := $searchTokens[1]
      let $nextTokens := $searchTokens[position() ge 2]
      return 
           wildcardForm($searchToken,
                        $matchOption/@language),
                        applyWildCardOption($matchOption, $nextTokens)
    }
    else if ($matchOption/@wildcardIndicator eq "without") then
            $searchTokens
         else ()
};
            </eg>
        </div4>
        
<!--         <div4 role="xquery" id="tq-ft-matchopt-FTIgnoreOption">
            <head>FTIgnoreOption</head>
            <p>The semantics of this match option is captured in phrase 
            matching,
FTDistance and FTWindow.</p>
        </div4>
 -->
       </div3>
    </div2>
    
    
    <div2 role="xquery" id="FullTextExprSec">
    <head>XQuery 1.0 and XPath 2.0 Full-Text and Scoring Expressions</head>
    
    
    <!-- *************************************************************
         ***                     FTContains                    ***
         ************************************************************* -->
    <div3 role="xquery" id="FTContainsSec">
        <head>FTContainsExpr</head>
        
        <p>The <function>FTContainsExpr</function> function defining the semantics 
		of <term>FTContainsExpr</term> takes the following parameters: 1) a
        search context consisting of a sequence of nodes (which is the result of
        a regular XQuery/XPath expression) and 2) an <term>AllMatches</term> corresponding
        to an <term>FTSelection</term>. The function returns a <code>xs:boolean</code> 
		atomic value. This value is <code>true</code> if and only if some node
		in the search contains satisifes the full-text condition given by the
		<term>FTSelection</term>. Since
        <term>FTContainsExpr</term> returns results in XDM (a sequence of
        items), it may be treated like XQuery 1.0 expressions and may be
        fully composed with other XQuery 1.0 expressions. In addition, since the
        <function>FTContainsExpr</function> function maps <term>AllMatches</term> to a 
		sequence of items, it provides
        semantics for mapping from <term>AllMatches</term> to XDM.</p>
        
        
        <!-- **********************************************************************
             *                    Semantics of FTContainsExpr                     *
             ********************************************************************** -->
        <div4 id="tq-ft-FTContainsExpr">
            <head>Semantics of FTContainsExpr</head>
                        
            <p>Consider an <term>FTContainsExpr</term> expression of the form
            <code>EvaluationContext ftcontains FTSelection</code>,
            where <code>EvaluationContext</code> is an XQuery 1.0
            expression that returns a sequence of nodes and
            <code>FTSelection</code> is an <term>FTSelection</term> that returns
            <term>AllMatches</term>. The <term>FTContainsExpr</term> returns
            true if and only if some node in the result of
            <code>EvaluationContext</code> satisfies the <term>AllMatches</term>
            returned by <code>FTSelection</code>.</p>
	    
	    <p>If the <term>FTContainsExpr</term> is of the form <code>EvaluationContext 
	    ftcontains FTSelection without content IgnoreExpr</code> for
	    some XQuery 1.0 expression <code>IgnoreExpr</code>, then that
	    <term>FTContainsExpr</term> is evaluated as given below. </p>

            <eg role="parse-text" xml:space="preserve">
declare function reconstruct($n as node(), 
                             $ignore as node()*) as node()? {
   if (some $i in $ignore satisfies $n is $i) then ()
   else if ($n instance of element()) then
            let $nodeName := fn:node-name($n)
	    let $nodeContent := for $nn in $n/node()
                                return reconstruct($nn)
	    return element {$nodeName} {$nodeContent}
        else $n
}
	    
let $newEvalContext := 
   let $ignoreNodes := EvaluationContext/IgnoreExpr/text()
   return for $n in EvaluationContext
          return reconstruct($n, $ignoreNodes)
return$newEvalContext ftcontains FTSelection 
            </eg>
	    
	    <p>The <code>EvaluationContext</code> is rewritten so it
	    does not include any text node descendants from nodes that should be
	    ignored.</p>
            
            <p>The XQuery 1.0 and XPath 2.0 <function>FTContainsExpr</function>
			function takes three parameters. </p>
			
			<olist>
			
			<item><p>The sequence of nodes returned by
            <code>EvalationContext</code></p></item>
			
			<item><p>The XML node representation of <code>FTSelection</code></p></item>
			
			
			<item><p>The XML representation of the set of default values for each of the
            <term>FTMatchOption</term>s as given by the static context.</p></item> 
			
			</olist>
			
			<p>The <function>FTContainsExpr</function> function returns true if
			and only if the corresponding <term>FTContainsExpr</term> returns true, and
			thus specifies the semantics of <term>FTContainsExpr</term>. Note that by using
			XQuery 1.0 and XPath 2.0 to specify the formal semantics, we avoid
			the need to introduce new formalism. We simply reuse the formal
			semantics of XQuery 1.0 and XPath 2.0.</p>
            
            <eg role="parse-text" xml:space="preserve">
declare function FTContainsExpr(
                 $searchContext as node()*,
                 $ftSelection as fts:FTSelection,
                 $defOptions as fts:FTMatchOptions)
                 as xs:Boolean 
{ 
 return some $node in $searchContext
        satisfies 
          let $allMatches := fts:evaluate($ftSelection,
                                          $node,
                                          $defOptions,
                                          0)
          return some $match in $allMatches/match
                 satisfies 
                   fn:count($match/stringExclude) eq 0
}
            </eg>
            
            <p>The <function>FTContainsExpr</function> function returns true if and only if the
            <term>AllMatches</term> that is the result of the application of the
            <term>FTSelection</term> for some node in the search context contains a
            <term>Match</term> with no <term>StringExclude</term>s. In other words, there is a set of
            <term>TokenInfo</term>s in that node which satisfy the condition of the
            <term>FTSelection</term>.</p>
            
        </div4>
        
        
        
    <!-- ***************************************************
         ***                    Example                  ***
         *************************************************** -->
        <div4 role="xquery" id="tq-ft-FTContainsExpr-example">
            <head>Example</head>
            
            <p>Consider this more complex example. This example uses the same 
			sample document fragment and assigns it <code>$doc</code>. 
            Consider the following <term>FTContainsExpr</term></p>
            
            <eg role="parse-text" xml:space="preserve">
    $doc ftcontains (
      (
       "mustang" &amp;&amp; (("great" || "excellent") 
       at least 2 occurrences)
      ) window 30 words
      &amp;&amp;
      ! "rust"
    ) same paragraph
</eg>
                
            <p>Begin by evaluating the <term>FTSelection</term> to <term>AllMatches</term>.</p>
            
            <eg role="parse-text" xml:space="preserve">
    (
      (
       "mustang" &amp;&amp; (("great" || "excellent") 
       at least 2 occurrences)
      ) window 30 words
      &amp;&amp;
      ! "rust"
    ) same paragraph
</eg>
                
            <p>Step 1: Evaluate the <term>FTWords</term>
                <code>"Mustang"</code>.
            </p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample01.jpg" alt="Example, step 1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p>Step 2: Evaluate the <term>FTWords</term>
                <code>"great"</code>.
            </p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample02.jpg" alt="Example, step 2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p>Step 3: Evaluate the <term>FTWords</term>
                <code>"excellent"</code>.
            </p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample03.jpg" alt="Example, step 3" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p>Step 4 - Apply the <term>FTOr</term>
                <code>("great" || "excellent")</code> forming 
				a union of the <term>Match</term>es.</p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample04.jpg" alt="Example, step 4" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p>Step 5 - Apply the <term>FTTimes</term>
                <code>("great" || "excellent") at least 2 occurrences</code>
				forming two pairs of <term>Match</term>es</p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample05_1.jpg" alt="Example, step 5.1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample05_1_2.jpg" alt="Example, step 5.1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample05_2.jpg" alt="Example, step 5.2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p>Step 6 - Apply the <term>FTAnd</term>
                <code>"Mustang" 
                &amp;&amp; (("great" || "excellent") at least 2 
                occurrences)</code> forming all possible pairs of <term>StringMatch</term>es.</p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_1.jpg" alt="Example, step 6.1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_1_2.jpg" alt="Example, step 6.1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_2.jpg" alt="Example, step 6.2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_2_2.jpg" alt="Example, step 6.2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_3.jpg" alt="Example, step 6.3" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_3_2.jpg" alt="Example, step 6.3" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_4.jpg" alt="Example, step 6.4" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_4_2.jpg" alt="Example, step 6.4" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_5.jpg" alt="Example, step 6.5" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample06_5_2.jpg" alt="Example, step 6.5" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p>Step 7 - Apply the <term>FTWindow</term>
                <code>("Mustang" 
                &amp;&amp; (("great" || "excellent") 
                at least 2 occurrences)) window 30 words</code>, filtering out <term>Match</term>es 
                for which the window is not less than or equal to 30 words.</p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample07_1.jpg" alt="Example, step 7.1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample07_1_2.jpg" alt="Example, step 7.1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample07_2.jpg" alt="Example, step 7.2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample07_2_2.jpg" alt="Example, step 7.2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p>Step 8 - Evaluate <term>FTWords</term>
                <code>"rust"</code>.
            </p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample08.jpg" alt="Example, step 8" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p>Step 9 - Apply the <term>FTUnaryNot</term>
                <code>! "rust"</code>, 
                transforming the <code>StringInclude</code> into a 
				<code>StringExclude</code>.
            </p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample09.jpg" alt="Example, step 9" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            <p>Step 10 - Apply the <term>FTAnd</term>
                <code>(("Mustang"
                &amp;&amp; (("great" || "excellent") at least 2 occurrences)) 
                window 30 words) &amp;&amp; ! "rust"</code>, forming all
				possible combintations of three <term>StringMatch</term>es from the first
				<term>AllMatches</term> and one <term>StringMatch</term> from the second <term>AllMatches</term>. </p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample10_1.jpg" alt="Example, step 10.1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/><p/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample10_1_2.jpg" alt="Example, step 10.1" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/><p/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample10_2.jpg" alt="Example, step 10.2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/><p/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample10_2_2.jpg" alt="Example, step 10.2" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/><p/>
            <p><emph>Continued on next diagram</emph></p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample10_3.jpg" alt="Example, step 10.3" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/><p/>
            <p>Step 11: Apply the <term>FTScope</term>,  filtering out <term>
                Match</term>es whose <term>TokenInfo</term>s are not within the same paragraph 
				(assuming the <code>&lt;offers&gt;</code> elements determine also
				paragraph boundaries).</p>
            <graphic xmlns:xlink="http://www.w3.org/1999/xlink" source="images/CompleteExample11.jpg" alt="Example, step 11" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
            
            <p>The resulting <term>AllMatches</term> contains a <term>Match</term> 
            that contains a <term>StringExclude</term>. Therefore, the
            sample <term>FTContainsExpr</term> returns <code>false</code>.</p>
            
        </div4>
    
    </div3>
    


    <!-- **********************************************************
         ***                     Scoring                    ***
         *********************************************************** -->
        <div3 role="xquery" id="ScoreSec">
            <head>Scoring</head>
            
            <p>This section addresses the semantics of 
               scoring variables in XQuery 1.0 <code>for</code> and
               <code>let</code> clauses and XPath 2.0 <code>for</code>
               expressions.</p>
			   
			 <p>The scoring variables are a constructed that allows the
			 association of a numeric score with the result of the evaluation
			 of XQuery 1.0 and XPath 2.0 expressions. This numeric score
			 tries to estimate the value of a result item to the user
			 information need expressed using the XQuery 1.0 and XPath 2.0 
			 expression. The numeric score is computed using a implementation-provided <emph>scoring algorithm</emph>.
			 </p>
			 
			 <p>There are numerous scoring algorithms used in practice. Most of
			 the scoring algorithms take as inputs a query and a set of results
			 to the query. In computing the score, these algorithms rely on the
			 structure of the query to estimate the relevance of the results. 
			 </p>
			 
			 <p>In the context of defining the semantics of XQuery 1.0 and XPath
			 2.0 Full-text, passing the structure of the query poses a problem.
			 The query is an XQuery 1.0 and XPath 2.0 expression and an 
			 XQuery 1.0 and XPath 2.0 Full-text expression in particular. The 
			 semantics of XQuery 1.0 and XPath 2.0 expressions is
			 expressed using functions take as arguments sequences of items and
			 return sequences of items. They are not aware of what
			 expression produced a particular sequence, i.e., they are not
			 aware of the expression structure.</p>
			 
			 <p>To define the semantics of scoring in XQuery 1.0 and XPath 2.0
			 Full-text using XQuery 1.0 using the current approach of
			 utilizing XQuery 1.0 and XPath 2.0 itself, it is necessary that
			 the XQuery 1.0 and XPath 2.0 expressions that produce
			 the query result (or the functions that implement the expressions)
			 can be passed as arguments. In other words, there is a necessity
			 for second-order functions. Current XQuery 1.0 and XPath 2.0 do
			 not provide such functions. </p>
			 
             
            <p>Nevertheless, in the interest of the exposition, assume 
               that such second-order functions are present. In particular, that 
               there are two semantic second-order function
               <code>fts:score</code> and <code>fts:scoreSequence</code>
               that take one argument (an expression) and return the
               score value of this expression, respectively a sequence
               of score values, one for each item to which the expression
               evaluates. The scores must satisfy <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#tq-ext-score" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">scoring properties</loc>.</p>
            <p>A <code>for</code> clause containing a score variable
<eg xml:space="preserve">
for $result score $score in Expr
...
</eg>
               is evaluated as
               though it is replaced by the following  the set of clauses
<eg xml:space="preserve">
let $scoreSeq := fts:scoreSequence(Expr)
for $result at $i in Expr
let $score := $scoreSeq[$i]
...
</eg>
               Here, <code>$scoreSeq</code> and <code>$i</code> are
               new variables, not appearing elsewhere, and
               <code>fts:scoreSequence</code> is the 
               second-order function.
            </p>
            <p>Similarly, a <code>let</code> clause containing a score variable
<eg xml:space="preserve">
let $result score $score := Expr
...
</eg>
               is evaluated as
               though it is replaced by the following set of clauses.
<eg xml:space="preserve">
let $result := Expr
let $score := fts:score(Expr)
...
</eg>	
            </p>
        </div3>
    </div2>
    
</div1>

	</body>
	<back id="id-appendices">
	
<div1 id="id-grammar">
		<head>EBNF for XQuery 1.0 Grammar with Full-Text
		extensions</head>

<p>The EBNF in this document and in this section is aligned with
the current XML Query 1.0 grammar (see <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/2005/CR-xquery-20051103/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/2005/CR-xquery-20051103/</loc>).</p>

		<scrap role="non-terminal-structure-expand" headstyle="show"><head/>
<prodrecap ref="BNF-Grammar-prods" role="BNF-Grammar-prods" at="../temp-full-text/temp-xquery-grammar.xml"/>
</scrap>

<div2 id="grammar-terminals"><head>Terminal Symbols</head><scrap headstyle="show">
		    
		  <head/><prodrecap ref="DefinedLexemes" role="DefinedLexemes" at="../temp-full-text/temp-xquery-grammar.xml"/> 
		   
		</scrap>
<p>The following symbols are used only in the definition of
  terminal symbols; they are not terminal symbols in the
  grammar of <specref ref="id-grammar"/>.</p><scrap headstyle="show">
		    
		  <head/><prodrecap ref="LocalTerminalSymbols" at="../full-text/temp-full-text/temp-xquery-grammar.xml" role="LocalTerminalSymbols" id="LocalTerminalSymbols"/> 
		   
		</scrap>
</div2></div1>

	
<div1 id="id-xpath-grammar">
		<head>EBNF for XPath 2.0 Grammar with Full-Text
		extensions</head>

<p>The EBNF in this document and in this section is aligned with
the current XPath 2.0 grammar (see <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/2005/CR-xpath20-20051103/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/2005/CR-xpath20-20051103/</loc>).</p>

		<scrap role="non-terminal-structure-expand" headstyle="show"><head/>
<prodrecap ref="BNF-Grammar-prods" role="BNF-Grammar-prods" at="../temp-full-text/temp-xpath-grammar.xml"/>
</scrap>

<div2 id="xpath-grammar-terminals"><head>Terminal Symbols</head><scrap headstyle="show">
		    
		  <head/><prodrecap ref="DefinedLexemes" role="DefinedLexemes" at="../temp-full-text/temp-xpath-grammar.xml"/> 
		   
		</scrap>
<p>The following symbols are used only in the definition of
  terminal symbols; they are not terminal symbols in the
  grammar of <specref ref="id-xpath-grammar"/>.</p><scrap headstyle="show">
		    
		  <head/><prodrecap ref="LocalTerminalSymbols" at="../full-text/temp-full-text/temp-xpath-grammar.xml" role="LocalTerminalSymbols" id="LocalTerminalSymbols-xpath"/> 
		   
		</scrap>
</div2></div1>

  
<!-- JD
<div1 role="xquery" id="id-xqft-context-components"><head>Context
Components</head><p>The tables in this section describe how values are
assigned to the various components of the static context and dynamic
context, and to the parameters that control the serialization
process.</p>
-->

<div1 id="id-xqft-static-context-components"><head>Static Context
Components</head><p>The following table describes the full-text components of
the <term>static context</term>. The following aspects of each
component are described:</p><ulist><item><p><emph>Default initial
value:</emph> This is the initial value of the component if it is not
overridden or augmented by the implementation or by a query.</p>
</item><item><p><emph>Can be overwritten or augmented by
implementation:</emph> Indicates whether an XQuery implementation is
allowed to replace the default initial value of the component by a
different, <termref def="dt-implementation-defined">implementation-defined</termref> value
and/or to augment the default initial value by additional <termref def="dt-implementation-defined">implementation-defined</termref>
values.</p></item><item><p><emph>Can be overwritten or augmented by a
query:</emph> Indicates whether a query is allowed to replace and/or
augment the initial value provided by default or by the
implementation. If so, indicates how this is accomplished (for
example, by a declaration in the
prolog).</p></item><item><p><emph>Scope:</emph> Indicates where the
component is applicable. "Global" indicates that the component applies
globally, throughout all the modules used in a query. "Module"
indicates that the component applies throughout a <termref def="dt-module">module</termref>. "Lexical" indicates that the
component applies within the expression in which it is defined
(equivalent to "module" if the component is declared in a <termref def="dt-prolog">Prolog</termref>.)</p></item><item><p><emph>Consistency
Rules:</emph> Indicates rules that must be observed in assigning
values to the component. </p></item></ulist><table width="100%" border="1" summary="Static Context" role="small">
<caption>Static Context Components</caption>

<tbody>
<tr>
<th colspan="1" rowspan="1">Component</th> <th colspan="1" rowspan="1">Default initial value</th> <th colspan="1" rowspan="1">Can be
overwritten or augmented by implementation?</th> <th colspan="1" rowspan="1">Can be
overwritten or augmented by a query?</th> <th colspan="1" rowspan="1">Scope</th>
<th colspan="1" rowspan="1">Consistency rules</th>
</tr>

<tr>
<td colspan="1" rowspan="1"><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftcaseoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTCaseOption</loc></td> <td colspan="1" rowspan="1"><code>case
insensitive</code></td> <td colspan="1" rowspan="1">overwriteable</td>
<td colspan="1" rowspan="1">overwriteable by prolog</td> <td colspan="1" rowspan="1">lexical</td> 
<td colspan="1" rowspan="1">Value must be
<code>case insensitive</code> or <code>case sensitive</code>.</td>
</tr>

<tr>
<td colspan="1" rowspan="1"><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftdiacriticsoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTDiacriticsOption</loc></td>
<td colspan="1" rowspan="1"><code>diacritics insensitive</code></td> <td colspan="1" rowspan="1">overwriteable</td> 
<td colspan="1" rowspan="1">overwriteable by prolog</td> <td colspan="1" rowspan="1">lexical</td> 
<td colspan="1" rowspan="1">Value must be <code>diacritics insensitive</code> or
<code>diacritics sensitive</code>.</td>
</tr>

<tr>
<td colspan="1" rowspan="1"><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftstemoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTStemOption</loc></td>
<td colspan="1" rowspan="1"><code>without stemming</code></td> <td colspan="1" rowspan="1">overwriteable</td> 
<td colspan="1" rowspan="1">overwriteable by prolog</td> <td colspan="1" rowspan="1">lexical</td> 
<td colspan="1" rowspan="1">Value must be <code>without stemming</code> or
<code>with stemming</code>.</td>
</tr>

<tr>
<td colspan="1" rowspan="1"><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftthesaurusoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTThesaurusOption</loc></td>
<td colspan="1" rowspan="1"><code>without thesaurus</code></td> <td colspan="1" rowspan="1">overwriteable</td> 
<td colspan="1" rowspan="1">overwriteable by prolog (refer to default to augment)</td> 
<td colspan="1" rowspan="1">lexical</td> 
<td colspan="1" rowspan="1"> Value must be part of the statically known thesauri.</td>
</tr>

<tr>
<td colspan="1" rowspan="1">Statically known thesauri</td>
<td colspan="1" rowspan="1">none</td> <td colspan="1" rowspan="1">augmentable</td> 
<td colspan="1" rowspan="1">cannot be augmented or overwritten by prolog</td> <td colspan="1" rowspan="1">module</td> 
<td colspan="1" rowspan="1"> Each URI uniquely identifies a thesaurus list.</td>
</tr>

<tr>
<td colspan="1" rowspan="1"><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftstopwordoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTStopWordOption</loc></td>
<td colspan="1" rowspan="1"><code>without stopwords</code></td> <td colspan="1" rowspan="1">overwriteable</td> 
<td colspan="1" rowspan="1">overwriteable by prolog (refer to default to augment)</td> 
<td colspan="1" rowspan="1">lexical</td>
<td colspan="1" rowspan="1">Value must be part of the statically known stop word lists.</td>
</tr>

<tr>
<td colspan="1" rowspan="1">Statically known stop word lists</td>
<td colspan="1" rowspan="1">none</td> <td colspan="1" rowspan="1">augmentable</td> 
<td colspan="1" rowspan="1">cannot be augmented or overwritten by prolog</td> <td colspan="1" rowspan="1">module</td> 
<td colspan="1" rowspan="1">Each URI uniquely identifies a stop word list.</td>
</tr>

<tr>
<td colspan="1" rowspan="1"><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftlanguageoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTLanguageOption</loc></td> 
<td colspan="1" rowspan="1">no language is selected</td> <td colspan="1" rowspan="1">overwriteable</td>
<td colspan="1" rowspan="1">overwriteable by prolog</td> <td colspan="1" rowspan="1">lexical</td> 
<td colspan="1" rowspan="1">Value must be castable to "xs:language" or "none".</td>
</tr>

<tr>
<td colspan="1" rowspan="1"><loc xmlns:xlink="http://www.w3.org/1999/xlink" href="#ftwildcardoption" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">FTWildCardOption</loc></td>
<td colspan="1" rowspan="1"><code>without wildcards</code></td> <td colspan="1" rowspan="1">no</td> 
<td colspan="1" rowspan="1">overwriteable by prolog</td> <td colspan="1" rowspan="1">lexical</td>
<td colspan="1" rowspan="1">Value must be <code>without wildcards</code> or <code>without
wildcards</code>.</td>
</tr>

</tbody>
</table>

</div1>


  
<div1 id="id-errors">	
  <head>Error Conditions</head>	

<error-list>

<error spec="XP" code="0004" class="TY" type="type">
<p>It is a type error if, during the static analysis phase,
an expression is found to have a static type
that is not appropriate for the context in which the expression occurs, or during the
dynamic evaluation phase, the dynamic type of a value does not match a required type as
specified by the matching rules in <xspecref spec="XP" ref="id-sequencetype-matching"/>.</p></error>

<error spec="FO" code="0002" class="CH" type="dynamic">
<p>It is a dynamic error if, in a function invocation, the argument corresponding to
the specified function's collation parameter does not identify a supported collation.</p></error>

</error-list>

</div1>
	<div1 id="References">
<head>References</head>
<div2 id="id-normative-references">
<head>Normative References</head>
<blist>
<bibl xmlns:xlink="http://www.w3.org/1999/xlink" id="xquery" key="XQuery 1.0: An XML Query Language" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>

<bibl xmlns:xlink="http://www.w3.org/1999/xlink" id="xpath20" key="XML Path Language (XPath) 2.0" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>

<bibl xmlns:xlink="http://www.w3.org/1999/xlink" id="xpath-functions" key="XQuery 1.0 and XPath 2.0 Functions and Operators" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>

<bibl xmlns:xlink="http://www.w3.org/1999/xlink" id="xqueryft-requirements" key="XQuery and XPath Full-Text Requirements" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"><emph><loc href="http://www.w3.org/TR/xquery-full-text-requirements/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">XQuery
and XPath Full-Text Requirements</loc></emph>,
Stephen Buxton, Michael Rys, Editors. World Wide Web Consortium, 02 May 2003.
This version is http://www.w3.org/TR/2003/WD-xquery-full-text-requirements-20030502/.
The <loc href="http://www.w3.org/TR/xquery-full-text-requirements/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest version</loc>
is available at <loc href="http://www.w3.org/TR/xquery-full-text-requirements/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/xquery-full-text-requirements/</loc>.
</bibl>

<bibl xmlns:xlink="http://www.w3.org/1999/xlink" id="xmlquery-full-text-use-cases" key="XQuery 1.0 and XPath 2.0 Full-Text Use Cases" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>

<!--  <bibl id="xqueryft-usecases" key="XQuery 1.0 and XPath 2.0 Full-Text Use Cases"><emph><loc href="http://www.w3.org/TR/xmlquery-full-text-use-cases/">XQuery 1.0 and XPath 2.0 Full-Text Use Cases</loc></emph>, -->
<!--  Sihem Amer-Yahia, Pat Case, Editors. World Wide Web Consortium, 04 April 2005. -->
<!--  This version is http://www.w3.org/TR/2004/WD-xmlquery-full-text-use-cases-20040709/. The -->
<!--  <loc href="http://www.w3.org/TR/xmlquery-full-text-use-cases/">latest version</loc> is available at -->
<!--  <loc href="http://www.w3.org/TR/xmlquery-full-text-use-cases/">http://www.w3.org/TR/xmlquery-full-text-use-cases/.</loc> -->
<!--  </bibl> -->

</blist>
</div2>
<div2 id="id-non-normative-references">
<head>Non-normative References</head>
<blist>

<bibl xmlns:xlink="http://www.w3.org/1999/xlink" id="iso-2788" key="ISO 2788" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
Documentation Guidelines for the Establishment and Development of
Monolingual Thesauri, Geneva: International Organization for
Standardization, 2nd edition, 1986.
</bibl>


<bibl xmlns:xlink="http://www.w3.org/1999/xlink" id="sqlmm" key="SQL/MM" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"> ISO/IEC 13249-2 Information technology
--- Database languages --- SQL Multimedia and Application Packages ---
Part 2: Full-Text. Geneva: International Organization for
Standardization, 2nd edition, 2003.
</bibl>


</blist>
</div2>
</div1>

  <inform-div1 id="ft-acknowledgements">
	<head>Acknowledgements</head>

<p>We would like to thank the members of the XQuery and XPath
Full-Text group for their fruitful discussions. </p>

<p>We would like to thank the following people for their contributions on earlier drafts of this document.</p>

<ulist>
  <item><p> "Andrew Eisenberg" - IBM - andrew.eisenberg@us.ibm.com</p></item>
  <item><p> "Roland Seiffert" - IBM -  seiffert@de.ibm.com</p></item>
  <item><p> "Andrew Cencini" - Microsoft - acencini@microsoft.com </p></item>
  <item><p> "Nimish Khanolkar" - Microsoft - nimishk@exchange.microsoft.com </p></item>
  <item><p> "Ashok Malhotra" Oracle - ashok.malhotra@oracle.com </p></item>
  <item><p> "Tapas Nayak" Microsoft - tapasnay@exchange.microsoft.com </p></item>
</ulist>
</inform-div1>

  <inform-div1 id="ft-glossary">
	<head>Glossary</head>

<p> This section contains definitions of important terms in this document. </p>

<p>Certain aspects of language
		processing are described in this specification as
		<term>implementation-defined</term> or
		<term>implementation-dependent</term>.</p>

<ulist>
  <item>
    <p><termdef id="dt-implementation-defined" term="implementation defined"><term>Implementation-defined</term>
		indicates an aspect that may differ between
		implementations, but must be specified by the
		implementor for each particular
		implementation.</termdef></p>
  </item>
  <item>
    <p><termdef id="dt-implementation-dependent" term="implementation   dependent"><term>Implementation-dependent</term>
		indicates an aspect that may differ between
		implementations, is not specified by this or any W3C
		specification, and is not required to be specified by
		the implementor for any particular
		implementation.</termdef></p>
  </item>
</ulist>

<p><termdef id="dt-module" term="module">A <term>module</term> is a 
  fragment of XQuery code that conforms to
  the module grammar defined in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/TR/xquery/#doc-xquery-Module" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">XQuery 1.0: An
  XML Query Language draft</loc>.</termdef> Each module is either a <termref def="dt-main-module">main module</termref> or a <termref def="dt-library-module">library module</termref>.
</p>
<p><termdef id="dt-main-module" term="main module">A <term>main
  module</term> consists of a <termref def="dt-prolog">Prolog</termref>
  followed by a <termref def="dt-queryBody">Query
  Body</termref>.</termdef> A query has exactly one main module. In a
  main module, the <termref def="dt-queryBody">Query Body</termref> can
  be evaluated, and its value is the result of the query.
</p>
<p><termdef id="dt-library-module" term="library module">A module that does not
  contain a <termref def="dt-queryBody">Query Body</termref> is called a
  <term>library module</term>. A library module consists of a <termref def="dt-module-declaration">module declaration</termref> followed by a
  <termref def="dt-prolog">Prolog</termref>.</termdef> A library module
  cannot be evaluated directly; instead, it provides function and
  variable declarations that can be imported into other
  modules.
</p>
<p>The XQuery syntax does not allow a <termref def="dt-module">module</termref> to contain both a <termref def="dt-module-declaration">module declaration</termref> and a
<termref def="dt-queryBody">Query Body</termref>.
</p>
<p><termdef id="dt-prolog" term="Prolog">A <term>Prolog</term> is a series of
  declarations and imports that define the processing environment for
  the <termref def="dt-module">module</termref> that contains the
  Prolog.</termdef> Each declaration or import is followed by a
  semicolon. A Prolog is organized into two parts. 
</p>
<p>
  The first part of the Prolog consists of setters, imports, 
  namespace declarations, and default namespace declarations. 
  <termdef term="setter" id="dt-setter"><term>Setters</term> are 
  declarations that set the value of some property that affects query 
  processing, such as construction mode, ordering mode, or default 
  collation.</termdef>
  Namespace declarations and default namespace declarations affect the
  interpretation of QNames within the query.  Imports are used to import
  definitions from schemas and modules. <termdef term="target namespace" id="dt-target-namespace">Each imported schema or module is identified
  by its <term>target namespace</term>, which is the namespace of the
  objects (such as elements or functions) that are defined by the schema
  or module.</termdef> 
</p>
<p>The second part of the Prolog consists of
  declarations of variables, functions, and options. These declarations
  appear at the end of the Prolog because they may be affected by
  declarations and imports in the first part of the
  Prolog.
</p>
<p><termdef id="dt-queryBody" term="query body">The
  <term>Query Body</term>, if present, consists of an expression that
  defines the result of the query</termdef>. A module can be evaluated only if it
  has a Query Body.</p>

<p><termdef id="dt-module-declaration" term="module declaration">A
  <term>module declaration</term> serves to identify a <termref def="dt-module">module</termref> as a <termref def="dt-library-module">library module</termref>. A module declaration
  begins with the keyword <code>module</code> and contains a namespace
  prefix and a URILiteral</termdef>.</p>

</inform-div1>

  
<inform-div1 id="impl-def">
<head>Checklist of Implementation-Defined Features</head>

<p>This appendix provides a summary of features defined in this specification
whose effect is explicitly <termref def="dt-implementation-defined">implementation-defined</termref>. 
The conformance rules require vendors to provide documentation that
explains how these choices have been exercised.
</p>

<olist>

<item><p> Everything about tokenization, including the definition of
the term "words", is <termref def="dt-implementation-defined">implementation-defined</termref>,
except that
<olist>
<item><p>each word consists of one or more consecutive characters;</p>
</item>
<item><p>the tokenizer must preserve the containment hierarchy
(paragraphs contain sentences contain words); and</p>
</item>
<item><p>the tokenizer must, when tokenizing two equal strings,
 identify the same tokens in each. </p>
</item>
</olist></p>
</item>

<item><p> Implementations are free to provide
<termref def="dt-implementation-defined">implementation-defined</termref> ways to differentiate between markup's 
effect on token boundaries during tokenization. </p></item>

<item><p>  It is <termref def="dt-implementation-defined">implementation-defined</termref> what a stem of a word is and 
whether stemming will based on an algorithm, dictionary, or mixed approach. </p></item>

<item><p> When the option "with default stop words" is used, an
<termref def="dt-implementation-defined">implementation-defined</termref> collection of stop words is used. </p></item>

<item><p> The set of valid language identifiers is <termref def="dt-implementation-defined">implementation-defined</termref>. </p></item>

<item><p>Certain values in the static context (see <specref ref="id-xqft-static-context-components"/>)
that can be overwritten or augmented by implementations are
<termref def="dt-implementation-defined">implementation-defined</termref>. </p></item>

</olist>

</inform-div1>
	<inform-div1 id="ft-issues">
	<head>Issues List</head>

<p> This section contains the current issues related to this document. </p>

<p>This list of issues is classified in clusters. Each cluster has a
unique name that reflects its topic. Each issue has a unique
number. Some issues are labelled VNext. The clusters are: 
       <olist>
	  <item>
	    <p>Cluster A: Scoring and Weighting</p>
          </item>
	  <item>
	    <p>Cluster B: IgnoreOption, Markup vs. Structure</p>
          </item>
	  <item>
	    <p>Cluster C: Wildcards, Regex, Match Anchoring</p>
          </item>
	  <item>
	    <p>Cluster D: Thesaurus, Match Option Defaults and Policies</p>
          </item>
	  <item>
	    <p>Cluster E: Other MatchOptions Details</p>
          </item>
	  <item>
	    <p>Cluster F: Grammar Integration, Syntax Details, and Naming</p>
          </item>
	  <item>
	    <p>Cluster G: Semantics Details</p>
          </item>
	  <item>
	    <p>Cluster H: Extensions</p>
          </item>
	  <item>
	    <p>Cluster I: Simplifications and Variations of Language Constructs</p>
          </item>
	  <item>
	    <p>Cluster J: IgnoreOption, Markup vs. Structure</p>
          </item>
	  <item>
	    <p>Cluster K: Issue closed before we started clustering</p>
          </item>
       </olist>
</p>

<issue id="scoring-properties" status="closed">
	<head>Scoring Properties (Cluster A, Issue 1)</head>
	<p>Is it possible to specify anything
    other than range ? Examples: do we want to define scoring rules
    for efficient scoring, rules to guarantee score monotonicity?</p>
    <resolution>
        <p>CLOSED.</p> <p>No changes required. Closed at FTTF Meeting
        62: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Oct/0020.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
    </resolution>
</issue>


<issue id="scoring-values" status="closed">
	<head>Scoring Values (Cluster A, Issue 2)</head>

<p>Answers that do not contain a match (in the Boolean sense) are
assigned a score value that depends on the scoring algorithm and that
might be greater than 0.</p>

<p>The following implications should hold:</p>

<p>score = 0 implies ftcontains is false.</p>
<p>score &lt;&gt; 0 does not imply anything for ftcontains.</p>
<p>ftcontains is true implies score &gt; 0.</p>
<p>ftcontains is false does not imply anything for score.</p>

<p>This interpretation enables the use of query relaxation in the
ftcontains expression and thus, return a score value greater than 0
for those nodes that do not match the ftcontains expression (in a
Boolean sense).</p> <p>For example, given the query:</p>

<eg xml:space="preserve"> for $b in //books
   score $score as $b//content ftcontains "usability &amp;&amp; testing"
   where $score &gt; 0
   return {$b} </eg> 

<p>The scoring algorithm could rewrite it to: </p>

<eg xml:space="preserve"> for for $b in //books
   score $score as $b//content ftcontains "usability || testing
               with stemming"
   where $score &gt; 0
   return {$b} </eg> 

<p>and thus, some of the books that are not returned by the first query
will be returned by the second query. </p>

<resolution>
<p>CLOSED.</p> <p>We discussed several alternatives in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Dec/0024.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
and we would like to adopt the one described above.</p> <p>However,
this issue is still under discussion.</p><p>See resolution in Cluster
A, Issue 60.</p>
</resolution>

</issue>

<issue id="data-model" status="closed">
	<head>Semantics Data Model (Cluster K, Issue 3)</head> <p>Data model incorporates
	new names - TokenInfo, Match, AllMatches.</p>
        <resolution>
           <p>CLOSED.</p> <p>All occurrences of FullMatch,
           SimpleMatch, and Position in the text, in the schemas, and
           in the XQuery implementations of the semantics have been
           replaced with AllMatches, Match, and TokenInfo
           respectively.</p>
        </resolution>
</issue>


<issue id="ftcontains-grammar" status="closed">
	<head>FTContains Grammar (Cluster K, Issue 4)</head> <p>Expr "ftcontains"
	FTSelection FTIgnoreCtxMod?. One production for FTSelection
	which includes FTIgnoreCtxMod?</p>
        <resolution>
           <p>CLOSED.</p>
           <p>We replaced the previous grammar production Expr
           "ftcontains" FTSelection that allowed FTIgnoreCtxMod to be
           combined with any FTSelection with the new one
           that restricts the application of FTIgnoreCtxMod to the
           highest level.</p>
        </resolution>
</issue>


<issue id="ftcontextmodifiers" status="closed">
	<head>FTContextModifiers (Cluster K, Issue 5)</head> <p> Paul
	C.: Change the name of the FTContextModifer production which
	modify the operational semantics of the FTSelections they are
	applied to. Abandon the use of "ContextModifier" as in
	FTCaseCtxMod, FTStemCtxMod, FTIgnoreCtxMod.  Issue raised at
	FTTF Feb 5-6, 2004 meeting. Find in the minutes at: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Feb/0010.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
	(Cntl-F on FTContextModifiers)</p>
        <resolution>
           <p> CLOSED.</p>
           <p>Replaced FTContextModfiers with FTMatchOptions as in
FTCaseOption, FTStemOption, FTIgnoreOption in the Feburary 26, 2004
Editor's Draft.  </p><p> CLOSED February 26, 2004.</p>
        </resolution>
</issue>


<issue id="grammar" status="closed">
	<head>Grammar (Cluster K, Issue 6)</head> <p>Grammar: Where does the
	ftcontains expression belong in the XQuery grammar: Boolean
	expression or comparison expression?</p>
        <resolution>
           <p> CLOSED.</p>
           <p>The ftcontains expression plugs in to the XQuery grammar in the "FTComparisonExpr" production. This seems to give ftcontains the correct precedence among other XQuery operations, and it makes intuitive sense.</p>
        </resolution>
</issue>

<issue id="wildcards" status="closed">
	<head>Wildcards (Cluster C, Issue 7)</head> <p>Pat Case: There are a few
	inconsistencies between this document and the Use Cases
	Working Draft. </p> <p>This document and the Use Cases Working
	Draft present different syntax in regex examples. I can find
	no syntax provided in this document for the starts-with and
	exact match functionality. Should we rename the Wildcard
	section in the Use Cases to Regex Section and possibly rethink
	the use cases?</p>
        <resolution>
           <p>CLOSED.</p> <p>We dropped regular expression support in
           favor of wildcard support. Closed at Meeting 67: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jan/0051.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p> 
        </resolution>
</issue>


<issue id="thesaurus" status="closed">
	<head>Thesaurus (Cluster D, Issue 8)</head> <p>Thesaurus
	names: "synonyms", "narrower terms", "soundex", "spellcheck"
	and "wordnet". We need to define Thesaurus operators. We need
	more options when specifying thesaurs: Name, URI, Depth,
	Dimension. Standards. ISO 2788/ANSI Z39.19.</p> <p>We need to
	discuss what the grammar of ThesaurusMatchOption is. Current
	grammar is: </p><p>FTThesaurusOption ::= ("with"?  "thesaurus"
	Expr) | "without thesaurus". </p> <p>Proposed grammar is:</p>
	<p>FTThesaurusOption ::= ("with"?  "thesaurus" Expr
	"operation" Expr) | "without
	thesaurus". </p>
         <resolution><p> CLOSED.</p>
           <p>Changed the syntax and semantics
	of thesaurus according to
	<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jan/0111.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
        </p></resolution>
</issue>


<issue id="window" status="closed">
	<head>Window (VNext, Cluster H, Issue 9)</head> <p>Currently, FTDistanceSpec only permits
	a single distance specification for all of the terms specified
	by an FTSelection.</p>
        <p>For example:</p>

        <p>("dog" &amp;&amp; "cat" &amp;&amp; "bird") with word
        distance at most 10</p>

        <p>In this scenario above, the terms "dog", "cat", and "bird"
        must all occur within 10 words of one another.</p>
        
        <p>However, if one would want to return documents where "dog"
	occurs within 10 words of "cat" and this SAME "cat" term
	occurs within 5 words of "bird", it is currently not possible
	with the current language specification.  The best that could
	be done is the following:</p>

        <p>(("dog" &amp;&amp; "cat") with word distance at most 10) and
           (("cat" &amp;&amp; "bird") with word distance at most 5)</p>
 
        <p>But, this will not lead to the exact desired result because
	the "cat" and "bird' comparison will not use only those "cat"
	terms which occurred within 10 positions of "dog" ... it can
	use any "cat" term within the search context.</p>
<resolution>
<p>CLOSED.</p> <p>The issue has been closed on April 25, 2005 &lt;<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Apr/0072.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
&gt;. No changes are made to the language. Although the current
language can express a lot of the specified types in question, the
group recognizes that the query expressions are clumsy and difficult
to write. Therefore, this issue will be considered again for
VNext.</p> </resolution>

</issue> 

  
<issue id="mildnot" status="closed">
	<head>MildNot (Cluster I, Issue 10)</head> <p>Andrew E.: Should we remove the mild
	not? It has never been included in a query language
	before. </p><p>Pat Case has provided use cases to justify its
	inclusion at:
	<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2003Dec/0034.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
	</p> <p>Discussion followed. Michael Rys' reply:
	<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2003Dec/0038.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
	</p><p>Pat Case's reply:
	<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2003Dec/0043.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
	</p>
	<p>Use case paraphrase (for non-members): Consider a collection of 3 documents:</p>
	<olist>
	  <item>
	    <p>The Delights of Mexico - a document that includes "Mexico" several times.</p>
	  </item>
	  <item>
	    <p>The Perils of New Mexico - a document that includes "New Mexico" several times.</p>
	  </item>
	  <item>
	    <p>Travel in North America - a document that includes both "Mexico" and "New Mexico" several times.</p>
	  </item>
	</olist>
  <p>Suppose you are planning a trip to Mexico. You want documents 1
  and 3, but not 2. You could search for "Mexico" and get documents 1,
  2 and 3. Or you could search for "Mexico AND NOT 'New Mexico'" and
  get just document 1. But the "strong not" has ruled out document 3 -
  even though it contained the thing you were looking for - just
  because it contained the thing you were not looking for.</p> <p>The
  "mild not" operator allows you to say "Mexico MILD NOT 'New
  Mexico'", which means "find me all the documents that contain
  'Mexico'. Do not take any notice of occurrences of 'New Mexico', but
  do not rule out a document just because it contains 'New
  Mexico'".</p> <p>There are many cases where you may want to search
  for a word, but NOT get documents just because they contain a common
  phrase that includes that word. e.g. "security" mildnot "social
  security", "house" mildnot "house of representatives", "estate tax"
  mildnot "real estate tax"</p>
    <resolution>
        <p>CLOSED.</p> <p>Issues 10 and 41 are now closed. We add the mildnot functionality and FTMildNot is spelled as "not in". Closed at FTTF Meeting
        80: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005May/att-0030/fttf-20050503.txt" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
    </resolution>
</issue>

    
<issue id="markup-vs-structure" status="closed">
	<head>Markup vs Structure (Cluster J, Issue 11)</head> <p>Some
	tags are "markup" - e.g. b - some are "structure" -
	e.g. title.  We generally want to treat structure tags as word
	boundaries, but not markup tags.  How do we distinguish
	between markup and structure?</p> <p>Michael to provide
	reformulation. </p><resolution><p> CLOSED.</p> <p>Closed on
	April 29, 2005 and updated Section 1.1 as in
	http://lists.w3.org/Archives/Member/member-query-fttf/2005Apr/0091.html.</p></resolution>
</issue>

      
<issue id="matchoption-policy" status="open">
	<head>MatchOption Policy (Cluster D, Issue 12)</head> 
        <p>We need some indirection to
	specify match context, defaults "Thesaurus name" gives us a
	way to define a thesaurus, then specify it in the query - an
	indirection.  Steve Buxton proposes there are many classes of
	things that are needed for context-match (stoplist, special
	characters, etc.) that need an indirection. So we need an
	extra level of indirection - a named policy that refers to a
	set of named things.</p>
</issue>

       
  <issue id="loose-grammar" status="closed">
      <head>Loose Grammar (Cluster I, Issue 13)</head> 
      <p>The grammar allows lots of
           queries that do not make sense.  e.g. "(dog || cat) within
           word distance N", "dog within word distance N", "(dog || cat)
           ordered", "!dog 5 times" If the grammar does not provide a way
           of identifying these "nonsense queries", then the
           implementation still has to identify them - i.e. implementors
           will have to augment the grammar to identify nonsense queries,
           and augment the semantics to do something with them.  </p>
           <p>
           J. Doerre asks if we should allow nested FTNegations in the
           RHS of a FTMildNegation. From his email (<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Apr/0019.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>)
           point 3: "The ApplyFTSelection ignores all StringExcludes
           in the arguments of the FTMildNegation. I think, if we
           don't want to deal with StringExcludes in that function, we
           should explicitly forbid them to appear, i.e.  require
           arguments of FTMildNegation to not include any FTNegation."

           </p><resolution><p> CLOSED.</p> <p>Leave the grammar as it
           is for a couple of reasons. 1. We cannot solve this problem
           with a (context-free) grammar without complicating it
           unnecessary. For example, apart from "(dog || cat) word
           distance N", the "no-op" rule can be also applied to "(dog
           with diacritics || cat) case-insensitive without stop words
           word distance N".</p> <p>2. It is hard if not impossible to
           enumerate all "no-ops". Here are some additional ones: "a"
           &amp;&amp; !"a", (dog &amp;&amp; cat) distance at most 5
           words distance at most 6 words, "To be or not to be"
           distance at least 10 words, etc. It should be left to the
           application to determine what constitutes a no-op and
           optimize if possible.</p><p>See F2F minutes in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jul/0049.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p></resolution>
</issue>
    
<issue id="fttimesselection" status="closed">
	<head>FTTimesSelection (Cluster G, Issue 14)</head> 
        <p>How do I count occurrences, where the query
        is NOT a single term?.  How many occurrences of "!dog" are
        there in "very very big"?  Zero or very many?</p>
<resolution><p> CLOSED.</p></resolution>
</issue>

 
<issue id="regexp-escape" status="closed">
	<head>RegExp Escape (Cluster C, Issue 15)</head> <p>Need to
        define some escaping mechanism for regexp characters, and for
        (||, ...).</p> <resolution><p> CLOSED.</p>
           <p>Closed on Feb. 14, 2005 because
        regular expressions are not part of the language
        anymore.</p></resolution> </issue>


<issue id="ftscopeselection" status="closed">
	<head>FTScopeSelection (Cluster I, Issue 16)</head> <p>Is
        there a need for both FTScopeSelection and FTDistance ? For
        example, how is the 'same sentence' or 'same paragraph' really
        different than a FTDistance of 'with sentence exactly 1' or
        'with paragraph exactly 1'?.</p> <resolution><p> CLOSED.</p><p>We
        decided to keep both FTScopeSelection and
        FTDistance.</p></resolution>
</issue>

 
<issue id="weighting" status="closed">
	<head>Weighting (Cluster A, Issue 17)</head> <p>Michael R.:
        What syntactic form should scoring take? How do we describe
        the constraints on the types of expressions that are allowed?
        Should scoring be expressed using a second-order function, a
        stand-alone operator, or as a clause in a FLWOR expression?
        Consider moving weighting to ftContains, something like the
        following: TreatExpr ("ftcontains" FTSelection ("weight"
        Expr)? )? </p><p>Options in presentation of full-text language
        proposal and some discussion at XQuery January meeting, Tampa
        at: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.w3.org/XML/Group/2004/01/xquery-minutes" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
        (Cntl-F on Report of Full-Text Task Force)</p>
        <resolution><p> CLOSED.</p>
           <p>Added weight to FTSelection inside a scoring
        expression.</p></resolution>
</issue>

     
<issue id="weight-values" status="closed">
	<head>Weight Values (Cluster A, Issue 18)</head> <p>Valid
        values for weights must be defined.</p> 
        <resolution><p> CLOSED.</p>
           <p>Weight values in scoring expressions are in the interval
        [0,1].</p></resolution>
</issue>

     
<issue id="ftscopeselection-on-structure" status="closed">
	<head>FTScopeSelection on structure (VNext, Cluster H, Issue 19)</head> 
       <p>Scoping based on structure (e.g. same node and different
        node) should be considered. Support for queries where distance
        is measured in terms of "number of intervening elements" where
        elements can be any markup including chapter, paragraph and
        sentence. Consider sentence/paragraph/node distance.</p>
        <resolution><p> CLOSED.</p><p>Postponed to VNext.</p></resolution>
</issue> 

     
<issue id="languagematchoption" status="closed">
	<head>LanguageMatchOption (Cluster E, Issue 20)</head> <p>What is the default
           language?  SA: Dana F.: does the language have to be a
           literal or an Expr that returns xs:string?  Is there an
           implementation-defined list of valid languages ?</p>
<resolution><p> CLOSED.</p>
<p>1. Default language is "None". </p>
<p>The Working Draft states explicitly in Section 3.2.7 the possibility
to have no language selected. I think this is a good choice for the
default (and it is specified as the default in the Working Draft). A
typical application that uses XQuery-FT will probably have logic in
place to override the default by the language setting from the locale
of the client, so the default is really unimportant.</p>

<p>2. The language is given by a UnionExpr that must return an
xs:string, or an empty sequence.  This is what the Working Draft
specifies. Let us keep it like that.</p>

<p>3. Yes, there is an implementation-defined list of valid languages.
We added a statement on this to Section 3.2.7. See
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jan/0083.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
</resolution>

</issue>

           
<issue id="casematchoption-specialcharmatchoption" status="closed">
	<head>CaseMatchOption and SpecialCharMatchOption (Cluster E, Issue 21)</head>
           <p>Paul C. pointed out whether "lowercase", "uppercase",
           "case sensitive" and "case insensitive" should be defined
           in the context of Unicode. J. Doerre provided this link to
           the Unicode standard is: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://www.unicode.org" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>. The
           current version is 4.0.0. Case folding is described in
           Chapter 3.13.  Please note that the case folding
           operations, like toUppercase(X), only depend on the
           characters to be folded, not on additional information,
           like language.</p>
<resolution><p> CLOSED.</p>
           <p>There will be no syntax for special character handling in the
current draft. Issues to consider for v. next are in this list of issues.
           </p></resolution>

</issue> 

          
<issue id="diacriticsmatchoption" status="closed">
	<head>DiacriticsMatchOption (Cluster E, Issue 22)</head>
           <p>Paul C.: We need to define what a diacritic is. Steve
           B. pointed out whether "with diacritics" and "without
           diacritics" are needed or not.</p> 
           <resolution><p> CLOSED.</p>
           <p>We removed
           the special character match option as instructed in
           <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jan/0051.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
           </p></resolution>

</issue>


<issue id="tokenizers" status="closed">
	<head>Tokenizers (Cluster J, Issue 23)</head> <p>Darin/Paul
           C.: What is the most general behavior for
           tokenizers?</p><p>Michael Kay: Can we define a set of rules
           that apply regardless of which tokenizer we are using in
           the same manner as the rues we defined for scoring?  For
           example, we could impose constraints on words, sentences
           and paragraphs.</p>
           <resolution><p> CLOSED.</p>
           <p>Modified item 7 in Section
           1.1 to reflect conditions on tokenizers.</p></resolution>
</issue>


<issue id="specialcharmatchoption" status="closed">
	<head>SpecialCharMatchOption (Cluster E, Issue 24)</head>
        <p>We need to say more about special characters, what kind of
        special characters do we want to consider, what is their
        impact on the ability to use a given index, their impact on
        tokenization.</p> 
        <resolution><p> CLOSED.</p>
           <p>We decided to remove this match
        option from the current WD and create new issues
        to be considered for v. next.</p></resolution>

</issue>


<issue id="matchoption-syntax" status="closed">
	<head>MatchOption Syntax (Cluster E, Issue 25)</head> <p>Paul C.: It maybe that we
        should reconsider the syntax and allow to apply modifiers to
        individual words.</p>
        <resolution><p> CLOSED.</p></resolution> 
</issue>


<issue id="stopwordsmatchoption" status="closed">
	<head>StopWordsMatchOption (Cluster E, Issue 26)</head> <p>We
        need to say more about stopwords, what kind of stop words do
        we want to consider, what is their impact on the ability to
        use a given index, their impact on tokenization. Should we
        allow to specify the URI of a StopWords list? Paul C.: What
        would a single search with a stop word
        return?</p>
        <resolution><p> CLOSED.</p>
           <p>We changed the syntax of stop words
        sepcification to allow for using a URI as a stop word
        list. The new syntax is given in:
        <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jan/0109.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
        </p></resolution>
</issue>



<issue id="matchoptionstokenization" status="closed">
	<head>MatchOption and Tokenization (Cluster C, Issue
27)</head> <p> Does the language document clearly state the impact of
match options on tokenization? Consider regex * when does it get
applied? What effect does it have on word breaks? Example: expr
ftcontains "brown .ox" with regex, expr ftcontains "brown .*ox" with
regex.  </p>
<resolution><p> CLOSED.</p>
<p>Closed, on Feb. 17, 2005, because no longer an issue.</p>
<p>The only impact of match options on tokenization that needs to be
addressed in the specification is the impact of the wildcard match option.
Other match options, like "language", are allowed to impact tokenization
in an implementation-dependent way.</p>
<p>For the wildcard match option its implication on tokenization is now
clearly stated in its description, namely that wildcards, i.e., the
character sequences ".", ".*", ".+", etc., are to be interpreted as
token-internal character sequences when within an FTWords that is inside
the scope of the wildcard match option.</p>
</resolution>
</issue>



<issue id="ignoresyntax" status="closed">
	<head>IGNORE Syntax (Cluster B, Issue 28)</head> <p> Do we need special syntax for
IGNORE in case of level by level search?</p>
<resolution>
<p>CLOSED.</p>
<p>We already have a syntax for this.</p>
</resolution>
</issue>



<issue id="scoping" status="closed">
	<head>Scoping (Cluster I, Issue 29)</head> <p> Do we need same sentence, same paragraph
search? * in semantics, not in requirements.
</p>
<resolution>
<p>CLOSED.</p>
<p>
Closed by Pat Case in
http://lists.w3.org/Archives/Member/member-query-fttf/2005Mar/0230.html</p>
<p>This recommendation should focus on functionality which serves all
languages. It should also selectively include functionalities useful
within families of languages. Searching within sentences and paragraphs
is useful to many western languages and some non-western languages. They
should remain in the recommendation. 
</p>
</resolution>
</issue>



<issue id="precedencexqueryfulltext" status="closed">
	<head>Precedence of XQuery and full-text (Cluster F, Issue 30)</head> <p> We need
	to distinguish between XQuery expressions embedded in
	full-text expressions and FTSelections themselves. S. Buxton
	suggests that we use different kinds of parentheses to
	distinguish between these two expressions. See his message in
	<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Apr/0042.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
	and subsequent messages.  A simple example is to distinguish
	between ("cat") as an XQuery expression that builds an XQuery
	sequence and ("cat") as an FTSelection.  </p> <p> In the
	current draft of the document, we are using lookahead </p> <p>
	Other possibilities include the use of "{}" to switch from
	full-text to XQuery when XQuery expressions are embedded in
	full-text expressions. This is similar to element construction
	in XQuery and has been pointed out by Mary H in her email at
	<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004May/0163.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
        <resolution>
           <p>CLOSED.</p> <p>We decided to use {} to delimit XQuery
           expressions inside XQuery Full-Text ones according to the
           discussion in
           <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Mar/0019.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
        </resolution>
</issue>



<issue id="ftdistancewith" status="closed">
<head> Optional Keyword "with" in FTDistance (Cluster F, Issue 31)</head>
<p>In 3.1.9 FTDistance: Do we need "with" in
FTDistance?</p>
<p>Raised by Pat Case by email April 28, 2004</p>

        <resolution>
           <p>CLOSED.</p> <p>We removed the optional keyword "with"
        from FTDistance. Closed at FTTF Meeting 69, by accepting text
        at
        <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jan/0112.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
        as amended.</p> 
        </resolution>
</issue>



<issue id="ftwindowwithin" status="closed">
<head> Optional Keyword "within" in FTWindow (Cluster F, Issue 32)</head>
<p>In 3.1.20 FTWindow: Do we need "within" in
FTWindow?</p>
<p>Raised by Pat Case by email April 28, 2004</p>
        <resolution>
           <p>CLOSED.</p> <p>We removed the optional keyword "within" from FTWindow. Closed at FTTF Meeting 69, by accepting text
        at
        <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jan/0112.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
        as amended.</p>
        </resolution>
</issue>



<issue id="ftspecialcharoption-issue" status="closed">
<head> FTSpecialCharOption (Cluster E, Issue 33)</head>
<p>In 3.2.3 FTSpecialCharOption: Should we have to or be able to
specify which special characters are to be matched or not? Should the
following syntax be allowed "without special characters "-" or "with
special characters "-"?</p>
<p>Raised by Pat Case by email April 28, 2004</p>
<resolution><p> CLOSED.</p>
           <p>Closed on 14 Feb. 2005 because special character match
options is not part of the language anymore.</p></resolution>
</issue>



<issue id="ftnegationunarynot" status="closed">
<head> FTNegation Includes Unary Not (Cluster F, Issue 34)</head>
<p>In 3.1.5 FTNegation: If we are supporting the unary not which is
shown in the production, please add text and examples to show that both
the "unary not" and the "and not" are supported.</p>
<p>Raised by Pat Case by email April 28, 2004</p>
<resolution>
<p>CLOSED.</p> <p>Closed by Pat Case in http://lists.w3.org/Archives/Member/member-query-fttf/2005Mar/0230.html</p>
</resolution>
</issue>



<issue id="ftorderunordered" status="closed">
<head> FTOrder Unordered Option (Cluster F, Issue 35)</head>
<p>In 3.1.7 FTOrder: [30] FTOrder  ::=   FTSelection  "ordered" should
we have an explicit "unordered" for the default?</p>
<p>Raised by Pat Case by email April 28, 2004</p>
        <resolution>
           <p>CLOSED.</p> <p>We don't introduce an explicit
           "unordered" operator. This would necessitate the semantics
           to deal with partial orders inside ALLMATCHES. There are no
           use cases warranting such complications in the
           semantics. 
           Closed at FTTF Meeting 68:
           <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Feb/0020.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
           </p>
        </resolution>
</issue>



<issue id="ftignoreoptionnaming" status="closed">
<head> FTIgnoreOption Naming (Cluster F, Issue 36)</head>
<p>Would FTFilterOption be a better name than FTIgnoreOption?</p>
<p>Raised by Pat Case by email April 28, 2004</p>
<resolution>
<p>CLOSED.</p>
<p>Closed by Pat Case in
http://lists.w3.org/Archives/Member/member-query-fttf/2005Mar/0208.html</p>
<p>Since filter and skip are already used in the XQuery recommendation,
the name of this functionality should remain FTIgnore. 
</p>
</resolution>
</issue>


<issue id="ftrangespecsyntax" status="closed">
<head> FTRangeSpec Syntax for 1 to 4 (Cluster F, Issue 37)</head>
<p>We should consider aligning the syntax for the FTRangeSpec with an
upper and lower boundary in 3.1.9 FTDistance (from 1 to 4) with the
syntax for using range expressions to construct sequences in XQuery and
XPath (1 to 4), See the XQuery/XPath language document Section 3.3.1
Constructing Sequences.</p>
<p>Raised by Pat Case by email April 28, 2004</p>
<resolution>
<p>CLOSED.</p>
<p>Closed by Pat Case in http://lists.w3.org/Archives/Member/member-query-fttf/2005Mar/0227.html</p>
<p>The document will continue to use the syntax (from 1 to 4) for number
ranges in FTRange. This syntax for number ranges is the most
user-friendly. There is no need to align this syntax with the XML
Schema/XQuery regular expression syntax for number ranges.
</p>
</resolution>
</issue>

 

<issue id="booleannaming" status="closed">
<head> Boolean (&amp;&amp; || !) Naming (Cluster F, Issue 38)</head>
<p>Is it not possible and maybe preferable to use ftand ftor ftnot
instead of  &amp;&amp; || ! following the lead of ftcontains?</p>
<p>Raised by Pat Case by email April 28, 2004</p>
<resolution><p> CLOSED.</p></resolution>
</issue>

 

<issue id="exactelementcontent" status="closed">
<head> Exact Element Content (Cluster C, Issue 39)</head>
<p>We have a use case for an exact element content query which finds
the exact words or phrases being queried, no more and no less in an
element and allows variations on case, diacritics, and special
characters. Should this functionality be in XQuery full-text? If so,
should we use the keywords "exact content"?</p>
<p>Raised by Pat Case by email April 28, 2004</p>
<resolution><p> CLOSED.</p>
<p>We added an FTSelection in Section 3.1.12 to express exact content.
</p></resolution>
</issue>

 

<issue id="startswith" status="closed">
<head> Starts With (Cluster C, Issue 40)</head>
<p>We have a use case for a starts with query which finds the words or
phrases being queried as the first content of an element. Should this
functionality be in XQuery full-text? If so, should we use the keywords
"starts with"? </p>
<p>Raised by Pat Case by email April 28, 2004</p>
<resolution><p> CLOSED.</p>
<p>We added an FTSelection in Section 3.1.12 to express start with.
</p></resolution>
</issue>



<issue id="mild-not-naming" status="closed">
<head> What should we call the mild not (Cluster F, Issue 41)</head>
<p>The name "mild not" or "mild negation" is not really helpful in
understanding what we want it to denote. We should try hard to find a
better name for this construct. Since it is used to exclude certain
matches, why not call it "FTMatchExclude" or just "FTExclude"? Keeping
"mild not" as the name makes it recognizable as a form of "not". If it
remains as "mild not" and the ! continues as the syntax for "not",
consider using mild! as the syntax for "mild not".</p>
<p>Raised by Jochen by email April 21, 2004; Additional comments by Pat
Case May 4, 2004</p>
    <resolution>
        <p>CLOSED.</p> <p>Issues 10 and 41 are now closed. We add the mildnot functionality and FTMildNot is spelled as "not in". Closed at FTTF Meeting
        80: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005May/att-0030/fttf-20050503.txt" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
    </resolution>
</issue>



<issue id="multi-word-phrases-thesauri-lookup" status="closed">
        <head>Thesauri lookup for multi-word phrases (Cluster D, Issue 42)</head>
       <p>It should be decided whether thesauri lookups can be performed
              only on single words or whether it is possible to apply it on
              multi-word phrases. For example, should we allow the 
thesaurus to
              replace "bells and whistles" with "frills"?  </p>
        <p>In the latter case, should thesauri lookup be applied only to 
the
               FTWord "bells andwhistles", or should it applied also on
               ("bells" "and" "whistles") phrase? Another question is if
               the thesauri expansion can be applied on phrase and on a word
               in the phrase, which one takes precedence. </p>
<resolution><p> CLOSED.</p>
<p>The semantics has been modified so that thesauri lookups can be performed on
multi-token phrases. They are applied only on phrases that are explictly
specified by the user; e.g., they will be applied in FTWord selections
"('bells', 'and', 'whistles') phrase" or "'bells and whistles' any/all/phrase".
Multi-token phrase lookup for "bells and whistles" will no be performed for
"('bells', 'and', 'whistles') all word" or "'various bells and whistles'
phrase". Multi-token phrase lookups take precedence over single-token lookups:
once a multi-token phrase lookup is performed no more thesauri lookups will be
performed. </p>
</resolution>
</issue> 
   



<issue id="exactly" status="closed">
       <head>Exactly in FTRangeSpec (Cluster F, Issue 43)</head>
      <p>Should "exactly" be optional? Should we allow both "word
      distance 6" and "word distance exactly 6"? Raised at Redmond May
      2004 by Steve Buxton and Pat Case.</p><resolution>
      <p>CLOSED.</p><p>Exactly is required and is not
      optional.</p></resolution>
</issue>
    

  
<issue id="ftcontains-semantics" status="closed">
       <head>FTContains Semantics (VNext, Cluster H, Issue 44)</head> <p>FTContains operates on
      a sequence of nodes. Strings cannot be searched.</p>
      <p>Raised at Redmond May 2004 by Steve Buxton. See also:
      <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004May/0085.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/> </p><resolution>
           <p>CLOSED.</p><p>Postponed to VNext.</p></resolution>
 </issue>



<issue id="matchoptions-defaults" status="closed">
       <head>MatchOptions Default (Cluster D, Issue 45)</head> <p>We need to specify
      defaults for MatchOptions. We should align this default with
      the static context for XQuery/XPath and add to the XQuery prolog
      corresponding declarations to set query-wide defaults.</p>
      <resolution>
      <p>CLOSED.</p><p>Added match option declarations to prolog (see Section <specref ref="tq-ext-static-context"/>) and
static context components for match options (see Appendix <specref ref="id-xqft-static-context-components"/>). Closed at F2F Meeting 80: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005May/att-0030/fttf-20050503.txt" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>.</p></resolution>
</issue>



<issue id="ftnegation-semantics" status="closed">
       <head>FTNegation Semantics (Cluster K, Issue 46)</head> <p>We need to specify the
      semantics of FTNegation. </p><p>Raised by Jochen Doerre. See
      <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004May/0082.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p> 
      <resolution><p> CLOSED.</p>
      <p>we decided to use
      &lt;allMatches/&gt; to denote false. See answer to <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004May/0082.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p></resolution>
</issue>



<issue id="zero-length-phrase" status="closed">
      <head>Zero-length phrase (Cluster G, Issue 47)</head>
      <p>If Expr in FTWords  results in the empty sequence or the
tokenization results
      in a zero-length phrase, the result is? Always a match, never a
match?
      Depending on the keyword?</p>

        <resolution>
           <p>CLOSED.</p> <p>As agreed by the FTTF, an FTWords with an
           empty list of search tokens returns an empty
           AllMatches. This applies for both the search tokens
           supplied directly by the user (as an XQuery expression) and
           the final search tokens after the application of all match
           options. Closed at FTTF Meeting 70:
           <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Feb/0105.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
        </resolution>
</issue>

<issue id="stopwordsoptions" status="closed">
      <head>Stop words option (Cluster E, Issue 48)</head> <p>The
      syntax and semantics of stop words are still under
      discussion.</p> <p><specref ref="ftstopwordoption"/> is
      inconsistent with the grammar and semantics.</p>
      <olist>
        <item>
          <p>the second example includes "without stop words" NOT
          followed by an expression, which is not valid according to
          the EBNF (see also the default options query in <specref ref="ftmatchoptions"/>)</p>
        </item>
        <item>
          <p>the keyword "additional" is not part of the current grammar</p>
        </item>
        <item>
          <p>the text and examples in <specref ref="ftstopwordoption"/> imply that queries work as though
          stop words were removed from documents before positions are
          calculated, which is inconsistent with the description in
          <specref ref="semantics-ftstopwordoption"/></p>
        </item>
      </olist>
    <resolution><p> CLOSED.</p>
        <p>We changed the syntax of stop words sepcification to
        allow for using a URI as a stop word list. The new syntax is
        given in:
        <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jan/0109.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p></resolution>
</issue>

<issue id="grammar-precedence" status="closed">
	<head>Grammar Precedence and Lookahead (Cluster F, Issue 49)</head>
	<p>When integrating the XQuery Full-Text grammar with the XQuery 1.0 grammar, 
           there were a number of challenges. Challenges include (using pseudo-code for examples):</p>
<olist>
  <item>
    <p>The Full-Text operators must have the correct precedence
    (binding order) with respect to XQuery operators</p>
  </item>
  <item>
    <p>It must be possible to override the default precedence of the 
    Full-text operators - e.g. you must be able to express "(cat and dog) 
    or mouse" as well as "cat and (dog or mouse)"</p>
  </item>
  <item>
    <p>You must be able to embed XQuery expressions in the Full-Text expression, e.g. "cat and $i"</p>
  </item>
  <item>
    <p>You must be able to embed the XQuery Full-Text expression in an 
       arbitrarily-complex XQuery expression, e.g. "where title ftcontains ('dog' and 'cat') 
       and price/dollars &lt; 3 or disclaimer ftcontains 'buy this'"</p>
  </item>
</olist>
  <p>The Working Groups discussed a number of ways of achieving
   this. The current grammar satisfies these requirements at the cost
   of introducing ambiguity in one place. The current XQuery 1.0
   grammar is LL(1) - i.e. it is possible to write a parser that reads
   a query from left to right and only looks 1 token ahead. But the
   XQuery Full-Text grammar is NOT LL(1). At <specref ref="prod-xquery-FTWordsSelection"/> the parser must lookahead a
   full non-terminal - it must try to expand FTWords, and if that
   fails it must try to expand (FTSelection).</p> <p>This is still
   under discussion - the Working Groups may remove the requirement
   for lookahead in a future publication.</p>
   <resolution>
           <p>CLOSED.</p> <p>We decided to use {} to delimit XQuery expressions inside XQuery Full-Text 
           ones accroding to the discussion in  
           http://lists.w3.org/Archives/Member/member-query-fttf/2005Mar/0019.html</p>
   </resolution>
</issue>


<issue id="ignore-queries" status="closed">
	<head>IGNORE Queries (VNext, Cluster B, Issue 50)</head>

	<p>There are 3 main issues with IGNORE queries:</p>
	<olist>
	<item><p> Do we
	need to specify the UnionExpr that follows IGNORE in the
	grammar? </p> <p>Yes, we do.</p>  <p> This issue has been resolved in
	<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Aug/0059.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
 	</item>
	<item>
	<p> Should IGNORE be made composable with other
	FTSelections or should it be kept at the top level in the
	grammar?</p> 
	</item>
	<item><p> Does the semantics of level-by-level IGNORE
	(used in the Use Cases document) differ from the semantics of
	IGNORE in the language document?</p>
	</item>
	</olist>
   <resolution>
           <p>CLOSED.</p> <p>Point 1. We are using UnionExpr in the
           current syntax. Point 2. Composing FTIgnore at any level of
           FTSelections is too complex at this stage and should be
           postponed to VNext after we have some implementation
           experience. See examples where semantics of composing
           ignore with FTSelection is not clear. Point 3. No, the
           semantics of FTIgnore is now the level by level
           semantics. See minutes in http://lists.w3.org/Archives/Member/member-query-fttf/2005May/0007.html </p>
           </resolution>
</issue>

<issue id="ftwindow-alternative-semantics" status="closed">
<head>Alternative Semantics for FTWindow (Cluster I, Issue 51)</head>

<p>The current semantics of FTWindow does not capture the most
intuitive notion of window as a matching constraint. Suppose we have a
simple query like: </p> <p><code>"Internet" &amp;&amp;
"Cafe"</code>,</p> <p> and we want to restrict a match to say, a
window of 5. The interpretation I think is most natural for this
query, is that it restricts each match, such that it is required to
"lie" within a "window of 5 (word) positions" (but we could also use
sentence or paragraph as position unit). Note that this does not imply
that the search terms have to be a certain distance apart in any
way. The window in which a match can be found exists independently of
the match. In our current semantics, however, the "window" is defined
by the first and last stringInclude (matching term) position. This
allows us to constrain the window size using "exactly", "at most" and
"at least".  I find this notion of window counter-intuitive and
confusing. Finding a match in a larger window should always be a
weaker condition than finding a match in a smaller window!
</p>

<p>The difference in the notion of window also comes to bear when looking 
at 
queries with negative parts. A query like: </p>
<p><code>"Internet" &amp;&amp; ! "Cafe" within window 5</code>, </p>
<p>has the very intuitive meaning of searching for any occurrence of 
"Internet" such 
that inside some window of 5 positions that includes that occurrence there 
is not 
an occurrence of "Cafe". With our current notion of window, such a query 
simply 
cannot be expressed.
</p>

<p>Here is the formalization of the proposed window semantics.
</p>
  <eg role="parse-text" xml:space="preserve">
define function fts:ApplyFTWordWindow(
      $matchOptions as element(matchOptions, fts:FTMatchOptions),
      $allMatches as element(allMatches, fts:AllMatches),
      $n as xs:integer
      ) as element(allMatches, fts:AllMatches) {
  &lt;allMatches&gt;
   {
    for $match in $allMatches/match
    let $minpos := fn:min($match/*/tokenInfo/@pos),
        $maxpos := fn:max($match/*/tokenInfo/@pos)
     for $windowStartPos in ($minpos to $maxpos-n+1)
     let $windowEndPos := $windowStartPos+n-1
     where fn:min($match/stringInclude/tokenInfo/@pos) &gt;= $windowStartPos
           and fn:max($match/stringInclude/tokenInfo/@pos) &lt;= $windowEndPos
     return 
       &lt;match&gt;
         {$match/stringInclude}
         {
          for $stringExclude in $match/stringExclude
          where $stringExclude/tokenInfo/@pos &gt;= $windowStartPos
                and $stringExclude/tokenInfo/@pos &lt;= $windowEndPos
          return $stringExclude
         }
       &lt;/match&gt;
    }
  &lt;/allMatches&gt;
}
    </eg>
<p>Raised by Jochen.
</p>

<resolution><p>
	CLOSED.</p><p>The proposed new semantics has been accepted. 
        Closed at F2F Meeting 84: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jul/0061.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>.</p></resolution>
</issue>

<issue id="with-stop-words-UnionExpr" status="open">
	<head>UnionExpr in StopWords(Cluster D, Issue 52)</head>
	<p>The change from "UnionExpr" to "some complicated rewrite of
	UnionExpr that only includes literals" makes the grammar more
	complex, makes the language less clear and comprehensible, and
	adds only some questionable optimization possibilities (the
	query may be optimizable statically instead of at runtime).</p>

<p>Raised by Steve Buxton in
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Dec/0065.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
</issue>

<issue id="matchoptions-default-functions" status="closed"> 

        <head>Functions returning defaults
	for match options (VNext, Cluster D, Issue 53)</head> 

        <p>We would like to create functions that return the defaults
	for match options. Each implementation may choose different
	default values for match options. The purpose of these
	functions is to query and return those defaults.</p><p>This
	issue was raised at the Dec. 2004 F2F in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Dec/0072.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p><resolution><p>
	CLOSED.</p><p>If we decide to pursue this functionality, we
	decided to do it in VNext and it will most likely be pursued
	in XQuery instead of XQuery and XPath Full-Text because if
	users want to query for defaults, they will be interested in
	those for both XQuery and XQuery and XPath
	Full-Text.</p><p>See F2F minutes in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jul/0049.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p></resolution>
</issue>


<issue id="weight-granularity" status="closed">
	<head>Weight Granularity in Scoring (Cluster A, Issue
	54)</head> <p>Michael Rys: Should we permit weights to be
	expressed at the level of FTContainsExpr and FTSelection or
	should we only permit them at the level of individual terms
	(FTWords)?</p><resolution><p> CLOSED.</p><p>Resolved by
	Cluster A, Issue 17</p></resolution>
</issue>
     
<issue id="specialcharacters" status="closed">
	<head>Special Characters (VNext, Cluster E, Issue 55)</head>
	<p>We removed the special characters match option from the
	current draft and we will consider it for V next.</p>
	<p>Discussion initiated in
	<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Dec/0072.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p><resolution><p> CLOSED.</p><p>Postponed to VNext.</p></resolution>
</issue>
        
<issue id="scoring-corpus" status="closed">
	<head> Scoring Corpus (VNext, Cluster A, Issue 56)</head>
	<p>Do we want to alows users to specify a scoring corpus such as in:</p>
        <p>Discussion initiated in
	<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Dec/0072.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p><resolution><p> CLOSED.</p><p>Postponed to VNext.</p></resolution>
</issue>


<issue id="collations-match-option" status="closed">
	<head> Collations Match Option (VNext, Cluster D, Issue 57)</head>

       <p>Currently, XQuery 1.0 and XPath 2.0 Full-Text depends on the
collation chosen in XQuery. It can be modified by the FTCaseOption and
the FTDiacriticsOption match options. We need to explore the
interaction of the collation with FTLanguageOption. Presumably, the
latter will change the collation. What if there are more than one
collations available for a given language? Moreover, if we decide to
introduce back the FTSpecialCharsOption (see Issue 24), there might be
different collations that treat special characters differently.</p>

<p>One approach is to have a FTCollationOption:</p>

<p>FTCollationOption ::=  "using"? "collation" CollationUri</p>

<p>Another option is to have a collation only associated with 
FTLanguageOption (and possibly a future version of FTSpecialCharsOption)</p>

<p>FTLanguageOption := "language" UnionExpr ("collation" CollationUri)?</p><resolution><p> CLOSED.</p><p>Postponed to VNext.</p></resolution>
</issue>


<issue id="ft-about-operator" status="closed">
	<head> Free-text search operator ft-about (VNext, Cluster H, Issue 58)</head>

       <p>While 'ftcontains' is aimed at supporting full text queries
       for XPath/XQuery still it lacks internet-style IR searches
       where the user can't express precisely her needs and would like
       to let the search engine return also close matches. For example
       a user need like "+cat dog" which request to find documents
       that contain a 'cat' but rank those that contain also a 'dog'
       higher is hard to express with 'ftcontains'. With
       'ftcontains' one can express either ftcontains(cat and dog)
       which will return only documents that have both cat and dog or
       ftcontains(cat or dog) which will return documents containing
       cat or dog. None is what the user needs. </p>

       <p>In order to express the above user need in XQuery-FT one
       needs to separate the user need into a filtering part and a
       scoring part. For example, the XQuery syntax to find all books
       with a title that contains a 'cat', but give those that contain
       also a 'dog' a higher ranking is shown below. </p>

  <eg role="parse-text" xml:space="preserve">
for $book in /books/book
where $book/title ftcontains "cat" 
let $score := ft:score($book/title ftcontains "cat" || "dog")
where $score &gt; 0
order by $score
return $book
    </eg>
       <p>The first 'ftcontains' is needed for filtering while the
       second 'ftcontains' is for scoring. We see that the search
       arguments of the two 'ftcontains' predicates are quite similar
       with the difference that the first contains 'cat' while the
       second contains also 'dog'. In general, this results in rather
       complex queries that redundantly have to repeat the same query
       terms in different query parts, even for simple user needs.</p>

       <p>A proposal to overcome this problem has been put forward by
       Yosi Mass (IBM Research) and Jochen Doerre 
       by introducing a free-text operator 'ft-about' that allows to
       specify Internet-style searches directly. For instance, the
       query above could be expressed without duplication as:</p> 
  <eg role="parse-text" xml:space="preserve">
for $book in /books/book
let $score := ft:score($book/title ft-about "+cat dog")
where $score &gt; 0
order by $score
return $book
    </eg>

    <p>For more details see 
       <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2004Nov/0019.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
    </p>
    <p>Open question: how can ft-about be integrated more tightly with
    ftcontains?</p>

<p>Raised by Jochen.
</p>
<resolution><p> CLOSED.</p> <p>No change to the document with
  resolution that it is to be considered for VNext, because it is not
  clear how it will fit with the grammar and the data model and it is
  not clear what the ftabout search would do and how tightly we could
  define it.</p><p>See F2F minutes in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jul/0049.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p></resolution>
</issue>
  
<issue id="error-codes" status="closed">
	<head>Error Codes(Cluster J, Issue 59)</head> <p>XPath
        2.0, XQuery 1.0, and associated documents use 8-character
        error codes. The Full-Text spec uses 6-character error codes.
        Full-Text must be brought up to date and use 8-character error
        codes.</p>
<resolution><p> CLOSED.</p> <p>Error codes have been adapted.</p></resolution>
</issue>



<issue id="extended-scoring" status="closed">
	<head> Extended Scoring (Cluster A, Issue 60)</head>

<p>
Motivation:</p>
<p>The proposal extends the previous (SCORE AS) scoring proposal in
two ways.
</p>

<olist>
<item>
<p>It provides a iterator that can iterate over an item *and* its score
in a single construct.</p></item>

<item>
<p>It allows users to relax the semantics of XPath/XQuery expressions
so that users can obtain "fuzzy" results along with their scores.</p>
</item>
</olist>

<p>
The benefit of (1) is that it makes queries easier to write since the
score is directly attached to an item in a single construct. This is
in contrast to the original scoring proposal, where a FOR clause is
required to iterate over items and a separate SCORE AS clause
is required to score the items.
</p>

<p>
The benefit of (2) is that it generalizes traditional Information Retrieval (IR) and can
capture the class of queries used by the XML IR community (notably INEX). 
In traditional IR, end-users who ask keyword queries are perfectly 
happy when the system returns documents that contains those keywords or
stemmed versions of those keywords or synonyms. By analogy, XQuery FT
(like INEX) should allow the possibility of interpreting XQuery expressions
(i.e., queries on both content and structure) in a fuzzy way on behalf of 
users. This should make the query specification less cumbersome for users 
since they do not have to (and may not be able to) explicitly specify all 
the query variants. 
</p>

<p>
The proposal can be divided into three separate parts that can be decided upon independently.</p>
<olist>
<item>
<p> Extend FOR clause with a score binding option.</p>
<p>
Proposed syntax: 
  <eg xml:space="preserve">
    for $res scored $score in EXPR
    </eg>
</p>

<p>Semantics:</p>
<p>
Let S be the result of evaluating the XQuery expression EXPR.</p>

<p>
As a normal FOR clause this clause iterates over each item in S and 
binds $res to the item, but also binds $s to the score of the item. 
</p>

<p>
Like in the SCORE AS clause we need to assume a second-order 
function for the evaluation of EXPR. E.g., it makes a difference, 
whether EXPR is a just a function call which evaluates to some 
sequence, or is the equivalent body of the function. Only in the
latter case the scoring can take the evaluation of the function
body into account.
</p>

<p>
We might want to restrict the kinds of expressions allowed in EXPR as 
discussed below in 3.
</p>
</item>


<item>
<p> Add FUZZY keyword to scoring constructs.</p>
<p>
Proposed syntax (when combined with extended for):
  <eg xml:space="preserve">
    for $res scored $score in fuzzy EXPR
    </eg>
</p>

<p>
(when combined with SCORE AS):
  <eg xml:space="preserve">
    score $s as fuzzy EXPR
    </eg>
</p>

<p>
Motivation: allow for query relaxation based on relevance; find 
also items relevant to the query that are near matches.</p>

<p>
Semantics:
Based on super-sequence (as specified in 
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Mar/0152.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>)
Any result to the non-scoring variant of the expression
is a result, but there may be more.
</p>
</item>

<item>
<p> Should we restrict expressions over which scoring is
done to, say, Boolean combinations of FTContainsExpr?</p>

<p>
This applies to both the proposed new FOR syntax, as well as
the SCORE AS clause.</p>
<p>
Note: Because scoring semantics is completely implementation-dependent, 
implementations are free to simply ignore the embedding of search 
expression inside XPaths, for instance.</p>
</item>

<item>
<p> In combination with 1., extend LET clauses with a
score binding option, just as 1. extends FOR clauses.</p>

<p>
This syntax replaces the SCORE AS clause.</p>
<p>
Proposed syntax: 
  <eg xml:space="preserve">
    let $v := EXPR scored $score
    </eg>
</p>
<p>
In contrast to the SCORE AS clause where EXPR is evaluated to 
only calculate a score, but not a result, this syntax allows
to calculate a pair (result, score), as it is done in the
FOR clause extension above.

</p>
</item>
</olist>

<p>
Benefits of extended scoring:
</p>

<ulist>
<item><p>Can score over all of XQuery (note that Expr can be an arbitrary
XQuery expression).</p>
</item>
<item><p>Can support query relaxation using the FUZZY keyword.</p>
</item>
<item><p>Makes the syntax of queries simpler (illustrated below).</p>
</item>
<item><p>Can be integrated with XPath.</p>
</item>
<item><p>Can be combined with the ORDERBY clause of FLWOR to sort results based
on their scores.</p>
</item>
</ulist>

<p>
Examples:</p>
<p>
One of the main motivations for the  scoring FOR proposal is the ability to
express XML information retrieval queries such as the INEX queries 
(see http://inex.is.informatik.uni-duisburg.de:2004/). INEX is an
effort that collects XML documents to assess scoring methods for XML
in the same way as TREC was defined for assessing keyword search.
</p>
<p>
We give some examples below and explain the syntax/semantics of the
new scoring construct.
</p>

<p>
Query 1: Find articles on "Usability"
</p>

<p>Expressed using scoring FOR:

  <eg xml:space="preserve">
for $result scored $score in //article[. ftcontains "Usability"]
return &lt;result score="{$score}"&gt;{$result}&lt;/result&gt;
    </eg>

The above query returns all articles and their score, where the score
is computed with respect to the predicate: $a ftcontains "Usability".
</p>

<p>
Expressed using SCORE AS:

  <eg xml:space="preserve">
for $result in //article
score $score as $result ftcontains "Usability"
return &lt;result score="{$score}"&gt;{$result}&lt;/result&gt;
    </eg>

This illustrates how "scoring FOR" has a more compact syntax than SCORE AS
when scoring over Boolean expressions such as ftcontains.
</p>

<p>
Query 2: Find articles and other documents on "Usability".
</p>
<p>
Expressed using scoring FOR:

  <eg xml:space="preserve">
for $result scored $score in fuzzy //article [. ftcontains "Usability"]
order by $score
return &lt;result score = "{$score}"&gt;{$result}&lt;/result&gt; 
    </eg>

The above query returns articles and other documents along with their scores,
ordered by score. Note that //article can be interpreted in a fuzzy
way since  scoring FOR can return a super-sequence of the corresponding
XQuery sequence.
</p>

<p>
Expressed using SCORE AS (Version 1):

  <eg xml:space="preserve">
for $result in //article
score $score as $result ftcontains "Usability"
order by $score
return &lt;result score = "{$score}"&gt;{$result}&lt;/result&gt;
    </eg>

The above query only returns articles (and not other documents) that
are relevant to "Usability". In this sense, this SCORE AS query is
not semantically the same as the above scoring FOR query.
</p>
<p>
Expressed using SCORE AS (Version 2):

  <eg xml:space="preserve">
for $result in //*
score $score as tagname($result) = "article" and $result ftcontains "Usability"
order by $score
return &lt;result score = "{$score}"&gt;{$result}&lt;/result&gt;
    </eg>

The above query returns all elements (not just articles) ordered by
the score of how well the element's tag name matches "article" and
how relevant it is to "Usability". However, this syntax has two
disadvantages compared to the scoring FOR. First, it is more clumsy to write
compared to the scoring FOR syntax. Second, the system has to return *all*
elements (not just those closely related to article) unless the
user performs some explicit filtering based on scores; in contrast,
the scoring FOR query only returns elements that are related to articles.
</p>

<p>
Query 3 (topic 128 in INEX): Find discussions about on-board route planning or navigation systems
which are in publications about intelligent transport systems for
automobiles.
</p>
<p>
Expressed using  scoring FOR:
 
  <eg xml:space="preserve">
for $result scored $score 
  in fuzzy //article[. ftcontains "intelligent transport systems"]
             /sec[. ftcontains 
                  "on-board route planning navigation system for automobiles"]
return &lt;result score = "{$score}"&gt;{$result}&lt;/result&gt; 
    </eg>

Since scoring FOR interprets the entire expression in a fuzzy way, it can relax
the tag names of //article and /sec. In addition, it can relax /sec to
//sec to find sections that may be indirectly contained in article.
</p>
<p>
Expressed using SCORE AS (Version 1):

  <eg xml:space="preserve">
for $a in //article, $s in $a/sec
score $score as $a ftcontains "intelligent transport systems"
      and $s ftcontains "on-board route planning navigation system for automobiles"
return &lt;result score = "{$score}"&gt;{$s}&lt;/result&gt;
    </eg>

Using this version of SCORE AS, we cannot support relaxations of the
tag names of //article and /sec. Further, SCORE AS cannot explicitly
support the relaxation of /sec to //sec. Note that simply replacing
$a/sec with $a//sec is not semantically equivalent because, in this case,
$a/sec will *not* be ranked higher than $a//sec (which it will be in
the case of scoring FOR).
</p>
<p>
Expressed using SCORE AS (Version 2):

  <eg xml:space="preserve">
for $a in //*, $s in $a/*
score $score as tagname($a) = "article" and tagname($s) = "section" 
      and $a ftcontains "intelligent transport systems"
      and $s ftcontains "on-board route planning navigation system for automobiles"
return &lt;result score = "{$score}"&gt;{$s}&lt;/result&gt;
    </eg>

This version of SCORE AS is less readable than the version using
scoring FOR. Also, it is not possible to relax $a/* to $a//* (as in the
Version 1) without losing some scoring semantics.
</p>

<p>
Raised by Sihem and Jai in 
<loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Mar/0152.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/>
</p>
<resolution><p> CLOSED.</p> <p>1. Use in definition of score: Score is
between 0 and 1 regardless of whether the ftcontains expression
returns true or false. Score is inherently fuzzy. Can compute a score
independently of computing the Boolean value. </p> <p>2. Use two
syntaxes for score, replacing the current syntax: 1) Use to return
exactly what the Boolean returns.  for $b score $s in
//books[. ftcontains "dog"] return &lt;r&gt;{$b, $s}&lt;/r&gt; 2.a) Use to return
more or less than the Boolean returns. To use fuzzy within score. Must
have one let clause, could have more than one.  for $b in //books let
score $s := $b ftcontains "dog" let $t := $b ftcontains "dog" return
&lt;r&gt;{$b, $s}&lt;/r&gt; 2.b) Use to return more or less than the Boolean
returns. To use fuzzy within score.  for $b in //books let $t score $s
:= $b ftcontains "dog" return &lt;r&gt;{$b, $s}&lt;/r&gt;.</p><p> 3. Use this
semantics: for $res score $s in Expr has the semantics of for
$scoreSeq := fts:scoreSequence (Expr) for $res at $i in Expr let $s :=
$scoreSeq [$i] </p><p>See F2F minutes in <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jul/0049.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p></resolution>

</issue>

<issue id="desired-fttimes-semantics" status="open">
	<head>Desired semantics of FTTimes (Cluster G, Issue 61)</head>
	<p>Consider the document</p>
	<eg xml:space="preserve">cat cat</eg>
	<p>and the query</p>
	<eg xml:space="preserve">("cat" &amp;&amp; "cat") occurrences exactly 4</eg>
	<p>Currently, it returns true. Is this the desired semantics 
	for FTTimes?  If yes, how do we explain it in the language 
	document?</p>
</issue>
 
<issue id="doublenegation-semantics" status="closed">
	<head>Precise semantics of double negation (Cluster G, Issue 62)</head>
	<p>Currently, (! ! Q) does not produce the same AllMatches 
	   as (Q). There seem to be two reasons for that. First, 
	   there are duplicate StringIncludes, StringExcludes, and 
	   Matches. Second, there are Matches that are subsumed by 
	   other Matches (i.e. the former are a logical consequence 
	   of the latter). How do we handle these situations? It 
	   seems reasonable to expect that !!Q produces the same 
	   result as Q.</p>
<resolution><p> CLOSED.</p> <p>AllMatches returned for FTSelections are subject to a Normal Form now, by which it is insured that (! ! Q) behaves equivalent in all contexts to (Q) (see Section <specref ref="MatchNormalizationSec"/>).</p></resolution>
</issue>

<issue id="phrases-with-distance" status="open">
	<head>Distance constraints do not work on phrases (Cluster G, Issue 63)</head>
	<p>It is not possible to combine the distance operation with 
        searching for phrases.</p>

        <p>Example: 
<eg xml:space="preserve">
[. ftcontains "Redmond-based" &amp;&amp; "company" distance at least 2]
</eg>
        The problem is that a phrase is internally resolved into a
        distance operation itself, which can impose a contradicting
        requirement to the explicit distance operation used in the
        query. Here it is (with some assumptions on tokenization):  

<eg xml:space="preserve">
[. ftcontains ("Redmond" &amp;&amp; "-" &amp;&amp; "based" ordered with distance 0) &amp;&amp; "company" distance at least 2]
</eg>

        The second distance constraint is then imposed to all
        individual tokens (including those from the phrase) and hence
        cannot be satisfied. The query will also return false.</p> 
</issue>
  
<issue id="relativedefaults" status="open">
	<head>System Relative Operator Defaults (Cluster E, Issue 64)</head>
	<p>Do we want to add system relative operator defaults? Do we
        want to add "closer and "farther" to FTDistance for novice
        users who do not want to enter specific numbers of intervening
        words, sentences, and paragraphs? Similar relative defaults
        might also be added to other operators which call FTRange and
        score weighting.</p> 
        <p>Raised by Dana Florescu at Redmond Face to Face Meeting on
        July 15, 2005.</p>
</issue>


<issue id="nested-ftnegations-right-side-ftmildnegation" status="closed">
	<head>Nested FTNegations on Right Side of FTMildNegation
	(VNext, Cluster I, Issue 65)</head> <p/>
    <resolution>
        <p>CLOSED.</p> <p> Raise a dynamic error semantically if there
is a StringExclude on the right side of an FTMildNegation. Users can
replace "&amp;&amp; not" with FTMildNegation. Possibly reconsider for
VNext.</p> <p>No changes required. Closed at F2F Meeting 84: <loc xmlns:xlink="http://www.w3.org/1999/xlink" href="http://lists.w3.org/Archives/Member/member-query-fttf/2005Jul/0061.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"/></p>
    </resolution>
</issue>

                                                                
</inform-div1>

  <inform-div1 id="id-xqft-changelog">
<head>Change Log</head>
<table border="1" summary="Change Log Table">
<tbody>
<!--
=================== commented out from here
<tr>
<td>Jochen Doerre</td>
<td>2004-10-04</td>
<td>Added issue on FTIgnore</td>
<td>Added Cluster B, Issue 50 IGNORE Queries.</td>
</tr>
<tr>
<td>Jochen Doerre</td>
<td>2004-10-04</td>
<td>Added issue on FTWindow</td>
<td>Added Cluster I, Issue 51 Alternative Semantics for FTWindow.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-01-14</td>
<td>Added issue on UnionExpr in StopWords</td>
<td>Added Cluster D, Issue 52 UnionExpr in StopWords.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-01-16</td>
<td>Added FTStartswith to syntax</td>
<td>Added Section 3.1.12 on startswith. Closed Cluster C, Issue 40 Starts With</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-01-16</td>
<td>Removed FTSpecialCharacter syntax</td>
<td>Removed the Special Character match option in section 3 and closed Cluster E, Issue 22 DiacriticsMatchOption and Cluster E, Issue 24 SpecialCharMatchOption.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-01-16</td>
<td>Updated FTLanguage syntax</td>
<td>Added the sentence "The set of valid language identifiers is implementation-defined." in Section 3.2.7 (now 3.2.6) FTLanguage.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-01-16</td>
<td>Updated score syntax</td>
<td>Changed syntax of ft:score() into score $var as Expr in Section 3.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-01-16</td>
<td>Added score weighting syntax</td>
<td>Added 1) weight to FTSelection inside a scoring expression and 2) text stating that Weight values in scoring expressions are in the interval [0,1]. Closed Cluster A, Issue 17 Weighting and Cluster A, Issue 18 Weight Values.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-01-24</td>
<td>Changed FTStartswith syntax to FTContent syntax</td>
<td>Changed FTStartswith to FTContent and changed wording to use "the tokenized string of elements".</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-01-24</td>
<td>Added issue on defaults</td>
<td>Added issue Cluster D, Issue 45 MatchOptions Default.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-01-24</td>
<td>Changed FTStopWords and FTThesaurus syntax</td>
<td>Closed Cluster E, Issue 26 StopWordsMatchOption, Cluster E, Issue 48 Stop words option, and Cluster D, Issue 8 Thesaurus, among other things changing the syntax to allow URIs for a stop word list or thesaurus.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-01</td>
<td>Added issue on score weights</td>
<td>Added Issue 54 Cluster A on weights in scores.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-10</td>
<td>Updated FTStopwords syntax</td>
<td>Updated syntax in Section 2.3.5 Stop Words.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-10</td>
<td>Updated FTThesaurus section</td>
<td>Updated descriptive text, adding reference to ISO 2788, in Section 2.3.4 Theasurus.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-10</td>
<td>Updated introduction</td>
<td>Modified item 7 in Section 1.1 to reflect conditions on tokenizers.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-10</td>
<td>Updated FTDistance syntax</td>
<td>Removed the optional keyword "with" from FTDistance.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-10</td>
<td>Updated FTWindow syntax</td>
<td>Removed the optional keyword "within" from FTWindow.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-14</td>
<td>Updated FTDiacritics syntax</td>
<td>Closed Cluster E, Issue 33 FTSpecialCharOption and Updated Section 3.2.2 Diacritics according to its resolution.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-14</td>
<td>Added FTCase and FTDiacritics matrices</td>
<td>Added matrices which summarize the interaction between the diacritics and case match options and types of collations.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-14</td>
<td>Added FTRegex escape syntax</td>
<td>Closed Cluster C, Issue 15 RegExp Escape by adding wildcard escape syntax.</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-02-14</td>
<td>Updated FTThesaurusOption and FTRegexOption semantics</td>
<td>Updated FTThesaurusOption and FTRegexOption in Section 4 Semantics.</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-02-14</td>
<td>Updated FTDiacritics semantics</td>
<td>The fts:applySingleSearchToken function in the match-options semantics section has been modified. Now it explicitly checks for the diacritics option and applies the necessary semantic functions.</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-02-14</td>
<td>Removed FTSpecialCharacter semantics</td>
<td>Removed the special-characters option semantics.</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-02-14</td>
<td>Updated FTStopWord semantics</td>
<td>Changed the XML representation and the fts:ApplyStopwordOption semantic function to reflex the new syntax.</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-02-14</td>
<td>Added FTContent semantics</td>
<td>Added an XML representation and a semantic function for FTContent.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-18</td>
<td>Updated FTRegex syntax</td>
<td>Closed Cluster C, Issue 27 MatchOption and Tokenization which required changes only to FTRegex specifying it impact on tokenization. Text added.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-21</td>
<td>Replaced FTRegex syntax with FTWildcard syntax</td>
<td>Replaced FTRegex syntax with FTWildcard syntax in Section 3.2.8</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-02-21</td>
<td>Added issue proposing FTCollationOption</td>
<td>Added Cluster D, Issue 57 Collations Match Option.</td>
</tr>
<tr>
<td>Jochen Doerre</td>
<td>2005-02-22</td>
<td>Closed issues resolved previously</td>
<td>Closed Cluster A, Issue 1 Scoring Properties with no change to the document. Closed Cluster C, Issue 7 Wildcards - regular expressions were dropped in favor of wildcards. Closed Cluster F, Issue 31 Optional Keyword "with" in FTDistance - "with" was dropped. Closed Cluster F, Issue 32 Optional Keyword "within" in FTWindow - "within" was dropped. Closed Cluster F, Issue 34 FTNegation Includes Unary Not with no change to the document.</td>
</tr>
<tr>
<td>Jochen Doerre</td>
<td>2005-02-22</td>
<td>Added issue on ft-about</td>
<td>Added Cluster H, Issue 58 Free-text search operator ft-about.</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-02-22</td>
<td>Updated FTDistance semantics</td>
<td>Removed the optional keyword "with" from FTDistance.</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-02-22</td>
<td>Updated FTWindow semantics</td>
<td>Removed the optional keyword "within" from FTWindow.</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-02-22</td>
<td>Updated FTWords semantics</td>
<td>Updated FTWords semantics to allow for zero-length string: An FTWords with an empty list of search tokens returns an empty AllMatches.</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-02-22</td>
<td>Replaced FTRegex semantics with FTWildcards semantics</td>
<td>Replaced FTRegex semantics with FTWildcards semantics.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-03-03</td>
<td>Updated FTWildcards syntax</td>
<td>Updated FTWildcards syntax in Section 3.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-03-04</td>
<td>Updated Section 2 (syntax) and issues list</td>
<td>Closed and updated Section 2 to reflect resolutions for 1) Cluster F, Issue 30 Precedence of XQuery and full-text, 2) Cluster G, Issue 47 Zero-length phrase, 3) Cluster F, Issue 49 Grammar Precedence and Lookahead. Also added introduction to the Issues List explaining the clusters.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-03-04</td>
<td>Updated FTIgnoreOption syntax</td>
<td>Updated FTIgnoreOption in Section 3.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-03-04</td>
<td>Updated FTThesaurus examples</td>
<td>Added "at" in thesaurus examples in Section 3.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-03-04</td>
<td>Updated FTWindow section</td>
<td>Added descriptive text to FTWindow.</td>
</tr>
<tr>
<td>Scott Boag</td>
<td>2005-03-10</td>
<td>Updated grammar</td>
<td>1) Integrated full-text grammar (including the "{" "}" bracketing of expressions) into the main XPath grammar file. 2) Changed the way ftcontains is called. 3) Generated parser is now generated without any lookahead enabled.</td> 
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-03-17</td>
<td>Updated Thesauri lookup</td>
<td>Closed Cluster D, Issue 42 Thesauri lookup for multi-word phrases, and updated section 4 to reflect the changes.
</td>
</tr>
<tr>
<td>Chavdar Botev</td>
<td>2005-03-17</td>
<td>Added text to describe schemas</td>
<td>Added two paragraphs to FTSelections and FTMatchOptions which describe the schemas.
</td>
</tr>
<tr>
<td>Scott Boag</td>
<td>2005-03-19</td>
<td>Updated FTThesaurus production</td>
<td>Updated FTThesaurus production by adding "at" before "except" and "union".</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-03-22</td>
<td>Removed ft and fts namespace references</td>
<td>Removed references to the ft (full-text) and fts (full-text semantics) namespaces.</td>
</tr>
<tr>
<td>Sihem Amer-Yahia</td>
<td>2005-03-28</td>
<td>Updated FTThesaurus syntax</td>
<td>Updated FTThesaurus in Section 3.</td>
</tr>
============= commented out upto here
-->

<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-04-08</td>
<td colspan="1" rowspan="1">Updated case matrix</td>
<td colspan="1" rowspan="1">Updated case matrix row "sensitive", column "CCI" from "case-insensitive variant of CCI if it exists, else error" to 
"case-sensitive variant of CCI if it exists, else error".</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-02</td>
<td colspan="1" rowspan="1">Closed issues with no changes</td>
<td colspan="1" rowspan="1">Closed Cluster B, Issue 28 IGNORE Syntax with no change to the document. Closed Cluster B, Issue 50 IGNORE Queries with no change to the document.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-02</td>
<td colspan="1" rowspan="1">Updated FTTimes syntax</td>
<td colspan="1" rowspan="1">Closed Cluster G, Issue 14 FTTimesSelection and added a related bullet item in Section 3.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-02</td>
<td colspan="1" rowspan="1">Updated FTWildCard syntax</td>
<td colspan="1" rowspan="1">Updated FTWildCardOption in Section 3.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-03</td>
<td colspan="1" rowspan="1">Updated introduction</td>
<td colspan="1" rowspan="1">Replaced "semantic element" with "semantic markup" and "tag" with "element" in the introduction.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-03</td>
<td colspan="1" rowspan="1">Added issue on error codes</td>
<td colspan="1" rowspan="1">Added Cluster J, Issue 59 Error Codes.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-03</td>
<td colspan="1" rowspan="1">Closed issues with no change</td>
<td colspan="1" rowspan="1">Closed Cluster A, Issue 54 Weight Granularity in Scoring with same resolution as for Cluster A, Issue 5 Score Weighting, no further change to document. Closed Cluster H, Issue 9 Window with no change to the document. Closed Cluster H, Issue 19 FTScopeSelection on structure with no change to the document. Closed Cluster E, Issue 25 MatchOption Syntax with no change to the document. Closed Cluster H, Issue 44 FTContains Semantics with no change to the document.
</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-03</td>
<td colspan="1" rowspan="1">Updated FTContent syntax</td>
<td colspan="1" rowspan="1">Updated FTContent adding "entire content", Closed Cluster C, Issue 39 Exact Element Content.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-03</td>
<td colspan="1" rowspan="1">Closed issue on Boolean Naming</td>
<td colspan="1" rowspan="1">Closed Cluster F, Issue 38 Boolean Naming. Changes to the document are pending awaiting a decision on whether it is OK to use "and", "or", "not" for full-text. If so change existing symbols to "and", "or", "not". If not change existing symbols to "ftand", "ftor", "ftnot".</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Chavdar Botev</td>
<td colspan="1" rowspan="1">2005-05-03</td>
<td colspan="1" rowspan="1">Updated FTDistance semantics</td>
<td colspan="1" rowspan="1">Updated the semantics for distance.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-03</td>
<td colspan="1" rowspan="1">Updated FTRange syntax</td>
<td colspan="1" rowspan="1">Made "exactly" required before an exact number in FTRange. Closed Cluster F, Issue 43 Exactly in FTRangeSpec.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-05-04</td>
<td colspan="1" rowspan="1">Closed issue on collations</td>
<td colspan="1" rowspan="1">Closed Cluster D, Issue 57 Collations Match Option.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-05-19</td>
<td colspan="1" rowspan="1">Added issue on scoring</td>
<td colspan="1" rowspan="1">Added Cluster A, Issue 60 Extended Scoring.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Chavdar Botev</td>
<td colspan="1" rowspan="1">2005-06-29</td>
<td colspan="1" rowspan="1">Added issue on FTNegation</td>
<td colspan="1" rowspan="1">Added Cluster G, Issue 62 Precise semantics of double negation.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Chavdar Botev</td>
<td colspan="1" rowspan="1">2005-06-29</td>
<td colspan="1" rowspan="1">Added issue on FTTimes</td>
<td colspan="1" rowspan="1">Added Cluster G, Issue 61 Desired semantics of FTTimes.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-07-11</td>
<td colspan="1" rowspan="1">Updated FTMildNegation syntax</td>
<td colspan="1" rowspan="1">Updated the mild not syntax from "mild not" to "not in". Closed Cluster I, Issue 10 MildNot and Cluster F, Issue 41 Mildnot Naming.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Chavdar Botev</td>
<td colspan="1" rowspan="1">2005-07-12</td>
<td colspan="1" rowspan="1">Updated FTIgnore semantics</td>
<td colspan="1" rowspan="1">Changed semantics of FTIgnoreOption.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-07-18</td>
<td colspan="1" rowspan="1">Corrected error codes</td>
<td colspan="1" rowspan="1">Corrected and added error codes, closing and implementing the resolution for Cluster J Issue 59 Error Codes.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-07-18</td>
<td colspan="1" rowspan="1">Closed issues with no changes</td>
<td colspan="1" rowspan="1">closed Cluster I, Issue 13 "loose-grammar" leaving the grammar as it is. Closed issue Cluster D, Issue 53 "matchoptions-default" with no change to the document. Closed Cluster H, Issue 58 "ft-about-operator" with no change to the document.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-07-21</td>
<td colspan="1" rowspan="1">Updated score syntax</td>
<td colspan="1" rowspan="1">Closed Cluster A, Issue 60 "new-scoring-proposal" and Issue 2
"scoring-values" and updated Section 2.2 Score Clause to reflect new score syntaxes. There are now syntaxes for scored queries 1) returning the same results as queries with Boolean predicates and 2) for returning more or fewer results.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-07-21</td>
<td colspan="1" rowspan="1">Added appendix for defaults</td>
<td colspan="1" rowspan="1">Added appendix for defaults in the query prolog analogous to C.1 in the XQuery language document.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-07-21</td>
<td colspan="1" rowspan="1">Updated FTThesaurus section</td>
<td colspan="1" rowspan="1">Aligned description in Section 3.2.4 FTThesaurusOption with current grammar.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-07-21</td>
<td colspan="1" rowspan="1">Opened and closed issue on nested FTNegation</td>
<td colspan="1" rowspan="1">Opened and closed Cluster I, Issue 65 Nested FTNegations on the right side of an FTMildNegation.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Chavdar Botev</td>
<td colspan="1" rowspan="1">2005-07-25</td>
<td colspan="1" rowspan="1">Updated FTMildNegation semantics</td>
<td colspan="1" rowspan="1">Changed the semantics of MildNot.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-08-10</td>
<td colspan="1" rowspan="1">Added Change Log</td>
<td colspan="1" rowspan="1">Added Change Log harvesting back entries from CVS change log.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-17</td>
<td colspan="1" rowspan="1">Grammar changes</td>
<td colspan="1" rowspan="1">Changed XQuery/XPath grammar for new scoring syntax (resolution of
Issue 60), for match option defaults in query prolog (resolution of
Issue 45), for simplified window operator (resolution to Issue 51),
renamed "mild not" to "not in" (resolution of Issue 41), modified
FTThesaurusOption, FTStopwordOption and FTLanguageOption to require
StringLiterals as decided in May 05 F2F.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-17</td>
<td colspan="1" rowspan="1">Changes to Section 2</td>
<td colspan="1" rowspan="1">New scoring syntax introduced; rewritten most of 2.2. Corrected use
of weights in 2.2.1 (wrong default, wrong use of 1.5)</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-17</td>
<td colspan="1" rowspan="1">Changes to Section 3</td>
<td colspan="1" rowspan="1">Adapting the explanations to changed syntax for FTWindow,
FTThesaurusOption, FTStopwordOption and FTLanguageOption. Also
corrected a couple of example explanations. Removed FTIgnoreOption
from the list of match option defaults in 3.2 Corrected explanation
and example of FTLanguageOption (diacritics nor case are
language-specific!). Commented out last two examples of FTDistance,
because distance 15 does not work for phrases.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-17</td>
<td colspan="1" rowspan="1">Appendices A+B</td>
<td colspan="1" rowspan="1">Adapted introductory comment about which version of the
XQuery/XPath grammars we are aligned to.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-17</td>
<td colspan="1" rowspan="1">Dates in Header</td>
<td colspan="1" rowspan="1">Adapted current date and previous date and links in
full-text-query-language-semantics.xml and in tqheader.xml.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-19</td>
<td colspan="1" rowspan="1">Added Section 2.3, Changes in 3+4</td>
<td colspan="1" rowspan="1">Added Section 2.3 Extension to Static Context. Changed Sections 3.2
and 4.4.1.1 to refer to match option settings in the static context.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-19</td>
<td colspan="1" rowspan="1">Added Issue 63</td>
<td colspan="1" rowspan="1">Added Cluster G Issue 63: Distance constraints do not work on phrases.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-19</td>
<td colspan="1" rowspan="1">Changes in Section 4</td>
<td colspan="1" rowspan="1">Adapted semantics to new scoring feature (resolution of Issue 60),
changed FTWindow semantics according to resolution of Issue
51, and cleaned examples. </td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-19</td>
<td colspan="1" rowspan="1">Appendix G</td>
<td colspan="1" rowspan="1">Added lines for statically known thesauri and stop lists.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-08-25</td>
<td colspan="1" rowspan="1">Added Issue 64</td>
<td colspan="1" rowspan="1">Added Cluster E Issue 64:System Relative Operator Defaults (using wording proposed by Pat Case).</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-10-10</td>
<td colspan="1" rowspan="1">Changes in Section 3</td>
<td colspan="1" rowspan="1">Rephrased Section 3.2.7 FTIgnoreOption. Explanation and example adapted to simple (non-recursive) use of "ignore".</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-10-10</td>
<td colspan="1" rowspan="1">Changes in Section 4</td>
<td colspan="1" rowspan="1">Incorporated Section 4.3.1.4 Match and AllMatches Normal Form.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Sihem Amer-Yahia</td>
<td colspan="1" rowspan="1">2005-10-12</td>
<td colspan="1" rowspan="1">Incorporated comments</td>
<td colspan="1" rowspan="1">Incorporated Pat's comments at http://lists.w3.org/Archives/Member/member-query-fttf/2005Sep/0068.html</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jim Melton</td>
<td colspan="1" rowspan="1">2005-10-20</td>
<td colspan="1" rowspan="1">Changes in Sections 3 and 4</td>
<td colspan="1" rowspan="1">Properly marked up errors and inserted error summary appendix. Re-ordered appendices so normative appendices precede non-normative appendices.</td>
</tr>
<tr>
<td colspan="1" rowspan="1">Jochen Doerre</td>
<td colspan="1" rowspan="1">2005-10-24</td>
<td colspan="1" rowspan="1">Final editings</td>
<td colspan="1" rowspan="1">Included corrections to examples in Section 3. Changed meaning of distance 0 for sentences (paragraphs) to mean adjacent. Rework of Appendix H Checklist of Implementation-Defined Features. Resolution texts to issues 45, 59, and 62.</td>
</tr>
</tbody>
</table>
</inform-div1>

	</back>
</spec>