<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>18445</bug_id>
          
          <creation_ts>2012-07-31 07:46:40 +0000</creation_ts>
          <short_desc>[XQ31ReqUC] New functions for 3.1</short_desc>
          <delta_ts>2014-05-20 17:03:24 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Requirements for Future Versions</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Jim Melton">jim.melton</assigned_to>
          <cc>jim.melton</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>71697</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-07-31 07:46:40 +0000</bug_when>
    <thetext>Here are some proposals for new functions in XPath 3.1.

fn:sort($seq, $function, [$collation])

sorts the items in the sequence $seq by applying $function to each one to compute a sort key; if specified, the resulting sort keys are compared using $collation. 

Justification: XPath currently has no sorting capability, this will fill the gap. In addition, XQuery sorting capability is sometimes cumbersome and inflexible, for example collations cannot be selected dynamically.

fn:index-where($seq, $function)

returns the index positions of items in $seq where $function returns true. Equivalent to

for $item at $pos in $seq where $function($item) return $pos

Justification: more flexible than index-of, less cumbersome than the equivalent FLWOR expression, available in XPath as well as XQuery. Example: to find all the paragraphs before the first h1 element, use subsequence(1, index-where(*, function($p){$p[self::h1]})[1]-1).

fn:highest($seq, $function, [$collation])
fn:lowest($seq, $function, [$collation])

returns the items in $seq having a higher/lower value for $function than any other items in the sequence. For example, fn:highest(emp, function($e){number($e/salary)}) returns the highest paid employees. The function results are compared using $collation if specified

Justification: using min() and max() for this common task is cumbersome and inefficient; using sorting is not much better. Writing a recursive function is too difficult for many users.

fn:collation($language, $flags)

returns an (implementation-dependent) collation URI suitable for sorting strings in a given language, parameterized by a set of flags. Flags might include i=case-blind, a=accent-blind, p=ignore punctuation, w=multi-word sorting, n=smart numerics, etc. The resulting collation URI is implementation-dependent and the effect of using the returned collation is also implementation-dependent.

Justification: gives an interoperable way of requesting a collation with desired characteristics, even though the results of using this collation might not be 100% interoperable. 

(An alternative which has also been suggested is to standardize a collation URI syntax using query parameters. A problem with using a function is that XQuery &quot;order by&quot; currently requires a statically-known collation URI. But the function would serve the needs of XPath and XSLT well.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106489</commentid>
    <comment_count>1</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-05-20 17:03:24 +0000</bug_when>
    <thetext>Assigning to future requirements per Working Group decision (https://lists.w3.org/Archives/Member/w3c-xsl-query/2012Oct/0087.html).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>