<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc toc="yes"?>
<?rfc-ext parse-xml-in-artwork="yes" ?>
<?rfc-ext allow-markup-in-artwork="yes" ?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc-ext authors-section="end" ?>
<?rfc-ext sec-no-trailing-dots="yes" ?>
<?rfc-ext include-references-in-index="yes" ?>
<?rfc-ext html-pretty-print="prettyprint https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"?>

<rfc xmlns:x="http://purl.org/net/xml2rfc/ext" number="5323" category="std" x:maturity-level="proposed">

<front>
  <title abbrev="WebDAV SEARCH">Web Distributed Authoring and Versioning (WebDAV) SEARCH</title>
		
  <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
  	<organization abbrev="greenbytes">greenbytes GmbH</organization>
		<address>
      <postal>
        <street>Hafenweg 16</street>
        <city>Muenster</city><region>NW</region><code>48155</code>
        <country>Germany</country>
      </postal>
		  <phone>+49 251 2807760</phone>	
			<email>julian.reschke@greenbytes.de</email>	
			<uri>http://greenbytes.de/tech/webdav/</uri>	
		</address>
	</author>
    
	<author initials="S." surname="Reddy" fullname="Surendra Reddy">
		<organization abbrev="Mitrix">Mitrix, Inc.</organization>
		<address>
	    <postal>
   	    <street>303 Twin Dolphin Drive, Suite 600-37</street>
       	<city>Redwood City</city><region>CA</region><code>94065</code>
        <country>U.S.A.</country>
      </postal>
      <phone>+1 408 500 1135</phone>
      <email>Surendra.Reddy@mitrix.com</email>
	  </address>
  </author>
    
  <author initials="J." surname="Davis" fullname="Jim Davis">
    <address>
      <postal>
        <street>27 Borden Street</street>
        <city>Toronto</city><region>Ontario</region><code>M5S 2M8</code>
        <country>Canada</country>
      </postal>
      <phone>+1 416 929 5854</phone>
      <email>jrd3@alum.mit.edu</email>
      <uri>http://www.econetwork.net/~jdavis</uri>
    </address>
  </author>

	<author initials="A." surname="Babich" fullname="Alan Babich">
		<organization abbrev="IBM">IBM Corporation</organization>
    <address>
			<postal>
        <street>3565 Harbor Blvd.</street>
        <city>Costa Mesa</city><region>CA</region><code>92626</code>
        <country>U.S.A.</country>
      </postal>
      <phone>+1 714 327 3403</phone>
      <email>ababich@us.ibm.com</email>
    </address>
  </author>    

  <date month="November" year="2008"/>

  <keyword>HTTP</keyword>
  <keyword>Query</keyword>
  <keyword>Properties</keyword>

<abstract>
<t>
  This document specifies a set of methods, headers, and properties
  composing Web Distributed Authoring and Versioning (WebDAV) SEARCH, an application of the HTTP/1.1 protocol to efficiently search for DAV 
  resources based upon a set of client-supplied criteria.   
</t>
</abstract>



	</front><middle>

<section title="Introduction">

<section title="DASL">
<t>
  This document defines Web Distributed Authoring and Versioning (WebDAV) SEARCH, an application
  of HTTP/1.1 forming a lightweight search protocol to transport queries
  and result sets that allows clients to make use of server-side search facilities.
  It is based on earlier work done in the IETF DASL Working Group (see <xref target="contributors"/>).
  
  In this specification, the terms "WebDAV SEARCH" and "DASL" are used interchangeably.
</t>
<t>
  DASL minimizes the complexity of clients so as to facilitate widespread
  deployment of applications capable of utilizing the DASL search mechanisms.
</t>

<t>
  DASL consists of:
	<list style="symbols">
		<t>the SEARCH method and the request/response formats defined for it (<xref target="METHOD_SEARCH"/>),</t>
		<t>feature discovery through the "DASL" response header and
    the optional DAV:supported-grammar-set property (<xref target="discovery.of.supported.query.grammars"/>),</t>
		<t>optional grammar schema discovery (<xref target="QSD"/>), and</t>
    <t>one mandatory grammar: DAV:basicsearch (<xref target="basicsearch"/>).</t>
  </list>
</t>

</section>

<section title="Relationship to DAV">
<t>
  DASL relies on the resource and property model defined by <xref target="RFC4918"/>.
  DASL does not alter this model. Instead, DASL allows clients to access DAV-modeled
  resources through server-side search.
</t>
</section>



<section title="Terms">
<t>
   This document uses the terms defined in <xref target="RFC2616"/>, 
   <xref target="RFC4918"/>, <xref target="RFC3253"/>, and in this section.
</t>
<t><x:dfn>Criteria<iref item="Criteria" primary="true"/></x:dfn>
  <list><t>
    An expression against which each resource in the search scope is evaluated.
  </t></list>
</t>
<t><x:dfn>Query<iref item="Query" primary="true"/></x:dfn>
  <list><t>
    A query is a combination of a search scope, search criteria, result record
    definition, sort specification, and a search modifier.
  </t></list>
</t>
<t><x:dfn>Query Grammar<iref item="Query Grammar" primary="true"/></x:dfn>
  <list><t>
    A set of definitions of XML elements, attributes, and constraints on their
    relations and values that defines a set of queries and the intended semantics. 
  </t></list>
</t>
<t><x:dfn>Query Schema<iref item="Query Schema" primary="true"/></x:dfn>
  <list><t>
    A listing, for any given grammar and scope, of the properties and operators
    that may be used in a query with that grammar and scope. 
  </t></list>
</t>
<t><x:dfn>Result<iref item="Result" primary="true"/></x:dfn>
  <list><t>
    A result is a result set, optionally augmented with other information describing the search as a whole.
  </t></list>
</t>
<t><x:dfn>Result Record<iref item="Result Record" primary="true"/></x:dfn>
  <list><t>
    A description of a resource. A result record is a set of properties, and possibly other descriptive information.
  </t></list>
</t>
<t><x:dfn>Result Record Definition<iref item="Result Record Definition" primary="true"/></x:dfn>
  <list><t>
    A specification of the set of properties to be returned in the result record.
  </t></list>
</t>
<t><x:dfn>Result Set<iref item="Result Set" primary="true"/></x:dfn>
  <list><t>
    A set of records, one for each resource for which the search criteria evaluated to True. 
  </t></list>
</t>
<t><x:dfn>Scope<iref item="Scope" primary="true"/></x:dfn>
  <list><t>
    A set of resources to be searched. 
  </t></list>
</t>
<t><x:dfn>Search Arbiter<iref item="Search Arbiter" primary="true"/></x:dfn>
  <list><t>
    A resource that supports the SEARCH method.
  </t></list>
</t>
<t><x:dfn>Search Modifier<iref item="Search Modifier" primary="true"/></x:dfn>
  <list><t>
    An instruction that governs the execution of the query but is not part of
    the search scope, result record definition, the search criteria, or the sort
    specification. An example of a search modifier is one that controls how
    much time the server can spend on the query before giving a response. 
  </t></list>
</t>
<t><x:dfn>Sort Specification<iref item="Sort Specification" primary="true"/></x:dfn>
  <list><t>
    A specification of an ordering on the result records in the result set. 
  </t></list>
</t>
</section>

<section title="Notational Conventions">
<t>
  This specification uses the Augmented Backus-Naur Form (ABNF) notation of <xref target="RFC5234"/>,
  unless explicitly stated otherwise.
</t>
<t>
  The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document
  are to be interpreted as described in <xref target="RFC2119"/>.
</t>
<t>
  This document uses XML DTD fragments 
  (<xref target="XML" x:fmt="," x:sec="3.2" x:rel="#elemdecls"/>) as a purely notational convention. WebDAV
  request and response bodies cannot be validated by a DTD  due to the specific
  extensibility rules defined in <xref target="RFC4918" x:fmt="of" x:sec="17"/> and
  due to the fact that all XML elements defined by this specification use the 
  XML namespace name "DAV:". In particular:
  <list style="numbers">
    <t>element names use the "DAV:" namespace,</t>  
    <t>element ordering is irrelevant unless explicitly stated,</t>  
    <t>extension elements (elements not already defined as valid child
    elements) may be added anywhere, except when explicitly stated otherwise,</t>  
    <t>extension attributes (attributes not already defined as valid for this
    element) may be added anywhere, except when explicitly stated otherwise.</t>  
  </list>
</t>
<t>
  When an XML element type in the "DAV:" namespace is referenced in this document
  outside of the context of an XML fragment, the string "DAV:" will be prefixed to
  the element type.
</t>
<t>
  Similarly, when an XML element type in the namespace "http://www.w3.org/2001/XMLSchema"
  is referenced in this document outside of the context of an XML fragment, the
  string "xs:" will be prefixed to the element type.
</t>
<t>
  This document inherits, and sometimes extends, DTD productions from <xref target="RFC4918" x:fmt="of" x:sec="14"/>.
</t>

</section>

<section title="Note on Usage of 'DAV:' XML Namespace">
<t>
  This specification defines elements, properties, and condition names in the
  XML namespace "DAV:". In general, only specifications authored by IETF
  working groups are supposed to do this. In this case an exception was made,
  because WebDAV SEARCH started its life in the IETF DASL working group
  (<eref target="http://www.webdav.org/dasl/"/>, and at the time the working
  group closed down there was already significant deployment of this specification.
  
</t>
</section>


<section title="An Overview of DASL at Work">
<t>
One can express the basic usage of DASL in the following steps:
<list style="symbols">
  <t>The client constructs a query using the DAV:basicsearch grammar.</t>
  <t>The client invokes the SEARCH method on a resource that will perform the
     search (the search arbiter) and includes a text/xml or application/xml request entity that
     contains the query.</t>
  <t>The search arbiter performs the query.</t>
  <t>The search arbiter sends the results of the query back to the client in
     the response. The server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> send an entity
     that matches the 
     WebDAV multistatus format (<xref target="RFC4918" x:fmt="," x:sec="13"/>).</t>
</list>
</t>
</section>

</section>

<section title="The SEARCH Method" anchor="METHOD_SEARCH">
<iref item="SEARCH method" primary="true"/>
<iref item="Methods" subitem="SEARCH" primary="true"/>



<section title="Overview">
<t>
  The client invokes the SEARCH method to initiate a server-side search.
  The body of the request defines the query. The server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> emit
  an entity matching the WebDAV multistatus format
  (<xref target="RFC4918" x:fmt="," x:sec="13"/>).
</t>
<t>
  The SEARCH method plays the role of transport mechanism for the query
  and the result set. It does not define the semantics of the query. The
  type of the query defines the semantics.
</t>
<t>
  SEARCH is a safe method; it does not have any significance other than
  executing a query and returning a query result (see
  <xref target="RFC2616" x:fmt="," x:sec="9.1.1"/>).
</t>
</section>

<section title="The Request">
<t>
  The client invokes the SEARCH method on the resource named by the Request-URI.
</t>

<section title="The Request-URI">
<t>
  The Request-URI identifies the search arbiter.
  Any HTTP resource may function as search arbiter. It is not a new type of
  resource (in the sense of DAV:resourcetype as defined in 
  <xref target="RFC4918" x:fmt="," x:sec="15.9"/>),
  nor does it have to be a WebDAV-compliant resource.
</t>
<t>
  The SEARCH method defines no relationship between the arbiter and the
  scope of the search; rather, the particular query grammar used in the query
  defines the relationship. For example, a query grammar may force
  the Request-URI to correspond exactly to the search scope.
</t>
</section>

<section title="The Request Body" anchor="request.body">
<t>
  The server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> process a text/xml or application/xml request body, and
  <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> process request bodies in other formats. See <xref target="RFC3023"/> for guidance
  on packaging XML in requests.
</t>
<t>
  <x:h>Marshalling:</x:h>
  <list>
    <t>
      If a request body with content type text/xml or application/xml is included,
      it <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> be either a DAV:searchrequest or a DAV:query-schema-discovery XML
      element. Its single child element identifies the query grammar.
    </t>
    <t>
      For DAV:searchrequest, the definition of search criteria, the result record,
      and any other details needed to perform the search depend on the individual
      search grammar.
    </t>
    <t>
      For DAV:query-schema-discovery, the semantics is defined in
      <xref target="QSD"/>.
    </t>
  </list>
</t>
<t>
  <x:h>Preconditions:</x:h>
  <list>
    <t>
      <iref item="DAV:search-grammar-discovery-supported precondition" primary="true"/>
      <iref item="Condition Names" subitem="DAV:search-grammar-discovery-supported (pre)" primary="true"/>
      (DAV:search-grammar-discovery-supported): when an XML request body is present
      and has a DAV:query-schema-discovery document element, the server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14>
      support the query schema discovery mechanism described in <xref target="QSD"/>.
    </t>
    <t>
      <iref item="DAV:search-grammar-supported precondition" primary="true"/>
      <iref item="Condition Names" subitem="DAV:search-grammar-supported (pre)" primary="true"/>
      (DAV:search-grammar-supported): when an XML request body is present,
      the search grammar identified by the document element's child element
      must be a supported search grammar.
    </t>
    
    <t>
      <iref item="DAV:search-multiple-scope-supported precondition" primary="true"/>
      <iref item="Condition Names" subitem="DAV:search-multiple-scope-supported (pre)" primary="true"/>
      (DAV:search-multiple-scope-supported): if the SEARCH request specified
      multiple scopes, the server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> support this optional feature.
    </t>
    
    <t>
      <iref item="DAV:search-scope-valid precondition" primary="true"/>
      <iref item="Condition Names" subitem="DAV:search-scope-valid (pre)" primary="true"/>
      (DAV:search-scope-valid): the supplied search scope must be valid. There
      can be various reasons for a search scope to be invalid, including
      unsupported URI schemes and communication problems. Servers <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> add
      <xref target="RFC4918"/> compliant DAV:response elements as content to the
      condition element indicating the precise reason for the failure.
    </t>
  </list>
</t>
</section>
</section>

<section title="The Successful 207 (Multistatus) Response">
<t>
  If the server returns 207 (Multistatus), then the search proceeded
  successfully, and the response <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> 
  use the WebDAV multistatus format (<xref target="RFC4918" x:fmt="," x:sec="13"/>).
  The results of this method <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD NOT</bcp14> be cached. 
</t>
<t>
  There <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> be one DAV:response for each resource that matched
  the search criteria. For each such response, the DAV:href element
  contains the URI of the resource, and the response <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> include a DAV:propstat
  element.
</t>
<x:note><t>
  <x:h>Note:</x:h> the WebDAV multistatus format requires at least one
  DAV:response child element. This specification relaxes that restriction
  so that empty results can be represented.
</t></x:note>
<t>
  Note that for each matching resource found, there may be multiple URIs
  within the search scope mapped to it. In this case, a server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> report
  only one of these URIs. Clients can use the live property DAV:resource-id, defined
  in <xref target="WEBDAV-BIND" x:fmt="of" x:sec="3.1"/> to identify possible duplicates. 
</t>

<iref item="Result Set Truncation" subitem="Example" primary="true"/>
<section title="Result Set Truncation">
<t>
  A server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> limit the number of resources in a reply, for example, to limit
  the amount of resources expended in processing a query. If it does so,
  the reply <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> use status code 207, return a DAV:multistatus response
  body, and indicate a status of 507 (Insufficient Storage) for the search
  arbiter URI. It <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> include the partial results.
</t>
<t>
  When a result set is truncated, there may be many more resources that
  satisfy the search criteria but that were not examined.
</t>
<t>
  If partial results are included and the client requested an ordered
  result set in the original request, then any partial results that are returned
  <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> be ordered as the client directed.
</t>
<t>
  Note that the partial results returned <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> be any subset of the result
  set that would have satisfied the original query.
</t>
</section>

<section title="Extending the PROPFIND Response">
<t>
  A response <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> include more information than PROPFIND defines, so long as
  the extra information does not invalidate the PROPFIND response. Query
  grammars <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> define how the response matches the PROPFIND response.
</t>
</section>

<section title="Example: A Simple Request and Response">
<t>
  This example demonstrates the request and response framework. The following
  XML document shows a simple (hypothetical) natural language query. 
  The name of the query element is natural-language-query in the XML namespace
  "http://example.com/foo". The actual query is "Find the
  locations of good Thai restaurants in Los Angeles". For this hypothetical
  query, the arbiter returns two properties for each selected resource.
</t>
<figure>

<preamble>
&gt;&gt; Request:</preamble>
<artwork type="message/http; msgtype=&#34;request&#34;" xml:space="preserve">
SEARCH / HTTP/1.1
Host: example.org
Content-Type: application/xml; charset="utf-8" 
Content-Length: <x:length-of target="eb1"/>

<x:span anchor="eb1" x:lang="">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<x:parse-xml>&lt;D:searchrequest xmlns:D="DAV:" xmlns:F="http://example.com/foo"&gt;
  &lt;F:natural-language-query&gt;
    Find the locations of good Thai restaurants in Los Angeles
  &lt;/F:natural-language-query&gt;
&lt;/D:searchrequest&gt;
</x:parse-xml></x:span></artwork>
</figure>
<figure><preamble>
&gt;&gt; Response:</preamble>
<artwork type="message/http; msgtype=&#34;response&#34;" xml:space="preserve">
HTTP/1.1 207 Multi-Status
Content-Type: text/xml; charset="utf-8"
Content-Length: <x:length-of target="eb2"/>

<x:span anchor="eb2" x:lang="">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<x:parse-xml>&lt;D:multistatus xmlns:D="DAV:"
   xmlns:R="http://example.org/propschema"&gt;
  &lt;D:response&gt;
    &lt;D:href&gt;http://siamiam.example/&lt;/D:href&gt;
    &lt;D:propstat&gt;
      &lt;D:prop&gt;
        &lt;R:location&gt;259 W. Hollywood&lt;/R:location&gt;
        &lt;R:rating&gt;&lt;R:stars&gt;4&lt;/R:stars&gt;&lt;/R:rating&gt;
      &lt;/D:prop&gt;
      &lt;D:status&gt;HTTP/1.1 200 OK&lt;/D:status&gt;
    &lt;/D:propstat&gt;
  &lt;/D:response&gt;
&lt;/D:multistatus&gt;
</x:parse-xml></x:span></artwork>
</figure>
</section>


<section title="Example: Result Set Truncation">
<t>
  In the example below, the server returns just two results, and then
  indicates that the result is truncated by adding a DAV:response element
  for the search arbiter resource with 507 (Insufficient Storage) status.
</t>
<figure><preamble>
&gt;&gt; Request:</preamble>
<artwork type="message/http; msgtype=&#34;request&#34;">
SEARCH / HTTP/1.1
Host: example.net
Content-Type: text/xml; charset="utf-8"
Content-Length: xxx

 ... the query goes here ...
</artwork></figure>
<figure><preamble>
&gt;&gt; Response:</preamble>
<artwork type="message/http; msgtype=&#34;response&#34;" xml:space="preserve">
HTTP/1.1 207 Multistatus
Content-Type: text/xml; charset="utf-8"
Content-Length: <x:length-of target="eb3"/>

<x:span anchor="eb3" x:lang="">&lt;?xml version="1.0" encoding="utf-8"?&gt;
<x:parse-xml>&lt;D:multistatus xmlns:D="DAV:"&gt;
  &lt;D:response&gt;
    &lt;D:href&gt;http://www.example.net/sounds/unbrokenchain.au&lt;/D:href&gt;
    &lt;D:status&gt;HTTP/1.1 200 OK&lt;/D:status&gt;
  &lt;/D:response&gt;
  &lt;D:response&gt;
    &lt;D:href&gt;http://tech.mit.example/arch96/photos/Lesh1.jpg&lt;/D:href&gt;
    &lt;D:status&gt;HTTP/1.1 200 OK&lt;/D:status&gt;
  &lt;/D:response&gt;
  &lt;D:response&gt;
    &lt;D:href&gt;http://example.net&lt;/D:href&gt;
    &lt;D:status&gt;HTTP/1.1 507 Insufficient Storage&lt;/D:status&gt;
    &lt;D:responsedescription xml:lang="en"&gt;
       Only first two matching records were returned
    &lt;/D:responsedescription&gt;
  &lt;/D:response&gt;
&lt;/D:multistatus&gt;
</x:parse-xml></x:span></artwork></figure>
</section>
</section>

<section title="Unsuccessful Responses">
<t>
  If a SEARCH request could not be executed or the attempt to execute it
  resulted in an error, the server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> indicate the failure with an
  appropriate status code and <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> add a response body as defined in
  <xref target="RFC3253" x:fmt="of" x:sec="1.6"/>. Unless otherwise stated, condition
  elements are empty; however, specific condition elements <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> include
  additional child elements that describe the error condition in more detail.
</t>

<section title="Example of an Invalid Scope">
<t>
  In the example below, a request failed because the scope identifies a 
  HTTP resource that was not found.
</t>
<figure><preamble>
&gt;&gt; Response:</preamble>
<artwork type="message/http; msgtype=&#34;response&#34;" xml:space="preserve">
HTTP/1.1 409 Conflict
Content-Type: text/xml; charset="utf-8"   
Content-Length: <x:length-of target="eb4"/>

<x:span anchor="eb4" x:lang="">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<x:parse-xml>&lt;d:error xmlns:d="DAV:"&gt;
  &lt;d:search-scope-valid&gt;
    &lt;d:response&gt;
      &lt;d:href&gt;http://www.example.com/X&lt;/d:href&gt;
      &lt;d:status&gt;HTTP/1.1 404 Object Not Found&lt;/d:status&gt;
    &lt;/d:response&gt;
  &lt;/d:search-scope-valid&gt;
&lt;/d:error&gt;
</x:parse-xml></x:span></artwork></figure>
</section>
</section>
</section>
  
<section title="Discovery of Supported Query Grammars" anchor="discovery.of.supported.query.grammars">
<iref item="Query Grammar Discovery" primary="true"/>
<t>
  Servers <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> support discovery of the query grammars supported by a search
  arbiter resource.
</t>
<t>
  Clients can determine which query grammars are supported by an arbiter
  by invoking OPTIONS on the search arbiter. If the resource supports SEARCH,
  then the DASL response header will appear in the response. The DASL response
  header lists the supported grammars.
</t>
<t>
  Servers supporting the WebDAV extensions <xref target="RFC3253"/> and/or 
  <xref target="RFC3744"/> <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> also:
  <list style="symbols">
    <t>report SEARCH in the live property DAV:supported-method-set for all search arbiter resources, and</t>
    <t>support the live property DAV:supported-query-grammar-set as defined in <xref target="PROPERTY_supported-query-grammar-set"/>.</t>
  </list>
</t>

<section title="The OPTIONS Method">
<iref item="Query Grammar Discovery" subitem="using OPTIONS" primary="true"/>
<iref item="OPTIONS method" primary="true"/>
<t>
  The OPTIONS method allows the client to discover if a resource supports
  the SEARCH method and to determine the list of search grammars supported
  for that resource.
</t>
<t>
  The client issues the OPTIONS method against a resource named by the
  Request-URI. This is a normal invocation of OPTIONS as defined in <xref target="RFC2616" x:sec="9.2" x:fmt="of"/>.
</t>
<t>
  If a resource supports the SEARCH method, then the server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> list
  SEARCH in the Allow header
  defined in <xref target="RFC2616" x:sec="14.7" x:fmt="of"/>.
</t>
<t>
  DASL servers <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> include the DASL header in the OPTIONS response. This
  header identifies the search grammars supported by that resource.
</t>
</section>

<section title="The DASL Response Header" anchor="header.dasl">
<iref item="OPTIONS method" subitem="DASL response header" primary="true"/>
<figure>
<artwork type="abnf2616">
DASLHeader = "DASL" ":" 1#Coded-URL
Coded-URL  = &lt;defined in <xref target="RFC4918" x:fmt="of" x:sec="10.1"/>&gt;
</artwork>
<postamble>
(This grammar uses the augmented BNF format defined in <xref target="RFC2616" x:fmt="of" x:sec="2.1"/>.)
</postamble>
</figure>
<t>
  The DASL response header indicates server support for query grammars in
  the OPTIONS method. The value is a
  list of URIs that indicate the types of supported grammars.
  Note that although the URIs can be used to identify each supported search
  grammar, there is not necessarily a direct relationship between the URI and the
  XML element name that can be used in XML based SEARCH requests (the element 
  name itself is identified by its namespace name (a URI reference) and 
  the element's local name).
</t>
<x:note><t>
  <x:h>Note:</x:h> this header field value is defined as a comma-separated list
  (<xref target="RFC2616" x:fmt="," x:sec="4.2"/>); thus, grammar URIs can
  appear in multiple header instances, separated by commas, or both.
</t></x:note>
<figure><preamble>
For example:</preamble>
<artwork type="example">
DASL: &lt;http://foobar.example/syntax1&gt;,
      &lt;http://akuma.example/syntax2&gt;, &lt;DAV:basicsearch&gt;
DASL: &lt;http://example.com/foo/natural-language-query&gt;
</artwork></figure>

</section>


<section title="DAV:supported-query-grammar-set (Protected)" anchor="PROPERTY_supported-query-grammar-set">
<iref item="DAV:supported-query-grammar-set property" primary="true"/>
<iref item="Properties" subitem="DAV:supported-query-grammar-set" primary="true"/>
<iref item="Query Grammar Discovery" subitem="using live property" primary="true"/>
<t>
  This WebDAV property is required for any server supporting either
  <xref target="RFC3253"/> and/or <xref target="RFC3744"/> and
  identifies the XML-based query grammars that are supported by the search arbiter resource.
</t>
<figure>
<artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT supported-query-grammar-set (supported-query-grammar*)&gt;
&lt;!ELEMENT supported-query-grammar (grammar)&gt;
&lt;!ELEMENT grammar ANY&gt;
&lt;!-- ANY value: a query grammar element type --&gt;
</artwork></figure>
</section>


<section title="Example: Grammar Discovery">
<t>
  This example shows that the server supports search on the /somefolder
  resource with the query grammars: DAV:basicsearch, http://foobar.example/syntax1
  and http://akuma.example/syntax2. Note that servers supporting WebDAV SEARCH <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> support
  DAV:basicsearch.
</t>
<figure><preamble>
&gt;&gt; Request:</preamble>
<artwork type="message/http; msgtype=&#34;request&#34;">
OPTIONS /somefolder HTTP/1.1
Host: example.org
</artwork></figure>
<figure><preamble>
&gt;&gt; Response:</preamble>
<artwork type="message/http; msgtype=&#34;response&#34;">
HTTP/1.1 200 OK
Allow: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, COPY, MOVE
Allow: MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH
DASL: &lt;DAV:basicsearch&gt;
DASL: &lt;http://foobar.example/syntax1&gt;, &lt;http://akuma.example/syntax2&gt;
</artwork></figure>
<t>
  This example shows the equivalent taking advantage of a server's support for
  DAV:supported-method-set and DAV:supported-query-grammar-set.
</t>
<figure><preamble>
&gt;&gt; Request:</preamble>
<artwork type="message/http; msgtype=&#34;request&#34;" xml:space="preserve">
PROPFIND /somefolder HTTP/1.1
Host: example.org
Depth: 0
Content-Type: text/xml; charset="utf-8"
Content-Length: <x:length-of target="eb5"/>

<x:span anchor="eb5" x:lang="">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
<x:parse-xml>&lt;propfind xmlns="DAV:"&gt;
  &lt;prop&gt;
    &lt;supported-query-grammar-set/&gt;
    &lt;supported-method-set/&gt;
  &lt;/prop&gt;
&lt;/propfind&gt;
</x:parse-xml></x:span></artwork></figure>
<figure><preamble>
&gt;&gt; Response:</preamble>
<artwork type="message/http; msgtype=&#34;response&#34;" xml:space="preserve">
HTTP/1.1 207 Multi-Status
Content-Type: text/xml; charset="utf-8"
Content-Length: <x:length-of target="eb6"/>

<x:span anchor="eb6" x:lang="">&lt;?xml version="1.0" encoding="utf-8" ?&gt;
<x:parse-xml>&lt;multistatus xmlns="DAV:"&gt;
 &lt;response&gt;
  &lt;href&gt;http://example.org/somefolder&lt;/href&gt;
  &lt;propstat&gt;
   &lt;prop&gt;
    &lt;supported-query-grammar-set&gt;
     &lt;supported-query-grammar&gt;
      &lt;grammar&gt;&lt;basicsearch/&gt;&lt;/grammar&gt;
     &lt;/supported-query-grammar&gt;
     &lt;supported-query-grammar&gt;
      &lt;grammar&gt;&lt;syntax1 xmlns="http://foobar.example/"/&gt;&lt;/grammar&gt;
     &lt;/supported-query-grammar&gt;
     &lt;supported-query-grammar&gt;
      &lt;grammar&gt;&lt;syntax2 xmlns="http://akuma.example/"/&gt;&lt;/grammar&gt;
     &lt;/supported-query-grammar&gt;
    &lt;/supported-query-grammar-set&gt;
    &lt;supported-method-set&gt;
     &lt;supported-method name="COPY" /&gt;
     &lt;supported-method name="DELETE" /&gt;
     &lt;supported-method name="GET" /&gt;
     &lt;supported-method name="HEAD" /&gt;
     &lt;supported-method name="LOCK" /&gt;
     &lt;supported-method name="MKCOL" /&gt;
     &lt;supported-method name="MOVE" /&gt;
     &lt;supported-method name="OPTIONS" /&gt;
     &lt;supported-method name="POST" /&gt;
     &lt;supported-method name="PROPFIND" /&gt;
     &lt;supported-method name="PROPPATCH" /&gt;
     &lt;supported-method name="PUT" /&gt;
     &lt;supported-method name="SEARCH" /&gt;
     &lt;supported-method name="TRACE" /&gt;
     &lt;supported-method name="UNLOCK" /&gt;
    &lt;/supported-method-set&gt;
   &lt;/prop&gt;
   &lt;status&gt;HTTP/1.1 200 OK&lt;/status&gt;
  &lt;/propstat&gt;
 &lt;/response&gt;
&lt;/multistatus&gt;
</x:parse-xml></x:span></artwork></figure>
<t>
  Note that the query grammar element names marshalled as part of the 
  DAV:supported-query-grammar-set can be directly used as element names in
  an XML-based query.
</t>
</section>
</section>
  
<section title="Query Schema Discovery: QSD" anchor="QSD">
<t>
  Servers <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> support the discovery of the schema for a query grammar.
</t>
<t>
  The DASL response header and the DAV:supported-query-grammar-set property
  provide means for clients to discover the
  set of query grammars supported by a resource. This alone is not sufficient
  information for a client to generate a query. For example, the DAV:basicsearch
  grammar defines a set of queries consisting of a set of operators applied
  to a set of properties and values, but the grammar itself does not specify
  which properties may be used in the query. QSD for the DAV:basicsearch
  grammar allows a client to discover the set of properties that are searchable,
  selectable, and sortable. Moreover, although the DAV:basicsearch
  grammar defines a minimal set of operators, it is possible that a resource
  might support additional operators in a query. For example, a resource
  might support an optional operator that can be used to express content-based
  queries in a proprietary syntax. QSD allows a client to discover these
  operators and their syntax. The set of discoverable quantities will differ
  from grammar to grammar, but each grammar can define a means for a client
  to discover what can be discovered.
</t>
<t>
  In general, the schema for a given query grammar depends on both the
  resource (the arbiter) and the scope. A given resource might have access
  to one set of properties for one potential scope, and another set for a
  different scope. For example, consider a server able to search two distinct
  collections: one holding cooking recipes, the other design documents for
  nuclear weapons. While both collections might support properties such as
  author, title, and date, the first might also define properties such as
  calories and preparation time, while the second defined properties such
  as yield and applicable patents. Two distinct arbiters indexing the same
  collection might also have access to different properties. For example,
  the recipe collection mentioned above might also be indexed by a value-added
  server that also stored the names of chefs who had tested the recipe. Note
  also that the available query schema might also depend on other factors,
  such as the identity of the principal conducting the search, but these
  factors are not exposed in this protocol.
</t>


<section title="Additional SEARCH Semantics" anchor="additional.search.semantics">
<t>
  Each query grammar supported by DASL defines its own syntax for expressing
  the possible query schema. A client retrieves the schema for a given query
  grammar on an arbiter resource with a given scope by invoking the SEARCH
  method on that arbiter with that grammar and scope and with a root element
  of DAV:query-schema-discovery rather than DAV:searchrequest.
</t>

<t>
  <x:h>Marshalling:</x:h>
  <list style="empty"> 
    <t>
      The request body <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> be a DAV:query-schema-discovery element.
<figure><artwork type="application/xml-dtd" x:indent-with="   " x:lang="">
&lt;!ELEMENT query-schema-discovery ANY&gt;
&lt;!-- ANY value: XML element specifying the query grammar
                and the scope --&gt;
</artwork></figure>
    </t>
    <t>
      The response body takes the form of a DAV:multistatus element (<xref target="RFC4918" x:fmt="," x:sec="13"/>),
      where DAV:response is extended to hold the returned query grammar
      inside a DAV:query-schema container element.
<figure><artwork type="application/xml-dtd" x:indent-with="   " x:lang="">
&lt;!ELEMENT response (href, status, query-schema?,
  responsedescription?) &gt;
&lt;!ELEMENT query-schema ANY&gt;
</artwork></figure>
    </t>
  </list>
</t>
<t>
  The content of this container is an XML element whose name and syntax depend upon the grammar,
  and whose value may (and likely will) vary depending upon the grammar,
  arbiter, and scope.
</t>

<section title="Example of Query Schema Discovery">
<t>
  In this example, the arbiter is recipes.example, the grammar is DAV:basicsearch,
  the scope is also recipes.example.
</t>
<figure><preamble>
&gt;&gt; Request:</preamble>
<artwork type="message/http; msgtype=&#34;request&#34;" xml:space="preserve">
SEARCH / HTTP/1.1
Host: recipes.example
Content-Type: application/xml; charset="utf-8" 
Content-Length: <x:length-of target="eb7"/>

<x:span anchor="eb7" x:lang="">&lt;?xml version="1.0"?&gt;
<x:parse-xml>&lt;query-schema-discovery xmlns="DAV:"&gt;
  &lt;basicsearch&gt;
    &lt;from&gt;
      &lt;scope&gt;
        &lt;href&gt;http://recipes.example&lt;/href&gt;
        &lt;depth&gt;infinity&lt;/depth&gt;
      &lt;/scope&gt;
    &lt;/from&gt;
  &lt;/basicsearch&gt;
&lt;/query-schema-discovery&gt;
</x:parse-xml></x:span></artwork></figure>
<figure><preamble>
&gt;&gt; Response:</preamble>
<artwork type="message/http; msgtype=&#34;response&#34;">
HTTP/1.1 207 Multistatus
Content-Type: application/xml; charset="utf-8" 
Content-Length: xxx

<x:span x:lang="">&lt;?xml version="1.0"?&gt;
<x:parse-xml>&lt;multistatus xmlns="DAV:"&gt;
  &lt;response&gt;  
    &lt;href&gt;http://recipes.example&lt;/href&gt;
    &lt;status&gt;HTTP/1.1 200 OK&lt;/status&gt;
    &lt;query-schema&gt;
      &lt;basicsearchschema&gt;
        &lt;!-- (See <xref target="qs-basicsearch"/> for
        the actual contents) --&gt;
      &lt;/basicsearchschema&gt;
    &lt;/query-schema&gt;
  &lt;/response&gt;
&lt;/multistatus&gt;
</x:parse-xml></x:span></artwork></figure>
<t>
  The query schema for DAV:basicsearch is defined in <xref target="qs-basicsearch"/>.
</t>
</section>
</section>
</section>

<section title="The DAV:basicsearch Grammar" anchor="basicsearch">

<section title="Introduction">


<t>
  DAV:basicsearch uses an extensible XML syntax that allows clients
  to express search requests that are generally useful for WebDAV scenarios.
  DASL-extended servers <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> accept this grammar, and <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> accept other grammars.
</t>
<t>
  DAV:basicsearch has several components:
</t>
<t><list style="symbols">
  <t>DAV:select provides the result record definition.</t>
  <t>DAV:from defines the scope.</t>
  <t>DAV:where defines the criteria.</t>
  <t>DAV:orderby defines the sort order of the result set.</t>
  <t>DAV:limit provides constraints on the query as a whole.</t>
</list>
</t>


</section>

<section title="The DAV:basicsearch DTD">


<figure>
<preamble>&lt;!-- "basicsearch" element --&gt;</preamble>
<artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT <x:ref>basicsearch</x:ref>   (<x:ref>select</x:ref>, <x:ref>from</x:ref>, <x:ref>where</x:ref>?, <x:ref>orderby</x:ref>?, <x:ref>limit</x:ref>?) &gt;
</artwork></figure>
<figure>
<preamble anchor="select">&lt;!-- "select" element --&gt;</preamble>
<artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT <x:ref>select</x:ref>        (allprop | prop) &gt;
</artwork></figure>
<figure>
<preamble anchor="from">&lt;!-- "from" element --&gt;</preamble>

<artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT <x:ref>from</x:ref>          (scope+) &gt;
&lt;!ELEMENT scope         (href, depth, include-versions?) &gt;
&lt;!ELEMENT include-versions EMPTY &gt;
</artwork>

</figure>
<figure>
<preamble anchor="where">&lt;!-- "where" element --&gt;</preamble>
<artwork type="application/xml-dtd" x:lang="">
&lt;!ENTITY % comp_ops     "eq | lt | gt| lte | gte"&gt;
&lt;!ENTITY % log_ops      "and | or | not"&gt;
&lt;!ENTITY % special_ops  "is-collection | is-defined | 
                         language-defined | language-matches"&gt;
&lt;!ENTITY % string_ops   "like"&gt;
&lt;!ENTITY % content_ops  "contains"&gt;

&lt;!ENTITY % all_ops      "%comp_ops; | %log_ops; | %special_ops; |
                         %string_ops; | %content_ops;"&gt;

&lt;!ELEMENT <x:ref>where</x:ref>         ( %all_ops; ) &gt;

&lt;!ELEMENT and           ( %all_ops; )+ &gt;

&lt;!ELEMENT or            ( %all_ops; )+ &gt;

&lt;!ELEMENT not           ( %all_ops; ) &gt;

&lt;!ELEMENT lt            (prop, (literal|typed-literal)) &gt;
&lt;!ATTLIST lt            caseless   (yes|no) #IMPLIED&gt;

&lt;!ELEMENT lte           (prop, (literal|typed-literal)) &gt;
&lt;!ATTLIST lte           caseless   (yes|no) #IMPLIED&gt;

&lt;!ELEMENT gt            (prop, (literal|typed-literal)) &gt;
&lt;!ATTLIST gt            caseless   (yes|no) #IMPLIED&gt;

&lt;!ELEMENT gte           (prop, (literal|typed-literal)) &gt;
&lt;!ATTLIST gte           caseless   (yes|no) #IMPLIED&gt;

&lt;!ELEMENT eq            (prop, (literal|typed-literal)) &gt;
&lt;!ATTLIST eq            caseless   (yes|no) #IMPLIED&gt;

&lt;!ELEMENT literal       (#PCDATA)&gt;
&lt;!ELEMENT typed-literal (#PCDATA)&gt;
&lt;!ATTLIST typed-literal xsi:type CDATA #IMPLIED&gt;

&lt;!ELEMENT is-collection EMPTY &gt;
&lt;!ELEMENT is-defined    (prop) &gt;

&lt;!ELEMENT language-defined    (prop) &gt;
&lt;!ELEMENT language-matches    (prop, literal) &gt;

&lt;!ELEMENT like          (prop, literal) &gt;
&lt;!ATTLIST like          caseless   (yes|no) #IMPLIED&gt;

&lt;!ELEMENT contains      (#PCDATA)&gt;
</artwork>
</figure>
<figure>
<preamble anchor="orderby">&lt;!-- "orderby" element --&gt;</preamble>
<artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT <x:ref>orderby</x:ref>       (order+) &gt;
&lt;!ELEMENT order         ((prop | score), (ascending | descending)?)&gt;
&lt;!ATTLIST order         caseless   (yes|no) #IMPLIED&gt;
&lt;!ELEMENT ascending     EMPTY&gt;
&lt;!ELEMENT descending    EMPTY&gt;
</artwork></figure>
<figure>
<preamble anchor="limit">&lt;!-- "limit" element --&gt;</preamble>
<artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT <x:ref>limit</x:ref>         (nresults) &gt;
&lt;!ELEMENT nresults      (#PCDATA) &gt;
</artwork></figure>



<section title="Example Query">
<t>
  This query retrieves the content length values for all resources located
  under the server's "/container1/" URI namespace whose length exceeds 10000 sorted ascending by size.
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;d:searchrequest xmlns:d="DAV:"&gt;
  &lt;d:basicsearch&gt;
    &lt;d:select&gt;
      &lt;d:prop&gt;&lt;d:getcontentlength/&gt;&lt;/d:prop&gt;
    &lt;/d:select&gt;
    &lt;d:from&gt;
      &lt;d:scope&gt;
        &lt;d:href&gt;/container1/&lt;/d:href&gt;
        &lt;d:depth&gt;infinity&lt;/d:depth&gt;
      &lt;/d:scope&gt;
    &lt;/d:from&gt;
    &lt;d:where&gt;
      &lt;d:gt&gt; 
        &lt;d:prop&gt;&lt;d:getcontentlength/&gt;&lt;/d:prop&gt;
        &lt;d:literal&gt;10000&lt;/d:literal&gt;
      &lt;/d:gt&gt;
    &lt;/d:where&gt;
    &lt;d:orderby&gt;
      &lt;d:order&gt;
        &lt;d:prop&gt;&lt;d:getcontentlength/&gt;&lt;/d:prop&gt;
        &lt;d:ascending/&gt;
      &lt;/d:order&gt;
    &lt;/d:orderby&gt;
  &lt;/d:basicsearch&gt;
&lt;/d:searchrequest&gt;
</x:parse-xml></artwork></figure>

</section>
</section>

<section title="DAV:select">
<iref item="DAV:select" primary="true"/>
<t>
  DAV:select defines the result record, which is a set of properties
  and values. This document defines two possible values: DAV:allprop
  and DAV:prop, both defined in <xref target="RFC4918" x:fmt="of" x:sec="14"/>.
</t>

</section>

<section title="DAV:from">

<iref item="DAV:from" primary="true"/>
<iref item="DAV:scope" primary="true"/>
<iref item="DAV:depth" primary="true"/>
<iref item="DAV:include-versions" primary="true"/>
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT scope            (href, depth, include-versions?) &gt;
&lt;!ELEMENT include-versions EMPTY &gt;
</artwork></figure>
<t>
  DAV:from defines the query scope.
  This contains one or more DAV:scope elements. Support for multiple scope
  elements is optional, however servers <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> fail a request specifying
  multiple DAV:scope elements if they can't support it (see <xref target="request.body"/>,
  precondition DAV:search-multiple-scope-supported).
  The scope element contains mandatory DAV:href and DAV:depth elements.
</t>
<t>
  DAV:href indicates the URI reference (<xref target="RFC3986" x:fmt="," x:sec="4.1"/>) to use as a scope.
</t>
<t>
  When the scope is a collection, if DAV:depth is "0", the search
  includes only the collection. 
  When it is "1", the search includes the collection and its immediate
  children. When it is "infinity", it includes the collection and all its progeny.
</t>
<t>
  When the scope is not a collection, the
  depth is ignored and the search applies just to the resource itself.
</t>
<t>
  
  If the server supports WebDAV Redirect Reference Resources (<xref target="RFC4437"/>)
  and the search scope contains a redirect reference resource, then
  
  it applies only to that resource, not to its target.
</t>
<t>
  When the child element DAV:include-versions is present, the search scope
  will include all versions (see <xref target="RFC3253" x:fmt="," x:sec="2.2.1"/>) of all
  version-controlled resources in scope. Servers that do support versioning
  but do not support the DAV:include-versions feature <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> signal an 
  error if it is used in a query (see <xref target="request.body"/>, precondition DAV:search-scope-valid).
</t>


<section title="Relationship to the Request-URI">
<t>
  If the DAV:scope element is a URI (<xref target="RFC3986" x:fmt="," x:sec="3"/>), the scope is exactly
  that URI.
</t>
<t>
  If the DAV:scope element is a relative reference (<xref target="RFC3986" x:fmt="," x:sec="4.2"/>), the scope is taken
  to be relative to the Request-URI.
</t>
</section>

<section title="Scope">
<t>
  A Scope can be an arbitrary URI reference.
</t>
<t>
  Servers, of course, may support only particular scopes. This may include
  limitations for particular schemes such as "http:" or "ftp:" or certain
  URI namespaces.
  However, WebDAV-compliant search arbiters minimally <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> support
  scopes that match their own URI.
</t>
</section>
</section>


<section title="DAV:where">
<iref item="DAV:where" primary="true"/>
<t>
  The DAV:where element defines the search condition for inclusion of
  resources in the result set. The value of this element is an XML element
  that defines a search operator that evaluates to one of the Boolean truth
  values TRUE, FALSE, or UNKNOWN. The search operator contained by DAV:where
  may itself contain and evaluate additional search operators as operands,
  which in turn may contain and evaluate additional search operators as operands,
  etc., recursively.
</t>


<section title="Use of Three-Valued Logic in Queries">
<t>
  Each operator defined for use in the where clause that returns a Boolean
  value <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> evaluate to TRUE, FALSE, or UNKNOWN. The resource under scan
  is included as a member of the result set if and only if the search condition
  evaluates to TRUE.
</t>
<t>
  Consult <xref target="three-valued-logic"/> for details on the application of three-valued logic
  in query expressions.
</t>
</section>

<section title="Handling Optional Operators">
<t>
  If a query contains an operator that is not supported by the server, then 
  the server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> respond with a 422 (Unprocessable Entity) status code.
</t>
</section>

<section title="Treatment of NULL Values" anchor="null-values">
<t>
  If a PROPFIND for a property value would yield a
  non-2xx (see <xref target="RFC2616" x:fmt="of" x:sec="10.2"/>)
  response for that property, then that property is considered NULL.
</t>
<t>
  NULL values are "less than" all other values in comparisons.
</t>
<t>
  Empty strings (zero length strings) are not NULL values. An empty string
  is "less than" a string with length greater than zero.
</t>
<t>
  The DAV:is-defined operator is defined to test if the value
  of a property is not NULL.
</t>
</section>


<section title="Treatment of Properties with Mixed/Element Content" anchor="non-simple-types">
<t>
  Comparisons of properties that do not have simple types (text-only content) is
  out of scope for the standard operators defined for DAV:basicsearch and therefore is defined
  to be UNKNOWN (as per <xref target="three-valued-logic"/>).
  For querying the DAV:resourcetype property, see <xref target="OPERATOR_is-collection"/>.
</t>
</section>

<section title="Example: Testing for Equality">
<t>
  The example shows a single operator (DAV:eq) applied in the criteria.
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;d:where xmlns:d='DAV:'&gt;
  &lt;d:eq&gt;
    &lt;d:prop&gt;
      &lt;d:getcontentlength/&gt;
    &lt;/d:prop&gt;
    &lt;d:literal&gt;100&lt;/d:literal&gt;
  &lt;/d:eq&gt;
&lt;/d:where&gt;</x:parse-xml></artwork></figure>
</section>

<section title="Example: Relative Comparisons">
<t>
  The example shows a more complex operation involving several operators
  (DAV:and, DAV:eq, DAV:gt) applied in the criteria.
  This DAV:where expression matches those resources of type "image/gif"
  over 4K in size.
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;D:where xmlns:D='DAV:'&gt;
  &lt;D:and&gt;
    &lt;D:eq&gt;
      &lt;D:prop&gt;
        &lt;D:getcontenttype/&gt;
      &lt;/D:prop&gt;
      &lt;D:literal&gt;image/gif&lt;/D:literal&gt;
    &lt;/D:eq&gt;
    &lt;D:gt&gt;
      &lt;D:prop&gt;
        &lt;D:getcontentlength/&gt;
      &lt;/D:prop&gt;
      &lt;D:literal&gt;4096&lt;/D:literal&gt;
    &lt;/D:gt&gt;
  &lt;/D:and&gt;
&lt;/D:where&gt;</x:parse-xml></artwork></figure>
</section>
</section>

<section title="DAV:orderby">
<iref item="DAV:orderby" primary="true"/>
<t>
  The DAV:orderby element specifies the ordering of the result set. It contains
  one or more DAV:order elements, each of which specifies a comparison between
  two items in the result set. Informally, a comparison specifies a test that
  determines whether one resource appears before another in the result set.
  Comparisons are applied in the order they occur in the DAV:orderby element,
  earlier comparisons being more significant.
</t>
<t>
  The comparisons defined here use only a single property from each resource,
  compared using the same ordering as the DAV:lt operator
  (ascending<iref item="DAV:ascending" primary="true"/>) or DAV:gt operator
  (descending<iref item="DAV:descending" primary="true"/>).
  If neither direction is specified, the default is DAV:ascending.
</t>
<t>
  In the context of the DAV:orderby element, null values are
  considered to collate before any actual (i.e., non-null) value, including
  strings of zero length (this is compatible with <xref target="SQL99"/>).
</t>
<t>
  <iref item="caseless attribute"/>
  The "caseless" attribute may be used to indicate case-sensitivity
  for comparisons (<xref target="caseless"/>).
</t>



<section title="Example of Sorting">
<t>
  This sort orders first by last name of the author and then by size, in
  descending order, so that for each author, the largest works appear first.
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;d:orderby xmlns:d='DAV:' xmlns:r='http://example.com/ns'&gt;
  &lt;d:order&gt;
    &lt;d:prop&gt;&lt;r:lastname/&gt;&lt;/d:prop&gt;
    &lt;d:ascending/&gt;
  &lt;/d:order&gt;
  &lt;d:order&gt;
    &lt;d:prop&gt;&lt;d:getcontentlength/&gt;&lt;/d:prop&gt;
    &lt;d:descending/&gt;
  &lt;/d:order&gt;
&lt;/d:orderby&gt;</x:parse-xml></artwork></figure>
</section>
</section>


<section title="Boolean Operators: DAV:and, DAV:or, and DAV:not">
<iref item="DAV:and" primary="true"/>
<t>
  The DAV:and operator performs a logical AND operation on the expressions
  it contains.
</t>
<iref item="DAV:or" primary="true"/>
<t>
  The DAV:or operator performs a logical OR operation on the values it contains.
</t>
<iref item="DAV:not" primary="true"/>
<t>
  The DAV:not operator performs a logical NOT operation on the
  values it contains.
</t>
</section>

<section title="DAV:eq">
<iref item="DAV:eq" primary="true"/>
<t>
  The DAV:eq operator provides simple equality matching on property values.
</t>
<iref item="DAV:eq" subitem="caseless attribute"/>
<iref item="caseless attribute"/>
<t>
  The "caseless" attribute may be used with this element (<xref target="caseless"/>).
</t>
</section>

<section title="DAV:lt, DAV:lte, DAV:gt, DAV:gte">

<iref item="DAV:lt" primary="true"/>
<iref item="DAV:lte" primary="true"/>
<iref item="DAV:gt" primary="true"/>
<iref item="DAV:gte" primary="true"/>
<iref item="caseless attribute"/>
<t>
  The DAV:lt, DAV:lte, DAV:gt, and DAV:gte
  operators provide comparisons on property values, using less-than, less-than
  or equal, greater-than, and greater-than or equal, respectively. The "caseless"
  attribute may be used with these elements (<xref target="caseless"/>).
</t>
</section>

<section title="DAV:literal">
<iref item="DAV:literal" primary="true"/>

<t>
  DAV:literal allows literal values to be placed in an expression.
</t>
<t>
  White space in literal values is significant in comparisons. For consistency
  with <xref target="RFC4918"/>, clients <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD NOT</bcp14> specify the attribute "xml:space"
  (<xref target="XML" x:fmt="of" x:sec="2.10" x:rel="#sec-white-space"/>) to override this behavior.
</t>
<t>
  In comparisons, the contents of DAV:literal <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> be treated as string, with
  the following exceptions:
  <list style="symbols">
    <t>when operand for a comparison with a DAV:getcontentlength property,
    it <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> be treated as an unsigned integer value (the behavior for values not in this format
    is undefined),
    </t>
    <t>when operand for a comparison with a DAV:creationdate or DAV:getlastmodified property,
    it <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> be treated as a date value in the ISO-8601 subset defined for
    the DAV:creationdate property (see <xref target="RFC4918" x:fmt="of" x:sec="15.1"/>;
    the behavior of values not in this format is undefined),
    </t>
    <t>when operand for a comparison with a property for which the type is known and when compatible with that type,
    it <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> be treated according to this type.
    </t>
  </list>
</t>
</section>

<section title="DAV:typed-literal (Optional)">
<iref item="DAV:typed-literal" primary="true"/>
<t>
  There are situations in which a client may want to force a comparison not to
  be string-based (as defined for DAV:literal). In these cases, a typed
  comparison can be enforced by using DAV:typed-literal instead.
</t>
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT typed-literal (#PCDATA)&gt;
</artwork></figure>
<t>
  The data type is specified using the xsi:type attribute defined in
  <xref target="XS1" x:fmt="of" x:sec="2.6.1" x:rel="#xsi_type"/>. If the type is not specified, it
  defaults to "xs:string".
</t>
<t>
  A server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> reject a request using an unknown type with a status of 422 (Unprocessable Entity).
  It <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> reject a request if the value provided in DAV:typed-literal cannot be cast to the specified type.
</t>
<t>
  The comparison evaluates to UNKNOWN if the property value cannot be
  cast to the specified datatype (see <xref target="XPATHFUNC" x:fmt="," x:sec="17" x:rel="#casting"/>).
</t>

<section title="Example for Typed Numerical Comparison">
<t>
  Consider a set of resources with the dead property "edits" in the namespace
  "http://ns.example.org":
</t>
<texttable>
  <ttcol>URI</ttcol><ttcol>property value</ttcol>
  <c>/a</c><c>"-1"</c>
  <c>/b</c><c>"01"</c>
  <c>/c</c><c>"3"</c>
  <c>/d</c><c>"test"</c>
  <c>/e</c><c>(undefined)</c>
</texttable>
<t>
  The expression
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;lt xmlns="DAV:"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;prop&gt;&lt;edits xmlns="http://ns.example.org"/&gt;&lt;/prop&gt;
  &lt;typed-literal xsi:type="xs:integer"&gt;3&lt;/typed-literal&gt;
&lt;/lt&gt;
</x:parse-xml></artwork></figure>
<t>
  will evaluate to TRUE for the resources "/a" and "/b" (their property values
  can be parsed as type xs:integer, and the numerical comparison evaluates to
  true), to FALSE for "/c" (property value is compatible, but numerical comparison
  evaluates to false), and UNKNOWN for "/d" and "/e" (the property either is
  undefined, or its value cannot be parsed as xs:integer).
</t>
</section>
</section>





<section title="Support for Matching xml:lang Attributes on Properties">
<t>
  The following two optional operators can be used to express conditions
  on the language of a property value (as expressed using the xml:lang
  attribute).
</t>
<section title="DAV:language-defined (Optional)" anchor="operator.language-defined">
<iref item="DAV:language-defined" primary="true"/>
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT language-defined (prop)&gt;
</artwork></figure>
<t>
  This operator evaluates to TRUE if the language for the value of
  the given property is known, FALSE if it isn't, and UNKNOWN if the property itself
  is not defined.
</t>
</section>

<section title="DAV:language-matches (Optional)" anchor="operator.language-matches">
<iref item="DAV:language-matches" primary="true"/>
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT language-matches (prop, literal)&gt;
</artwork></figure>
<t>
  This operator evaluates to TRUE if the language for the value of the 
  given property is known and matches the language name given in the
  &lt;literal&gt; element, FALSE if it doesn't match, and UNKNOWN
  if the property itself is not defined.
</t>
<t>
  Languages are considered to match if they are the same, or if the
  language of the property value is a sublanguage of the language
  specified in the &lt;literal&gt; element (see <xref target="XPATH" x:fmt="of" x:sec="4.3" x:rel="#function-lang"/>,
  "lang function"). 
</t>
</section>

<section title="Example of Language-Aware Matching">
<t>
  The expression below will evaluate to TRUE if the property "foobar" exists
  and its language is either unknown, English, or a sublanguage of English. 
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;or xmlns="DAV:"&gt;
  &lt;not&gt;
    &lt;language-defined&gt;
      &lt;prop&gt;&lt;foobar/&gt;&lt;/prop&gt;
    &lt;/language-defined&gt;
  &lt;/not&gt;
  &lt;language-matches&gt;
    &lt;prop&gt;&lt;foobar/&gt;&lt;/prop&gt;
    &lt;literal&gt;en&lt;/literal&gt;
  &lt;/language-matches&gt;
&lt;/or&gt;
</x:parse-xml></artwork></figure>
</section>
</section>





<section title="DAV:is-collection" anchor="OPERATOR_is-collection">
<iref item="DAV:is-collection" primary="true"/>
<t>
  The DAV:is-collection operator allows clients to determine whether a resource is
  a collection (that is, whether its DAV:resourcetype element contains the
  element DAV:collection). 
</t>
<t>
  Rationale: This operator is provided in lieu of defining generic
  structure queries, which would suffice for this and for many more powerful
  queries, but seems inappropriate to standardize at this time.
</t>

<section title="Example of DAV:is-collection">
<t>
  This example shows a search criterion that picks out all, and only, the resources
  in the scope that are collections.
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;where xmlns="DAV:"&gt;
  &lt;is-collection/&gt;
&lt;/where&gt;</x:parse-xml></artwork></figure>
</section>
</section>

<section title="DAV:is-defined">
<iref item="DAV:is-defined" primary="true"/>
<t>
  The DAV:is-defined operator allows clients to determine whether
  a property is defined on a resource. The meaning of "defined on a resource"
  is found in <xref target="null-values"/>.
</t>
<figure><preamble>Example:</preamble><artwork type="example" x:lang="">
<x:parse-xml>&lt;d:is-defined xmlns:d='DAV:' xmlns:x='http://example.com/ns'&gt;
  &lt;d:prop&gt;&lt;x:someprop/&gt;&lt;/d:prop&gt;
&lt;/d:is-defined&gt;</x:parse-xml></artwork></figure>
</section>

<section title="DAV:like">
<iref item="DAV:like" primary="true"/>
<t>
  The DAV:like is an optional operator intended to give simple wildcard-based
  pattern matching ability to clients.
</t>
<t>
  The operator takes two arguments.
</t>
<t>
  The first argument is a DAV:prop element identifying a single
  property to evaluate.
</t>
<t>
  The second argument is a DAV:literal element that gives the
  pattern matching string.
</t>

<section title="Syntax for the Literal Pattern">
<figure>

<artwork type="abnf">
pattern       = [wildcard] 0*( text [wildcard] )

wildcard      = exactlyone / zeroormore
text          = 1*( character / escapeseq )

exactlyone    = "_"
zeroormore    = "%"
escapechar    = "\"
escapeseq     = escapechar ( exactlyone / zeroormore / escapechar ) 

; character: see <xref target="XML" x:fmt="," x:sec="2.2" x:rel="#charsets"/>, minus wildcard / escapechar
character     = HTAB / LF / CR ; whitespace
character     =/ %x20-24 / %x26-5B / %x5D-5E / %x60-D7FF
character     =/ %xE000-FFFD / %x10000-10FFFF
</artwork>
<postamble>
  (Note that the ABNF above is defined in terms of Unicode code points (<xref target="UNICODE5"/>);
  when a query is transmitted as an XML document over WebDAV, these characters are
  typically encoded in UTF-8 or UTF-16.)
</postamble>
</figure>
<t>
  The value for the literal is composed of wildcards separated by segments
  of text. Wildcards may begin or end the literal.
</t>
<t>
  The "_" wildcard matches exactly one character.
</t>
<t>
  The "%" wildcard matches zero or more characters.
</t>
<t>
  The "\" character is an escape sequence so that the literal can include
  "_" and "%". To include the "\" character in the pattern, the escape sequence
  "\\" is used.
</t>
</section>

<section title="Example of DAV:like">
<t>
  This example shows how a client might use DAV:like to identify
  those resources whose content type was a subtype of image.
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;D:where xmlns:D='DAV:'&gt;
  &lt;D:like caseless="yes"&gt;
    &lt;D:prop&gt;&lt;D:getcontenttype/&gt;&lt;/D:prop&gt;
    &lt;D:literal&gt;image/%&lt;/D:literal&gt;
  &lt;/D:like&gt;
&lt;/D:where&gt;</x:parse-xml></artwork></figure>
</section>
</section>



<section title="DAV:contains" anchor="contains">
<iref item="DAV:contains" primary="true"/>
<t>
  The DAV:contains operator is an optional operator that provides
  content-based search capability. This operator implicitly searches against
  the text content of a resource, not against the content of properties. The
  DAV:contains operator is intentionally not overly constrained, in order to allow the
  server to do the best job it can in performing the search.
</t>
<t>
  The DAV:contains operator evaluates to a Boolean value. It
  evaluates to TRUE if the content of the resource satisfies the search.
  Otherwise, it evaluates to FALSE.
</t>
<t>
  Within the DAV:contains XML element, the client provides a
  phrase: a single word or whitespace delimited sequence of words. Servers
  <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> ignore punctuation in a phrase. Case-sensitivity is at the
discretion of the server implementation.
</t>
<t>
  
  The following non-exhaustive list enumerates things that may or may not be done
  as part of the search: Phonetic
  methods such as "soundex" may or may not be used. Word stemming may or
  may not be performed. Thesaurus expansion of words may or may not be done.
  Right or left truncation may or may not be performed. The search may be
  case insensitive or case sensitive. The word or words may or may not be
  interpreted as names. Multiple words may or may not be required to be adjacent
  or "near" each other. Multiple words may or may not be required to occur
  in the same order. Multiple words may or may not be treated as a phrase.
  The search may or may not be interpreted as a request to find documents
  "similar" to the string operand.
  Character canonicalization such as that done by the Unicode collation
  algorithm may or may not be applied.
</t>


<section title="Result Scoring (DAV:score Element)" anchor="score">
<iref item="DAV:score" primary="true"/>
<t>
  Servers <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> indicate scores for the DAV:contains condition by adding a
  DAV:score XML element to the DAV:response element. Its value is defined only
  in the context of a particular query result. The value is a string representing
  the score, an integer from zero to 10000 inclusive, where a higher value
  indicates a higher score (e.g., more relevant).
</t>
<figure>
<preamble>Modified DTD fragment for DAV:propstat:</preamble><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT response (href, ((href*, status)|(propstat+)),
                    responsedescription?, score?) &gt;
&lt;!ELEMENT score    (#PCDATA) &gt;
</artwork></figure>
<t>
  Clients should note that, in general, it is not meaningful to compare
  the numeric values of scores from two different query results unless both were
  executed by the same underlying search system on the same collection of
  resources.
</t>
</section>

<section title="Ordering by Score">
<t>
  To order search results by their score, the DAV:score element may be added
  as child to the DAV:orderby element (in place of a DAV:prop element).
</t>
</section>

<section title="Examples">
<t>
  The example below shows a search for the phrase "Peter Forsberg".
</t>
<t>
  Depending on its support for content-based searching, a server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> treat
  this as a search for documents that contain the words "Peter" and "Forsberg".
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;D:where xmlns:D='DAV:'&gt;
  &lt;D:contains&gt;Peter Forsberg&lt;/D:contains&gt;
&lt;/D:where&gt;</x:parse-xml></artwork></figure>
<t>
  The example below shows a search for resources that contain "Peter" and
  "Forsberg".
</t>
<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;D:where xmlns:D='DAV:'&gt;
  &lt;D:and&gt;
    &lt;D:contains&gt;Peter&lt;/D:contains&gt;
    &lt;D:contains&gt;Forsberg&lt;/D:contains&gt;
  &lt;/D:and&gt;
&lt;/D:where&gt;</x:parse-xml></artwork></figure>
</section>
</section>

<section title="Limiting the Result Set" anchor="limiting.the.result.set">
<iref item="DAV:limit" primary="true"/>
<iref item="DAV:nresults" primary="true"/>
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT limit (nresults) &gt;
&lt;!ELEMENT nresults (#PCDATA)&gt; &lt;!-- only digits --&gt;</artwork></figure>
<t>
  The DAV:limit XML element contains requested limits from the client
  to limit the size of the reply or amount of effort expended by the server.
  The DAV:nresults XML element contains a requested maximum number
  of DAV:response elements to be returned in the response body.
  The server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> disregard this limit.  The value of this element is an
  unsigned integer.
</t>

<section title="Relationship to Result Ordering">
<iref item="DAV:score" subitem="relationship to DAV:orderby" primary="true"/>

<t>
  If the result set is both limited by DAV:limit and ordered according to
  DAV:orderby, the results that are included in the response document <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> be
  those that order highest.
</t>
</section>
</section>


<section title="The 'caseless' XML Attribute" anchor="caseless">
<iref item="caseless attribute" primary="true"/>
<t>
  The "caseless" attribute allows clients to specify caseless matching behavior
  instead of character-by-character matching for DAV:basicsearch operators.
</t>
<t>
  The possible values for "caseless" are "yes" or "no". The default value is
  server-specified. Caseless matching <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> be implemented as defined in
  
  <eref target="http://www.unicode.org/versions/Unicode5.0.0/ch05.pdf#G21180">Section 5.18</eref>
  of the Unicode Standard (<xref target="UNICODE5"/>).
</t>
<t>
  Support for the "caseless" attribute is optional. A server should
  respond with a status of 422 if it is used but cannot be supported.
</t>
</section>



<section title="Query Schema for DAV:basicsearch" anchor="qs-basicsearch">
<t>
  The DAV:basicsearch grammar defines a search criteria that is
  a Boolean-valued expression, and allows for an arbitrary set of properties
  to be included in the result record. The result set may be sorted on a
  set of property values. Accordingly, the DTD for schema discovery for this
  grammar allows the server to express:
</t>
<t>
  <list style="numbers">
    <t>the set of properties that may be either searched, returned, or used
    to sort, and a hint about the data type of such properties.</t>
    <t>the set of optional operators defined by the resource.</t>
  </list>
</t>

<section title="DTD for DAV:basicsearch QSD">
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT basicsearchschema  (properties, operators)&gt;
&lt;!ELEMENT any-other-property EMPTY&gt;
&lt;!ELEMENT properties         (propdesc*)&gt;
&lt;!ELEMENT propdesc           ((prop|any-other-property), datatype?,
                              searchable?, selectable?, sortable?,
                              caseless?)&gt;
&lt;!ELEMENT operators          (opdesc*)&gt;
&lt;!ELEMENT opdesc             ANY&gt;
&lt;!ATTLIST opdesc             allow-pcdata (yes|no) #IMPLIED&gt;
&lt;!ELEMENT operand-literal    EMPTY&gt;
&lt;!ELEMENT operand-typed-literal EMPTY&gt;
&lt;!ELEMENT operand-property   EMPTY&gt;
</artwork></figure>
<t>
  The DAV:properties element holds a list of descriptions of properties.
</t>
<t>
  The DAV:operators element describes the optional operators
  that may be used in a DAV:where element.
</t>
</section>

<section title="DAV:propdesc Element">
<t>
  Each instance of a DAV:propdesc element describes the property
  or properties in the DAV:prop element it contains. All subsequent
  elements are descriptions that apply to those properties. All descriptions
  are optional and may appear in any order. Servers <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14> support all the
  descriptions defined here, and <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> define others.
</t>
<t>
  DASL defines five descriptions. The first, DAV:datatype, provides
  a hint about the type of the property value, and may be useful to a user
  interface prompting for a value. The remaining four (DAV:searchable,
  DAV:selectable, DAV:sortable, and DAV:caseless)
  identify portions of the query (DAV:where, DAV:select,
  and DAV:orderby, respectively). If a property has a description
  for a section, then the server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> allow the property to be used in that
  section. These descriptions are optional. If a property does not have such
  a description, or is not described at all, then the server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> still allow
  the property to be used in the corresponding section.
</t>

<section title="DAV:any-other-property">
<t>
  This element can be used in place of DAV:prop to describe properties of
  WebDAV properties not mentioned in any other DAV:prop element. For instance,
  this can be used to indicate that all other properties are searchable and selectable
  without giving details about their types (a typical scenario for dead properties).
</t>
</section>

</section>

<section title="The DAV:datatype Property Description">
<t>
  The DAV:datatype element contains a single XML element that provides
  a hint about the domain of the property, which may be useful to a user
  interface prompting for a value to be used in a query.
  Data types are identified by an element name. Where appropriate, a server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD</bcp14>
  use the simple data types defined in <xref target="XS2"/>.
</t>
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT datatype ANY &gt;</artwork></figure>
<t>
  Examples from <xref target="XS2" x:fmt="," x:sec="3" x:rel="#built-in-datatypes"/>:
</t>

<texttable>
<ttcol>Qualified name</ttcol><ttcol>Example</ttcol>
<c>xs:boolean</c><c>true, false, 1, 0</c>
<c>xs:string</c><c>Foobar</c>
<c>xs:dateTime</c><c>1994-11-05T08:15:5Z</c>
<c>xs:float</c><c>.314159265358979E+1</c>
<c>xs:integer</c><c>-259, 23</c>
</texttable>

<t>
  If the data type of a property is not given, then the data type defaults
  to xs:string.
</t>
</section>

<section title="The DAV:searchable Property Description">
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT searchable EMPTY&gt;</artwork></figure>
<t>
  If this element is present, then the server <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> allow this property to
  appear within a DAV:where element where an operator allows a property.
  Allowing a search does not mean that the property is guaranteed to be defined
  on every resource in the scope, it only indicates the server's willingness
  to check.
</t>
</section>

<section title="The DAV:selectable Property Description">
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT selectable EMPTY&gt;</artwork></figure>
<t>
  This element indicates that the property may appear in the DAV:select
  element.
</t>
</section>

<section title="The DAV:sortable Property Description">
<t>
  This element indicates that the property may appear in the DAV:orderby
  element.
</t>
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT sortable EMPTY&gt;</artwork></figure>
</section>

<section title="The DAV:caseless Property Description">
<t>
  This element only applies to properties whose data type is "xs:string" 
  and derived data types as per the DAV:datatype property description. Its presence indicates
  that comparisons performed for searches, and the comparisons for ordering
  results on the string property will be caseless (the default is
  character by character).
</t>
<figure><artwork type="application/xml-dtd" x:lang="">
&lt;!ELEMENT caseless EMPTY&gt;</artwork></figure>
</section>



<section title="The DAV:operators XML Element">

<t>
  The DAV:operators element describes every optional operator supported
  in a query. (Mandatory operators are not listed since they are mandatory
  and permit no variation in syntax.) All optional operators that are supported
  <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> be listed in the DAV:operators element.
</t>
<t>
  The listing for an operator, contained in an DAV:opdesc element,
  consists of the operator (as an empty element), followed by one
  element for each operand. The operand <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> be either DAV:operand-property,
  DAV:operand-literal, or DAV:operand-typed-literal, which indicate that the
  operand in the corresponding position is a property, a literal value, or
  a typed literal value, respectively.
  If an operator is polymorphic (allows more than one operand syntax) then
  each permitted syntax <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST</bcp14> be listed separately.
</t>
<t>
  The DAV:opdesc element <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MAY</bcp14> have a "allow-pcdata" attribute (defaulting to
  "no"). A value of "yes" indicates that the operator can contain character
  data, as it is the case with DAV:contains (see <xref target="contains"/>).
  Definition of additional operators using this format is <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">NOT RECOMMENDED</bcp14>.
</t>

<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;operators xmlns='DAV:'&gt;
  &lt;opdesc&gt;
    &lt;like/&gt;&lt;operand-property/&gt;&lt;operand-literal/&gt;
  &lt;/opdesc&gt;
&lt;/operators&gt;</x:parse-xml>
</artwork></figure>
</section>

<section title="Example of Query Schema for DAV:basicsearch" anchor="example.qsd.basicsearch">

<figure><artwork type="example" x:lang="">
<x:parse-xml>&lt;D:basicsearchschema xmlns:D="DAV:"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;D:properties&gt;
    &lt;D:propdesc&gt;
      &lt;D:prop&gt;&lt;D:getcontentlength/&gt;&lt;/D:prop&gt;
      &lt;D:datatype&gt;&lt;xs:nonNegativeInteger/&gt;&lt;/D:datatype&gt;
      &lt;D:searchable/&gt;&lt;D:selectable/&gt;&lt;D:sortable/&gt;
    &lt;/D:propdesc&gt;
    &lt;D:propdesc&gt;
      &lt;D:prop&gt;&lt;D:getcontenttype/&gt;&lt;D:displayname/&gt;&lt;/D:prop&gt;
      &lt;D:searchable/&gt;&lt;D:selectable/&gt;&lt;D:sortable/&gt;
    &lt;/D:propdesc&gt;
    &lt;D:propdesc&gt;
      &lt;D:prop&gt;&lt;fstop xmlns="http://ns.example.org"/&gt;&lt;/D:prop&gt;
      &lt;D:selectable/&gt;
    &lt;/D:propdesc&gt;
    &lt;D:propdesc&gt;
      &lt;D:any-other-property/&gt;
      &lt;D:searchable/&gt;&lt;D:selectable/&gt;
    &lt;/D:propdesc&gt;
  &lt;/D:properties&gt;
  &lt;D:operators&gt;
    &lt;D:opdesc&gt;
      &lt;D:like/&gt;&lt;D:operand-property/&gt;&lt;D:operand-literal/&gt;
    &lt;/D:opdesc&gt;
    &lt;D:opdesc allow-pcdata="yes"&gt;
      &lt;D:contains/&gt;
    &lt;/D:opdesc&gt;
  &lt;/D:operators&gt;
&lt;/D:basicsearchschema&gt;</x:parse-xml></artwork></figure>
<t>
  This response lists four properties. The data type of the last three properties
  is not given, so it defaults to xs:string. All are selectable, and the first
  three may be searched. All but the last may be used in a sort. Of the optional
  DAV operators, DAV:contains and DAV:like are supported.
</t>
<x:note><t>
  <x:h>Note:</x:h> The schema discovery defined here does not provide for discovery of
  supported values of the "caseless" attribute. This may require that the reply
  also list the mandatory operators.
</t></x:note>
</section>
</section>
</section>

<section title="Internationalization Considerations">
<t>
  Properties may be language-tagged using the xml:lang attribute (see
  <xref target="RFC4918" x:fmt="," x:sec="4.3"/>). The optional operators
  DAV:language-defined (<xref target="operator.language-defined"/>) 
  and DAV:language-matches (<xref target="operator.language-matches"/>)
  allow the expression of conditions on the language tagging information.
</t>
</section>

<section title="Security Considerations">
<t>
  This section is provided to detail issues concerning security implications
  of which DASL applications need to be aware. All of the security considerations
  of HTTP/1.1 (<xref target="RFC2616"/>
  and WebDAV (<xref target="RFC4918"/>) also apply to DASL. In addition, this section will include
  security risks inherent in the search and retrieval of resource properties
  and content.
</t>
<t>
  A query <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">MUST NOT</bcp14> allow clients to retrieve information that wouldn't have
  been available through the GET or PROPFIND methods in the first place. In
  particular:
  <list style="symbols">
    <t>
      Query constraints on WebDAV properties for which the client does not
      have read access need to be evaluated as if the property did not
      exist (see <xref target="null-values"/>).
    </t>
    <t>
      Query constraints on content (as with DAV:contains, defined in <xref target="contains"/>)
      for which the client does not have read access need to be evaluated as
      if a GET would return a 4xx status code.
    </t>
  </list>  
</t>
<t>
  A server should prepare for denial-of-service attacks. For example a
  client may issue a query for which the result set is expensive to calculate
  or transmit because many resources match or must be evaluated.
</t>

<section title="Implications of XML External Entities">
<t>
  XML supports a facility known as "external entities", defined in
  <xref target="XML" x:fmt="of" x:sec="4.2.2" x:rel="#sec-external-ent"/>, which instruct an XML processor to retrieve and perform
  an inline include of XML located at a particular URI. An external XML entity
  can be used to append or modify the document type declaration (DTD) associated
  with an XML document. An external XML entity can also be used to include
  XML within the content of an XML document. For non-validating XML, such
  as the XML used in this specification, including an external XML entity
  is not required by <xref target="XML"/>. However, <xref target="XML"/> does state that an XML
  processor may, at its discretion, include the external XML entity.
</t>
<t>
  External XML entities have no inherent trustworthiness and are subject
  to all the attacks that are endemic to any HTTP GET request. Furthermore,
  it is possible for an external XML entity to modify the DTD, and hence
  affect the final form of an XML document, in the worst case significantly
  modifying its semantics, or exposing the XML processor to the security
  risks discussed in <xref target="RFC3023"/>. Therefore, implementers must be aware that
  external XML entities should be treated as untrustworthy.
</t>
<t>
  There is also the scalability risk that would accompany a widely deployed
  application that made use of external XML entities. In this situation,
  it is possible that there would be significant numbers of requests for
  one external XML entity, potentially overloading any server that fields
  requests for the resource containing the external XML entity.
</t>
</section>
</section>

<section title="Scalability">
<t>
  Query grammars are identified by URIs. Applications <bcp14 xmlns="http://purl.org/net/xml2rfc/ext">SHOULD NOT</bcp14> attempt
  to retrieve these URIs even if they appear to be retrievable (for example,
  those that begin with "http://").
</t>
</section>

<section title="IANA Considerations">
<t>
  This document uses the namespace defined in <xref target="RFC4918" x:fmt="of" x:sec="21"/> for XML
  elements.
</t>

<section title="HTTP Headers">
<t>
  This document specifies the HTTP header listed below, which has been added to the
  permanent HTTP header registry defined in <xref target="RFC3864"/>.
</t>
<section title="DASL">
<t>
<list style="hanging">
  <t hangText="Header field name:">DASL</t>
  <t hangText="Applicable protocol:">http</t>
  <t hangText="Status:">standard</t>
  <t hangText="Author/Change controller:">IETF</t>
  <t hangText="Specification document:">this specification (<xref target="header.dasl"/>)</t>
</list>
</t>
</section>
</section>

</section>

<section title="Contributors" anchor="contributors">
<t>
  This document is based on prior work on the DASL protocol done by the WebDAV
  DASL working group until the year 2000 -- namely by Alan Babich, Jim Davis,
  Rick Henderson, Dale Lowry, Saveen Reddy, Surendra Reddy,
  and Judith Slein (see <eref target="http://www.webdav.org/dasl/"/> for the
  working group's web site, <eref target="http://purl.org/NET/webdav/dasl-references/reqs"/>
  for a requirements document, and <eref target="http://purl.org/NET/webdav/dasl-references/dasl-protocol-00"/>
  for an early version of the specification).
</t>
</section>

<section title="Acknowledgements" anchor="acknowledgements">
<t>
  This document has benefited from thoughtful discussion by Lisa Dusseault,
  Javier Godoy, 
  Sung Kim, Chris Newman, Elias Sinderson, Martin Wallmer, Keith Wannamaker, Jim Whitehead,
  and Kevin Wiggen.
</t>
</section>
</middle>

<back>
<references title="Normative References">


  <reference anchor="RFC2616">
    <front>
      <title>Hypertext Transfer Protocol -- HTTP/1.1</title>
      <author initials="R." surname="Fielding" fullname="R. Fielding">
        <organization>University of California, Irvine</organization>
        <address><email>fielding@ics.uci.edu</email></address>
      </author>
      <author initials="J." surname="Gettys" fullname="J. Gettys">
        <organization>W3C</organization>
        <address><email>jg@w3.org</email></address>
      </author>
      <author initials="J." surname="Mogul" fullname="J. Mogul">
        <organization>Compaq Computer Corporation</organization>
        <address><email>mogul@wrl.dec.com</email></address>
      </author>
      <author initials="H." surname="Frystyk" fullname="H. Frystyk">
        <organization>MIT Laboratory for Computer Science</organization>
        <address><email>frystyk@w3.org</email></address>
      </author>
      <author initials="L." surname="Masinter" fullname="L. Masinter">
        <organization>Xerox Corporation</organization>
        <address><email>masinter@parc.xerox.com</email></address>
      </author>
      <author initials="P." surname="Leach" fullname="P. Leach">
        <organization>Microsoft Corporation</organization>
        <address><email>paulle@microsoft.com</email></address>
      </author>
      <author initials="T." surname="Berners-Lee" fullname="T. Berners-Lee">
        <organization>W3C</organization>
        <address><email>timbl@w3.org</email></address>
      </author>
      <date month="June" year="1999"/>
    </front>
    <seriesInfo name="RFC" value="2616"/>
  </reference>
  

  <reference anchor="RFC2119">
    <front>
      <title abbrev="RFC Key Words">Key words for use in RFCs to Indicate Requirement Levels</title>
      <author initials="S." surname="Bradner" fullname="Scott Bradner">
        <organization>Harvard University</organization>
        <address><email>sob@harvard.edu</email></address>
      </author>
      <date month="March" year="1997"/>
      <area>General</area>
      <keyword>keyword</keyword>
    </front>
    <seriesInfo name="BCP" value="14"/>
    <seriesInfo name="RFC" value="2119"/>
  </reference>


  <reference anchor="RFC5234">
    <front>
      <title abbrev="ABNF for Syntax Specifications">Augmented BNF for Syntax Specifications: ABNF</title>
      <author initials="D." surname="Crocker" fullname="Dave Crocker" role="editor">
        <organization>Brandenburg InternetWorking</organization>
        <address>
        <postal>
        <street>675 Spruce Dr.</street>
        <city>Sunnyvale</city>
        <region>CA</region>
        <code>94086</code>
        <country>US</country></postal>
        <phone>+1.408.246.8253</phone>
        <email>dcrocker@bbiw.net</email></address>  
      </author>
      <author initials="P." surname="Overell" fullname="Paul Overell">
        <organization>THUS plc.</organization>
        <address>
        <postal>
        <street>1/2 Berkeley Square</street>
        <street>99 Berkely Street</street>
        <city>Glasgow</city>
        <code>G3 7HR</code>
        <country>UK</country></postal>
        <email>paul.overell@thus.net</email></address>
      </author>
      <date month="January" year="2008"/>
    </front>
    <seriesInfo name="STD" value="68"/>
    <seriesInfo name="RFC" value="5234"/>
  </reference>

  <reference anchor="XML" target="http://www.w3.org/TR/2006/REC-xml-20060816">
    <front>
      <title>Extensible Markup Language (XML) 1.0 (Fourth Edition)</title>
      <author initials="T." surname="Bray" fullname="Tim Bray">
        <organization>Textuality and Netscape</organization>
        <address>
          <email>tbray@textuality.com</email>
        </address>
      </author>
      <author initials="J." surname="Paoli" fullname="Jean Paoli">
        <organization>Microsoft</organization>
        <address>
          <email>jeanpa@microsoft.com</email>
        </address>
      </author>
      <author initials="C.M." surname="Sperberg-McQueen" fullname="C. M. Sperberg-McQueen">
        <organization>University of Illinois at Chicago and Text Encoding Initiative</organization>
        <address>
          <email>cmsmcq@uic.edu</email>
        </address>
      </author>
      <author initials="E." surname="Maler" fullname="Eve Maler">
        <organization>Sun Microsystems</organization>
        <address>
          <email>eve.maler@east.sun.com</email>
        </address>
      </author>
      <author initials="F." surname="Yergeau" fullname="Francois Yergeau">
        <address>
          <email>francois@yergeau.com</email>
        </address>
      </author>
      <date day="16" month="August" year="2006"/>
    </front>
    <seriesInfo name="W3C" value="REC-xml-20060816"/>
  </reference>

  <reference anchor="XS1" target="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/">
    <front>
      <title>XML Schema Part 1: Structures</title>
      <author initials="H. S." surname="Thompson" fullname="Henry S. Thompson">
        <organization>University of Edinburgh</organization>
        <address><email>ht@cogsci.ed.ac.uk</email></address>
      </author>
      <author initials="D." surname="Beech" fullname="David Beech">
        <organization>Oracle</organization>
        <address><email>David.Beech@oracle.com</email></address>
      </author>
      <author initials="M." surname="Maloney" fullname="Murray Maloney">
        <organization>(for) Commerce One</organization>
        <address><email>murray@muzmo.com</email></address>
      </author>
      <author initials="N." surname="Mendelsohn" fullname="Noah Mendelsohn">
        <organization>Lotus Development Corporation</organization>
        <address><email>Noah_Mendelsohn@lotus.com</email></address>
      </author>
      <author>
        <organization abbrev="W3C">World Wide Web Consortium</organization>
        <address>
        <postal>
        <street>MIT Laboratory for Computer Science</street>
        <street>545 Technology Square</street>
        <city>Cambridge</city> <region>MA</region> <code>02139</code>
        <country>US</country>
        </postal>
        <phone>+ 1 617 253 2613</phone>
        <facsimile>+ 1 617 258 5999</facsimile>
        <email>timbl@w3.org</email>
        <uri>http://www.w3c.org</uri>
        </address>
      </author>
      <date month="October" year="2004"/>
    </front>
    <seriesInfo name="W3C" value="REC-xmlschema-1-20041028"/>
  </reference>

  <reference anchor="XS2" target="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/">
    <front>
      <title>XML Schema Part 2: Datatypes Second Edition</title>
      <author initials="P. V." surname="Biron" fullname="Paul V. Biron">
        <organization>Kaiser Permanente, for Health Level Seven</organization>
        <address><email>Paul.V.Biron@kp.org</email></address>
      </author>
      <author initials="A." surname="Malhotra" fullname="Ashok Malhotra">
        <organization>Microsoft, formerly of IBM</organization>
        <address><email>ashokma@microsoft.com</email></address>
      </author>
      <author>
        <organization abbrev="W3C">World Wide Web Consortium</organization>
        <address>
        <postal>
        <street>MIT Laboratory for Computer Science</street>
        <street>545 Technology Square</street>
        <city>Cambridge</city> <region>MA</region> <code>02139</code>
        <country>US</country>
        </postal>
        <phone>+ 1 617 253 2613</phone>
        <facsimile>+ 1 617 258 5999</facsimile>
        <email>timbl@w3.org</email>
        <uri>http://www.w3c.org</uri>
        </address>
      </author>
      <date month="October" year="2004"/>
    </front>
    <seriesInfo name="W3C" value="REC-xmlschema-2-20041028"/>
  </reference>


  <reference anchor="RFC4918">
    <front>
      <title>HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)</title>
      <author initials="L." surname="Dusseault" fullname="Lisa Dusseault" role="editor">
        <organization>CommerceNet</organization>
        <address>
          <postal>
            <street>2064 Edgewood Dr.</street>
            <city>Palo Alto</city> <region>CA</region> <code>94303</code>
            <country>US</country>
          </postal>
          <email>ldusseault@commerce.net</email>
        </address>
      </author>
      <date month="June" year="2007"/>
    </front>
    <seriesInfo name="RFC" value="4918"/>
  </reference>


  <reference anchor="RFC3253">
    <front>
      <title>Versioning Extensions to WebDAV (Web Distributed Authoring and Versioning)</title>
      <author initials="G." surname="Clemm" fullname="G. Clemm">
        <organization>Rational Software</organization>
        <address><email>geoffrey.clemm@rational.com</email></address>
      </author>
      <author initials="J." surname="Amsden" fullname="J. Amsden">
        <organization>IBM</organization>
        <address><email>jamsden@us.ibm.com</email></address>
      </author>
      <author initials="T." surname="Ellison" fullname="T. Ellison">
        <organization>IBM</organization>
        <address><email>tim_ellison@uk.ibm.com</email></address>
      </author>
      <author initials="C." surname="Kaler" fullname="C. Kaler">
        <organization>Microsoft</organization>
        <address><email>ckaler@microsoft.com</email></address>
      </author>
      <author initials="J." surname="Whitehead" fullname="J. Whitehead">
        <organization>UC Santa Cruz, Dept. of Computer Science</organization>
        <address><email>ejw@cse.ucsc.edu</email></address>
      </author>
      <date month="March" year="2002"/>
    </front>
    <seriesInfo name="RFC" value="3253"/>
  </reference>



  <reference anchor="RFC3023">
    <front>
      <title>XML Media Types</title>
      <author initials="M." surname="Murata" fullname="Murata Makoto">
        <organization>IBM Tokyo Research Laboratory</organization>
        <address><email>mmurata@trl.ibm.co.jp</email></address>
      </author>
      <author initials="S." surname="St. Laurent" fullname="Simon St.Laurent">
        <organization>simonstl.com</organization>
        <address><email>simonstl@simonstl.com</email></address>
      </author>
      <author initials="D." surname="Kohn" fullname="Dan Kohn">
        <organization>Skymoon Ventures</organization>
        <address><email>dan@dankohn.com</email></address>
      </author>
      <date month="January" year="2001"/>
    </front>
    <seriesInfo name="RFC" value="3023"/>
  </reference>


  <reference anchor="RFC3744">
    <front>
      <title abbrev="WebDAV Access Control Protocol">Web Distributed Authoring and Versioning (WebDAV) Access Control Protocol</title>
      <author initials="G." surname="Clemm" fullname="Geoffrey Clemm">
        <organization>IBM</organization>
        <address>
          <postal>
            <street>20 Maguire Road</street>
            <city>Lexington</city>
            <region>MA</region>
            <code>02421</code>
          </postal>
          <email>geoffrey.clemm@us.ibm.com</email>
        </address>
      </author>
      <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke">
        <organization abbrev="greenbytes">greenbytes GmbH</organization>
        <address>
          <postal>
            <street>Salzmannstrasse 152</street>
            <city>Muenster</city><region>NW</region><code>48159</code>
            <country>Germany</country>
          </postal>
          <email>julian.reschke@greenbytes.de</email>
        </address>
      </author>
      <author initials="E." surname="Sedlar" fullname="Eric Sedlar">
        <organization>Oracle Corporation</organization>
        <address>
          <postal>
            <street>500 Oracle Parkway</street>
            <city>Redwood Shores</city>
            <region>CA</region>
            <code>94065</code>
          </postal>
          <email>eric.sedlar@oracle.com</email>
        </address>
      </author>
      <author initials="J." surname="Whitehead" fullname="Jim Whitehead">
        <organization abbrev="U.C. Santa Cruz">U.C. Santa Cruz, Dept. of Computer Science</organization>
        <address>
          <postal>
            <street>1156 High Street</street>
            <city>Santa Cruz</city>
            <region>CA</region>
            <code>95064</code>
          </postal>
          <email>ejw@cse.ucsc.edu</email>
        </address>
      </author>
      <date month="May" year="2004"/>
    </front>
    <seriesInfo name="RFC" value="3744"/>
  </reference>



  <reference anchor="XPATH" target="http://www.w3.org/TR/1999/REC-xpath-19991116">
    <front>
      <title>XML Path Language (XPath) Version 1.0</title>
      <author initials="J." surname="Clark" fullname="James Clark">
        <address><email>jjc@jclark.com</email></address>
      </author>
      <author initials="S." surname="DeRose" fullname="Steven DeRose">
        <organization>Inso Corp. and Brown University</organization>
        <address><email>Steven_DeRose@Brown.edu</email></address>
      </author>
      <date month="November" day="16" year="1999"/>
    </front>
    <seriesInfo name="W3C" value="REC-xpath-19991116"/>
  </reference>


  <reference anchor="XPATHFUNC" target="http://www.w3.org/TR/2007/REC-xpath-functions-20070123/">
    <front>
      <title>XQuery 1.0 and XPath 2.0 Functions and Operators</title>
      <author initials="A." surname="Malhotra" fullname="Ashok Malhotra">
        <organization>Oracle Corporation</organization>
        <address><email>ashok.malhotra@alum.mit.edu</email></address>
      </author>
      <author initials="J." surname="Melton" fullname="Jim Melton">
        <organization>Oracle Corporation</organization>
        <address><email>jim.melton@acm.org</email></address>
      </author>
      <author initials="N." surname="Walsh" fullname="Norman Walsh">
        <organization>Sun Microsystems</organization>
        <address><email>Norman.Walsh@Sun.COM</email></address>
      </author>
      <date month="January" day="23" year="2007"/>
    </front>
    <seriesInfo name="W3C" value="REC-xpath-functions-20070123"/>
  </reference>
  
<reference anchor="RFC3986">

<front>
<title abbrev="URI Generic Syntax">Uniform Resource Identifier (URI): Generic Syntax</title>
<author initials="T." surname="Berners-Lee" fullname="Tim Berners-Lee">
<organization abbrev="W3C/MIT">World Wide Web Consortium</organization>
<address>
<postal>
<street>Massachusetts Institute of Technology</street>
<street>77 Massachusetts Avenue</street>
<city>Cambridge</city>

<region>MA</region>
<code>02139</code>
<country>USA</country></postal>
<phone>+1-617-253-5702</phone>
<facsimile>+1-617-258-5999</facsimile>
<email>timbl@w3.org</email>
<uri>http://www.w3.org/People/Berners-Lee/</uri></address></author>
<author initials="R." surname="Fielding" fullname="Roy T. Fielding">
<organization abbrev="Day Software">Day Software</organization>

<address>
<postal>
<street>5251 California Ave., Suite 110</street>
<city>Irvine</city>
<region>CA</region>
<code>92617</code>
<country>USA</country></postal>
<phone>+1-949-679-2960</phone>
<facsimile>+1-949-679-2972</facsimile>
<email>fielding@gbiv.com</email>

<uri>http://roy.gbiv.com/</uri></address></author>
<author initials="L." surname="Masinter" fullname="Larry Masinter">
<organization abbrev="Adobe Systems">Adobe Systems Incorporated</organization>
<address>
<postal>
<street>345 Park Ave</street>
<city>San Jose</city>
<region>CA</region>
<code>95110</code>
<country>USA</country></postal>

<phone>+1-408-536-3024</phone>
<email>LMM@acm.org</email>
<uri>http://larry.masinter.net/</uri></address></author>
<date year="2005" month="January"/>
</front>
<seriesInfo name="STD" value="66"/>
<seriesInfo name="RFC" value="3986"/>
</reference>

</references>

<references title="Informative References">

<reference anchor="SQL99">
<front>
<title>Database Language SQL Part 2: Foundation (SQL/Foundation)</title>
<author initials="J." surname="Milton" fullname="J. Milton">
<organization>International Organization for Standardization</organization>
</author>
<date month="July" year="1999"/>
</front>
<seriesInfo name="ISO" value="ISO/IEC 9075-2:1999 (E)"/>
</reference>

<reference anchor="UNICODE5" target="http://www.unicode.org/versions/Unicode5.0.0/">
  <front>
    <title>The Unicode Standard - Version 5.0</title>
    <author>
      <organization>The Unicode Consortium</organization>
    </author>
    <date month="November" year="2006"/>
  </front>
  <seriesInfo name="Addison-Wesley" value=""/>
  <annotation><eref target="urn:isbn:0321480910">ISBN 0321480910</eref></annotation>
</reference>



<reference anchor="WEBDAV-BIND">
  <front>
    <title>Binding Extensions to Web Distributed Authoring and Versioning (WebDAV)</title>
    
    <author initials="G." surname="Clemm" fullname="Geoffrey Clemm">
      <organization>IBM</organization>
      <address>
        <email>geoffrey.clemm@us.ibm.com</email>
      </address>
    </author>
    <author initials="J." surname="Crawford" fullname="Jason Crawford">
      <organization>IBM Research</organization>
      <address>
        <email>ccjason@us.ibm.com</email>
      </address>
    </author>
  	<author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
  		<organization abbrev="greenbytes">greenbytes GmbH</organization>
      <address>
  		  <email>julian.reschke@greenbytes.de</email>	
  		</address>
  	</author>
    <author initials="J." surname="Whitehead" fullname="Jim Whitehead">
      <organization abbrev="U.C. Santa Cruz">UC Santa Cruz, Dept. of Computer Science</organization>
      <address>
        <email>ejw@cse.ucsc.edu</email>
      </address>
    </author>

    <date month="October" year="2008"/>        
  </front>
</reference>



<reference anchor="RFC3864">
  <front>
    <title>Registration Procedures for Message Header Fields</title>
    <author initials="G." surname="Klyne" fullname="G. Klyne"/>
    <author initials="M." surname="Nottingham" fullname="M. Nottingham"/>
    <author initials="J." surname="Mogul" fullname="J. Mogul"/>
    <date year="2004" month="September"/>
  </front>
  <seriesInfo name="BCP" value="90"/>
  <seriesInfo name="RFC" value="3864"/>
</reference>


  <reference anchor="RFC4790">
    <front>
      <title>Internet Application Protocol Collation Registry</title>
      <author initials="C." surname="Newman" fullname="Chris Newman">
        <organization>Sun Microsystems</organization>
        <address>
          <email>chris.newman@sun.com</email>
        </address>
      </author>
      <author initials="M." surname="Duerst" fullname="Martin Duerst">
        <organization abbrev="AGU">Aoyama Gakuin University</organization>
        <address>
          <email>duerst@it.aoyama.ac.jp</email>
        </address>
      </author>
      <author initials="A." surname="Gulbrandsen" fullname="A. Gulbrandsen">
        <organization abbrev="Oryx">Oryx Mail Systems GmbH</organization>
        <address>
          <email>arnt@oryx.com</email>
        </address>
      </author>
      <date month="March" year="2007"/>
    </front>
    <seriesInfo name="RFC" value="4790"/>
  </reference>


  <reference anchor="BCP47">
    <front>
      <title>Matching of Language Tags</title>
      <author initials="A." surname="Phillips" fullname="A. Phillips">
        <organization>Yahoo! Inc.</organization>
      </author>
      <author initials="M." surname="Davis" fullname="M. Davis">
      <organization>Google</organization>
        </author>
      <date year="2006" month="September"/>
    </front>
    <seriesInfo name="BCP" value="47"/>
    <seriesInfo name="RFC" value="4647"/>
  </reference>


  <reference anchor="RFC4437">
    <front>
      <title abbrev="WebDAV Redirect Reference Resources">Web Distributed Authoring and Versioning (WebDAV) Redirect Reference Resources</title>
      <author initials="J." surname="Whitehead" fullname="Jim Whitehead">
        <organization abbrev="U.C. Santa Cruz">UC Santa Cruz, Dept. of Computer Science</organization>
        <address>
          <postal>
            <street>1156 High Street</street>
            <city>Santa Cruz</city>
            <region>CA</region>
            <code>95064</code>
            <country>US</country>
          </postal>
          <email>ejw@cse.ucsc.edu</email>
        </address>
      </author>
      <author initials="G." surname="Clemm" fullname="Geoff Clemm">
        <organization>IBM</organization>
        <address>
          <postal>
            <street>20 Maguire Road</street>
            <city>Lexington</city><region>MA</region><code>02421</code>
            <country>US</country>
          </postal>
          <email>geoffrey.clemm@us.ibm.com</email>
        </address>
      </author>
      <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
        <organization abbrev="greenbytes">greenbytes GmbH</organization>
        <address>
          <postal>
            <street>Hafenweg 16</street>
            <city>Muenster</city><region>NW</region><code>48155</code>
            <country>Germany</country>
          </postal>
          <phone>+49 251 2807760</phone>
          <facsimile>+49 251 2807761</facsimile>
         <email>julian.reschke@greenbytes.de</email>
          <uri>http://greenbytes.de/tech/webdav/</uri>
        </address>
      </author>
      <date month="March" year="2006"/>
    </front>
    <seriesInfo name="RFC" value="4437"/>
  </reference>

</references>

<section title="Three-Valued Logic in DAV:basicsearch" anchor="three-valued-logic">
<t>
  ANSI standard three-valued logic is used when evaluating the search condition
  (as defined in the ANSI standard SQL specifications, for example, in ANSI
  X3.135-1992, Section 8.12, pp. 188-189, Section 8.2, p. 169, General Rule
  1)a), etc.).
</t>
<t>
  ANSI standard three-valued logic is undoubtedly the most widely practiced
  method of dealing with the issues of properties in the search condition
  not having a value (e.g., being null or not defined) for the resource under
  scan, and with undefined expressions in the search condition (e.g., division
  by zero, etc.). Three valued logic works as follows.
</t>
<t>
  Undefined expressions are expressions for which the value of the expression
  is not defined. Undefined expressions are a completely separate concept
  from the truth value UNKNOWN, which is, in fact, well defined. Property
  names and literal constants are considered expressions for purposes of
  this section. If a property in the current resource under scan has not
  been set to a value, then
  the value of that property is undefined for the resource under scan. DASL
  1.0 has no arithmetic division operator, but if it did, division by zero
  would be an undefined arithmetic expression.
</t>
<t>
  If any subpart of an arithmetic, string, or datetime subexpression is
  undefined, the whole arithmetic, string, or datetime subexpression is undefined.
</t>
<t>
  There are no manifest constants to explicitly represent undefined number,
  string, or datetime values.
</t>
<t>
  Since a Boolean value is ultimately returned by the search condition,
  arithmetic, string, and datetime expressions are always arguments to other
  operators. Examples of operators that convert arithmetic, string, and datetime
  expressions to Boolean values are the six relational operators ("greater
  than", "less than", "equals", etc.). If either or both operands of a relational
  operator have undefined values, then the relational operator evaluates
  to UNKNOWN. Otherwise, the relational operator evaluates to TRUE or FALSE,
  depending upon the outcome of the comparison.
</t>
<t>
  The Boolean operators DAV:and, DAV:or, and DAV:not
  are evaluated according to the following rules:
</t>
<t>
  not UNKNOWN = UNKNOWN
</t>
<t>
  UNKNOWN and TRUE = UNKNOWN
</t>
<t>
  UNKNOWN and FALSE = FALSE
</t>
<t>
  UNKNOWN and UNKNOWN = UNKNOWN
</t>
<t>
  UNKNOWN or TRUE = TRUE
</t>
<t>
  UNKNOWN or FALSE = UNKNOWN
</t>
<t>
  UNKNOWN or UNKNOWN = UNKNOWN
</t>
</section>


<section title="Candidates for Future Protocol Extensions" anchor="future.protocol.extensions">
  <t>
    This section summarizes issues that have been raised during the development
    of this specification, but for which no resolution could be found with the
    constraints in place. Future revisions of this specification should revisit
    these issues, though.
  </t>


<section title="Collation Support" anchor="extensions.collations">
  <t>
    Matching and sorting of textual data relies on collations. With respect
    to WebDAV SEARCH, a combination of various design approaches could be used:
    <list style="symbols">
      <t>
        Require server support for specific collations.
      </t>
      <t>
        Require that the server can advertise which collations it supports.
      </t>
      <t>
        Allow a client to select the collation to be used.
      </t>
    </list>
  </t>
  <t>
    In practice, the current implementations of WebDAV SEARCH usually rely
    on backends they do not control, and for which collation information may
    not be available. To make things worse, implementations of the DAV:basicsearch grammar
    frequently need to combine data from multiple underlying stores (such as
    properties and full text content), and thus collation support may vary based
    on the operator or property.
  </t>
  <t>
    Another open issue is what collation formalism to support. At the time of
    this writing, the two specifications below seem to provide the
    necessary framework and thus may be the base for future work on collation
    support in WebDAV SEARCH:
    <list style="numbers">
      <t>
        "Internet Application Protocol Collation Registry" (<xref target="RFC4790"/>). 
      </t>
      <t>
        "XQuery 1.0 and XPath 2.0 Functions and Operators" (<xref target="XPATHFUNC" x:fmt="," x:sec="7.3.1" x:rel="#collations"/>). 
      </t>
    </list>
  </t>
</section>

<section title="Count" anchor="extensions.count">
<t>
  DAV:basicsearch does not allow a request that returns the count of matching
  resources.
</t>
<t>
  A protocol extension would need to extend DAV:select, and also modify the
  DAV:multistatus response format.
</t>
</section>


<section title="Diagnostics for Unsupported Queries" anchor="extensions.diagnostics">
<t>
  There are many reasons why a given query may not be supported by a server.
  Query Schema Discovery (<xref target="QSD"/>) can be used to discover some
  constraints, but not all.
</t>
<t>
  Future revisions should consider the introduction of specific condition
  codes (<xref target="RFC4918" x:fmt="," x:sec="16"/>) to these situations.
</t>
</section>



<section title="Language Matching" anchor="extensions.language.matching">
<t>
  <xref target="operator.language-matches"/> defines language matching in
  terms of the XPath "lang" function (<xref target="XPATH" x:fmt="," x:sec="4.3" x:rel="#function-lang"/>).
  Future revisions should consider building on <xref target="BCP47"/> instead.
</t>
</section>


<section title="Matching Media Types" anchor="extensions.mediatype-match">
<t>
  Matching media types using the DAV:getcontenttype property and the DAV:like
  operator is hard due to DAV:getcontenttype also allowing parameters.
  A new operator specifically designed for the purpose of matching media types
  probably would simplify things a lot. See <eref target="http://lists.w3.org/Archives/Public/www-webdav-dasl/2003OctDec/0109.html"/>
  for a specific proposal.
</t>
</section>



<section title="Query by Name" anchor="extensions.query-by-name">
<t>
  DAV:basicsearch operates on the properties (and optionally the contents)
  of resources, and thus doesn't really allow matching on parts of the
  resource's URI. See <eref target="http://lists.w3.org/Archives/Public/www-webdav-dasl/2003OctDec/0100.html"/>
  for a proposed extension covering this use case.
</t>
</section>


<section title="Result Paging" anchor="extensions.result-paging">
<t>
  A frequently discussed feature is the ability to specifically request
  the "next" set of results, when either the server decided to truncate
  the result, or the client explicitly asked for a limited set (for
  instance, using the DAV:limit element defined in <xref target="limiting.the.result.set"/>).
</t>
<t>
  In this case, it would be desirable if the server could keep the full
  query result, and provide a new URI identifying a separate result resource,
  allowing the client to retrieve additional data through GET requests,
  and remove the result through a DELETE request.
</t>
</section>


<section title="Search Scope Discovery" anchor="extensions.search.scope.discovery">
<t>
  Given a Search Arbiter resource, there's currently no way to discover
  programmatically the supported sets of search scopes. Future revisions
  of this specification could specify a scope discovery mechanism, similar
  to the Query Schema Discovery defined in <xref target="QSD"/>. 
</t>
</section>



</section>




</back></rfc>