← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/fix_bug_1182910 into lp:zorba

 

Sorin Marian Nasoi has proposed merging lp:~zorba-coders/zorba/fix_bug_1182910 into lp:zorba.

Commit message:
- partial fix for lp:1182910: updated function names from fn:map and fn:map-pairs to fn:for-each and fn:for-each-pair
- updated order of params for functions: fn:for-each, fn:for-each-pair, fn:filter, fn:fold-right, fn:fold-left
- updated XQuery 3.0 F&O spec for test xquery_30

Requested reviews:
  Sorin Marian Nasoi (sorin.marian.nasoi)
Related bugs:
  Bug #1182910 in Zorba: "changes in XQuery F&O 3.0 spec: fn:map, fn:map-pairs, fn:filter, fn:fold-left, and fn:fold-right"
  https://bugs.launchpad.net/zorba/+bug/1182910

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix_bug_1182910/+merge/167369
-- 
The attached diff has been truncated due to its size.
https://code.launchpad.net/~zorba-coders/zorba/fix_bug_1182910/+merge/167369
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'modules/w3c/xpath_functions.xq'
--- modules/w3c/xpath_functions.xq	2013-03-04 16:17:30 +0000
+++ modules/w3c/xpath_functions.xq	2013-06-04 18:53:34 +0000
@@ -259,7 +259,7 @@
 (:~
  : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-filter";>fn:filter</a>
  :)
-declare function fn:filter($f as function(item()) as xs:boolean, $seq as item()*) as item()* external;
+declare function fn:filter($seq as item()*, $f as function(item()) as xs:boolean) as item()* external;
 
 (:~
  : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-floor";>fn:floor</a>
@@ -269,12 +269,12 @@
 (:~
  : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-fold-left";>fn:fold-left</a>
  :)
-declare function fn:fold-left( $f as function(item()*, item()) as item()*, $zero as item()*, $seq as item()*) as item()* external;
+declare function fn:fold-left($seq as item()*, $zero as item()*, $f as function(item()*, item()) as item()*) as item()* external;
 
 (:~
  : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-fold-right";>fn:fold-right</a>
  :)
-declare function fn:fold-right( $f as function(item(), item()*) as item()*, $zero as item()*, $seq as item()*) as item()* external;
+declare function fn:fold-right($seq as item()*, $zero as item()*, $f as function(item(), item()*) as item()*) as item()* external;
 
 (:~
  : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-format-date";>fn:format-date</a>
@@ -407,14 +407,14 @@
 declare function fn:lower-case($arg as xs:string?) as xs:string external;
 
 (:~
- : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-map";>fn:map</a>
+ : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-for-each";>fn:for-each</a>
  :)
-declare function fn:map($f as function(item()) as item()*, $seq as item()*) as item()* external;
+declare function fn:for-each( $seq as item()*, $f as function(item()) as item()*) as item()* external;
 
 (:~
- : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-map-pairs";>fn:map-pairs</a>
+ : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-for-each-pair";>fn:for-each-pair</a>
  :)
-declare function fn:map-pairs( $f as function(item(), item()) as item()*, $seq1 as item()*, $seq2 as item()*) as item()* external;
+declare function fn:for-each-pair( $seq1 as item()*, $seq2 as item()*, $f as function(item(), item()) as item()*) as item()* external;
 
 (:~
  : @see for semantics please check <a href="http://www.w3.org/TR/xpath-functions-30/#func-matches";>fn:matches</a>

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2013-05-31 17:56:26 +0000
+++ src/compiler/translator/translator.cpp	2013-06-04 18:53:34 +0000
@@ -12168,27 +12168,27 @@
                               arguments[2]);
     break;
   }
-  case FunctionConsts::FN_MAP_2:
+  case FunctionConsts::FN_FOR_EACH_2:
   {
-    //  map(function, sequence) is rewritten internally as:
+    //  fn:for-each(sequence, function) is rewritten internally as:
     //
     //  for $item in $sequence
-    //  return dynamic_function_invocation[ $function, $item ]
-    
-    arguments[0] = normalize_fo_arg(0, arguments[0], f, loc);
+    //  return dynamic_function_invocation[ $item, $function ]
+
+    arguments[1] = normalize_fo_arg(0, arguments[1], f, loc);
 
     flwor_expr* flwor = CREATE(flwor)(theRootSctx, theUDF, loc);
-    for_clause* seq_fc = wrap_in_forclause(arguments[1], false);
+    for_clause* seq_fc = wrap_in_forclause(arguments[0], false);
     flwor->add_clause(seq_fc);
-    
+
     std::vector<expr*> fncall_args;
     fncall_args.push_back(CREATE(wrapper)(theRootSctx, theUDF, loc, seq_fc->get_var()));
 
     expr* dynamic_fncall = 
     CREATE(dynamic_function_invocation)(theRootSctx, theUDF, loc,
-                                        arguments[0],
+                                        arguments[1],
                                         fncall_args);
-    
+
     flwor->set_return_expr(dynamic_fncall);
 
     resultExpr = flwor;
@@ -12200,22 +12200,22 @@
     //
     //  for $item in $sequence
     //  return
-    //    if (dynamic_function_invocation[ $function, $item])
+    //    if (dynamic_function_invocation[ $item, $function ])
     //    then $item
     //    else ()
-    
-    arguments[0] = normalize_fo_arg(0, arguments[0], f, loc);
+
+    arguments[1] = normalize_fo_arg(0, arguments[1], f, loc);
 
     flwor_expr* flwor = CREATE(flwor)(theRootSctx, theUDF, loc);
-    for_clause* seq_fc = wrap_in_forclause(arguments[1], true);
+    for_clause* seq_fc = wrap_in_forclause(arguments[0], true);
     flwor->add_clause(seq_fc);
-    
+
     std::vector<expr*> fncall_args;
     fncall_args.push_back(CREATE(wrapper)(theRootSctx, theUDF, loc, seq_fc->get_var()));
-    
+
     expr* dynamic_fncall =
     CREATE(dynamic_function_invocation)(theRootSctx, theUDF, loc,
-                                        arguments[0],
+                                        arguments[1],
                                         fncall_args);
 
     expr* if_expr = 
@@ -12223,7 +12223,7 @@
                dynamic_fncall,
                CREATE(wrapper)(theRootSctx, theUDF, loc, seq_fc->get_var()),
                create_empty_seq(loc));
-      
+
     flwor->set_return_expr(if_expr);
 
     resultExpr = flwor;
@@ -12647,7 +12647,7 @@
 
         break;
       }
-      case FunctionConsts::FN_MAP_2:
+      case FunctionConsts::FN_FOR_EACH_2:
       case FunctionConsts::FN_FILTER_2:
       {
         flwor_expr* flworBody = CREATE(flwor)(theRootSctx, theUDF, loc);

=== modified file 'src/functions/func_fn_hof_functions_impl.cpp'
--- src/functions/func_fn_hof_functions_impl.cpp	2013-04-10 21:01:35 +0000
+++ src/functions/func_fn_hof_functions_impl.cpp	2013-06-04 18:53:34 +0000
@@ -33,10 +33,10 @@
 /*******************************************************************************
 
 ********************************************************************************/
-class fn_map_3_0 : public function
+class fn_for_each_3_0 : public function
 {
 public:
-  fn_map_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
+  fn_for_each_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
     :
     function(sig, kind)
   {
@@ -153,12 +153,12 @@
                    TypeConstants::QUANT_ONE);
 
     DECL_WITH_KIND(sctx,
-                   fn_map_3_0,
-                   (createQName(static_context::W3C_FN_NS, "", "map"),
+                   fn_for_each_3_0,
+                   (createQName(static_context::W3C_FN_NS, "", "for-each"),
+                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    hofParamType,
-                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    GENV_TYPESYSTEM.ITEM_TYPE_STAR),
-                   FunctionConsts::FN_MAP_2);
+                   FunctionConsts::FN_FOR_EACH_2);
   }
 
   {
@@ -173,8 +173,8 @@
     DECL_WITH_KIND(sctx,
                    fn_filter,
                    (createQName(static_context::W3C_FN_NS, "", "filter"),
+                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    hofParamType,
-                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    GENV_TYPESYSTEM.ITEM_TYPE_STAR),
                    FunctionConsts::FN_FILTER_2);
   }
@@ -190,13 +190,13 @@
                    TypeConstants::QUANT_ONE);
 
     DECL_WITH_KIND(sctx,
-                   fn_map_pairs_3_0,
-                   (createQName(static_context::W3C_FN_NS, "", "map-pairs"),
+                   fn_for_each_pair_3_0,
+                   (createQName(static_context::W3C_FN_NS, "", "for-each-pair"),
+                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    hofParamType,
-                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
-                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    GENV_TYPESYSTEM.ITEM_TYPE_STAR),
-                   FunctionConsts::FN_MAP_PAIRS_3);
+                   FunctionConsts::FN_FOR_EACH_PAIR_3);
   }
 
   {
@@ -213,9 +213,9 @@
     DECL_WITH_KIND(sctx,
                    fn_fold_left_3_0,
                    (createQName(static_context::W3C_FN_NS, "", "fold-left"),
+                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    hofParamType,
-                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
-                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    GENV_TYPESYSTEM.ITEM_TYPE_STAR),
                    FunctionConsts::FN_FOLD_LEFT_3);
     
@@ -230,9 +230,9 @@
     DECL_WITH_KIND(sctx,
                    fn_fold_right_3_0,
                    (createQName(static_context::W3C_FN_NS, "", "fold-right"),
+                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
+                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    hofParamType,
-                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
-                   GENV_TYPESYSTEM.ITEM_TYPE_STAR,
                    GENV_TYPESYSTEM.ITEM_TYPE_STAR),
                    FunctionConsts::FN_FOLD_RIGHT_3);
   }

=== modified file 'src/functions/function_consts.h'
--- src/functions/function_consts.h	2013-05-03 14:31:19 +0000
+++ src/functions/function_consts.h	2013-06-04 18:53:34 +0000
@@ -80,7 +80,7 @@
   FN_NAME_0,
   FN_NAME_1,
 
-  FN_MAP_2,
+  FN_FOR_EACH_2,
   FN_FILTER_2,
 
   OP_EXACTLY_ONE_NORAISE_1,

=== modified file 'src/functions/pregenerated/func_fn_hof_functions.cpp'
--- src/functions/pregenerated/func_fn_hof_functions.cpp	2013-04-10 21:01:35 +0000
+++ src/functions/pregenerated/func_fn_hof_functions.cpp	2013-06-04 18:53:34 +0000
@@ -53,14 +53,14 @@
   return new FunctionArityIterator(sctx, loc, argv);
 }
 
-PlanIter_t fn_map_pairs_3_0::codegen(
+PlanIter_t fn_for_each_pair_3_0::codegen(
   CompilerCB*,
   static_context* sctx,
   const QueryLoc& loc,
   std::vector<PlanIter_t>& argv,
   expr& ann) const
 {
-  return new FnMapPairsIterator(sctx, loc, argv);
+  return new FnForEachPairIterator(sctx, loc, argv);
 }
 
 

=== modified file 'src/functions/pregenerated/func_fn_hof_functions.h'
--- src/functions/pregenerated/func_fn_hof_functions.h	2013-04-10 21:01:35 +0000
+++ src/functions/pregenerated/func_fn_hof_functions.h	2013-06-04 18:53:34 +0000
@@ -98,11 +98,11 @@
 };
 
 
-//fn:map-pairs
-class fn_map_pairs_3_0 : public function
+//fn:for-each-pair
+class fn_for_each_pair_3_0 : public function
 {
 public:
-  fn_map_pairs_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
+  fn_for_each_pair_3_0(const signature& sig, FunctionConsts::FunctionKind kind)
     : 
     function(sig, kind)
   {

=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h	2013-04-17 21:30:29 +0000
+++ src/functions/pregenerated/function_enum.h	2013-06-04 18:53:34 +0000
@@ -210,7 +210,7 @@
   OP_ZORBA_FUNCTION_LOOKUP_5,
   FN_FUNCTION_NAME_1,
   FN_FUNCTION_ARITY_1,
-  FN_MAP_PAIRS_3,
+  FN_FOR_EACH_PAIR_3,
   FN_FOLD_LEFT_3,
   FN_FOLD_RIGHT_3,
   ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1,

=== modified file 'src/runtime/hof/fn_hof_functions_impl.cpp'
--- src/runtime/hof/fn_hof_functions_impl.cpp	2013-05-08 20:14:47 +0000
+++ src/runtime/hof/fn_hof_functions_impl.cpp	2013-06-04 18:53:34 +0000
@@ -256,7 +256,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-FnMapPairsIteratorState::~FnMapPairsIteratorState()
+FnForEachPairIteratorState::~FnForEachPairIteratorState()
 {
   if (theIsOpen)
   {
@@ -265,7 +265,7 @@
 }
 
 
-void FnMapPairsIteratorState::init(PlanState& planState)
+void FnForEachPairIteratorState::init(PlanState& planState)
 {
   PlanIteratorState::init(planState);
   thePlanState = &planState;
@@ -274,7 +274,7 @@
 }
 
 
-void FnMapPairsIteratorState::reset(PlanState& planState)
+void FnForEachPairIteratorState::reset(PlanState& planState)
 {
   PlanIteratorState::reset(planState);
   if (theIsOpen)
@@ -284,25 +284,25 @@
 }
 
 
-uint32_t FnMapPairsIterator::getStateSizeOfSubtree() const
+uint32_t FnForEachPairIterator::getStateSizeOfSubtree() const
 {
-  uint32_t size = NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>::
+  uint32_t size = NaryBaseIterator<FnForEachPairIterator, FnForEachPairIteratorState>::
                   getStateSizeOfSubtree();
 
   return size + sizeof(UDFunctionCallIteratorState);
 }
 
 
-void FnMapPairsIterator::openImpl(PlanState& planState, uint32_t& offset)
+void FnForEachPairIterator::openImpl(PlanState& planState, uint32_t& offset)
 {
-  StateTraitsImpl<FnMapPairsIteratorState>::createState(planState,
+  StateTraitsImpl<FnForEachPairIteratorState>::createState(planState,
                                                 theStateOffset,
                                                 offset);
 
-  StateTraitsImpl<FnMapPairsIteratorState>::initState(planState, theStateOffset);
+  StateTraitsImpl<FnForEachPairIteratorState>::initState(planState, theStateOffset);
 
-  FnMapPairsIteratorState* state =
-  StateTraitsImpl<FnMapPairsIteratorState>::getState(planState, theStateOffset);
+  FnForEachPairIteratorState* state =
+  StateTraitsImpl<FnForEachPairIteratorState>::getState(planState, theStateOffset);
 
   state->theUDFStateOffset = offset;
 
@@ -317,27 +317,27 @@
 }
 
 
-bool FnMapPairsIterator::nextImpl(
+bool FnForEachPairIterator::nextImpl(
     store::Item_t& result,
     PlanState& planState) const
 {
   store::Item_t child1, child2;
   std::vector<PlanIter_t> arguments;
-  
-  FnMapPairsIteratorState* state;
-  DEFAULT_STACK_INIT(FnMapPairsIteratorState, state, planState);
-
-  consumeNext(state->theFnItem, theChildren[0], planState);
+
+  FnForEachPairIteratorState* state;
+  DEFAULT_STACK_INIT(FnForEachPairIteratorState, state, planState);
+
+  consumeNext(state->theFnItem, theChildren[2], planState);
 
   // function signature guarantees that
   ZORBA_ASSERT(state->theFnItem->isFunction());
 
   while (true)
   {
-    if (!consumeNext(child1, theChildren[1], planState) ||
-        !consumeNext(child2, theChildren[2], planState))
+    if (!consumeNext(child1, theChildren[0], planState) ||
+        !consumeNext(child2, theChildren[1], planState))
       break;
-        
+
     if (child1.getp() && child2.getp())
     {
       {
@@ -348,12 +348,12 @@
         store::Iterator_t seqIter2 = seq2->getIterator();
         seqIter1->open();
         seqIter2->open();
-       
+
         arguments.push_back(NULL); // the first argument is expected to be the function item and it is not used
         arguments.push_back(new PlanStateIteratorWrapper(seqIter1));
         arguments.push_back(new PlanStateIteratorWrapper(seqIter2));
       }
-      
+
       state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB);
       // must be opened after vars and params are set
       state->thePlan->open(planState, state->theUDFStateOffset);
@@ -363,7 +363,7 @@
       {
         STACK_PUSH(true, state);
       }
-      
+
       // need to close here early in case the plan is completely
       // consumed. Otherwise, the plan would still be opened
       // if destroyed from the state's destructor.
@@ -452,18 +452,18 @@
   store::Item_t curSeqItem, nextSeqItem, tempItem;
   std::vector<store::Item_t> zero;
   bool haveSeqItems;
-  
+
   FnFoldLeftIteratorState* state;
   DEFAULT_STACK_INIT(FnFoldLeftIteratorState, state, planState);
 
-  consumeNext(state->theFnItem, theChildren[0], planState);
+  consumeNext(state->theFnItem, theChildren[2], planState);
 
   // function signature guarantees that
   ZORBA_ASSERT(state->theFnItem->isFunction());
 
-  if ((haveSeqItems = consumeNext(curSeqItem, theChildren[2], planState)))
-    haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState);
-  
+  if ((haveSeqItems = consumeNext(curSeqItem, theChildren[0], planState)))
+    haveSeqItems = consumeNext(nextSeqItem, theChildren[0], planState);
+
   if (curSeqItem.getp() == NULL && nextSeqItem.getp() == NULL)
   {
     // consume and return the "zero" argument
@@ -479,7 +479,7 @@
     {
       zero.push_back(tempItem);
     }
-    
+
     while (true)
     {
       {
@@ -490,48 +490,48 @@
         store::Iterator_t seqIter2 = seq->getIterator();
         seqIter1->open();
         seqIter2->open();
-        
+
         std::vector<PlanIter_t> arguments;
         arguments.push_back(NULL);
         arguments.push_back(new PlanStateIteratorWrapper(seqIter1));
         arguments.push_back(new PlanStateIteratorWrapper(seqIter2));
         if (theIsFoldRight)
           std::reverse(++arguments.begin(), arguments.end());
-        
+
         state->thePlan = static_cast<FunctionItem*>(state->theFnItem.getp())->getImplementation(arguments, planState.theCompilerCB);
         state->thePlan->open(planState, state->theUDFStateOffset);
         state->theIsOpen = true; 
       }
-      
+
       if (curSeqItem.isNull() || nextSeqItem.isNull())
         break;
-      
+
       zero.clear();
       while (consumeNext(tempItem, state->thePlan, planState))
       {
         zero.push_back(tempItem);
       }
-      
+
       state->thePlan->close(planState);
       state->theIsOpen = false;
-      
+
       curSeqItem = nextSeqItem;
       nextSeqItem = NULL;
       if (haveSeqItems)
-        haveSeqItems = consumeNext(nextSeqItem, theChildren[2], planState);
-      
+        haveSeqItems = consumeNext(nextSeqItem, theChildren[0], planState);
+
     } // while (true)
-    
+
     while (consumeNext(result, state->thePlan, planState))
     {
       STACK_PUSH(true, state);
     }
-    
+
     state->thePlan->close(planState);
     state->theIsOpen = false;
-    
+
   } // else
-  
+
   STACK_END(state);
 }
 

=== modified file 'src/runtime/hof/pregenerated/fn_hof_functions.cpp'
--- src/runtime/hof/pregenerated/fn_hof_functions.cpp	2013-04-16 06:45:24 +0000
+++ src/runtime/hof/pregenerated/fn_hof_functions.cpp	2013-06-04 18:53:34 +0000
@@ -120,17 +120,17 @@
 // </FunctionArityIterator>
 
 
-// <FnMapPairsIterator>
-SERIALIZABLE_CLASS_VERSIONS(FnMapPairsIterator)
+// <FnForEachPairIterator>
+SERIALIZABLE_CLASS_VERSIONS(FnForEachPairIterator)
 
-void FnMapPairsIterator::serialize(::zorba::serialization::Archiver& ar)
+void FnForEachPairIterator::serialize(::zorba::serialization::Archiver& ar)
 {
   serialize_baseclass(ar,
-  (NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>*)this);
+  (NaryBaseIterator<FnForEachPairIterator, FnForEachPairIteratorState>*)this);
 }
 
 
-void FnMapPairsIterator::accept(PlanIterVisitor& v) const
+void FnForEachPairIterator::accept(PlanIterVisitor& v) const
 {
   v.beginVisit(*this);
 
@@ -143,11 +143,11 @@
   v.endVisit(*this);
 }
 
-FnMapPairsIterator::~FnMapPairsIterator() {}
-
-FnMapPairsIteratorState::FnMapPairsIteratorState() {}
-
-// </FnMapPairsIterator>
+FnForEachPairIterator::~FnForEachPairIterator() {}
+
+FnForEachPairIteratorState::FnForEachPairIteratorState() {}
+
+// </FnForEachPairIterator>
 
 
 // <FnFoldLeftIterator>

=== modified file 'src/runtime/hof/pregenerated/fn_hof_functions.h'
--- src/runtime/hof/pregenerated/fn_hof_functions.h	2013-04-16 06:45:24 +0000
+++ src/runtime/hof/pregenerated/fn_hof_functions.h	2013-06-04 18:53:34 +0000
@@ -139,7 +139,7 @@
  *    
  * Author: Zorba Team
  */
-class FnMapPairsIteratorState : public PlanIteratorState
+class FnForEachPairIteratorState : public PlanIteratorState
 {
 public:
   PlanState* thePlanState; //
@@ -148,33 +148,33 @@
   uint32_t theUDFStateOffset; //
   store::Item_t theFnItem; //
 
-  FnMapPairsIteratorState();
+  FnForEachPairIteratorState();
 
-  ~FnMapPairsIteratorState();
+  ~FnForEachPairIteratorState();
 
   void init(PlanState&);
   void reset(PlanState&);
 };
 
-class FnMapPairsIterator : public NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>
+class FnForEachPairIterator : public NaryBaseIterator<FnForEachPairIterator, FnForEachPairIteratorState>
 { 
 public:
-  SERIALIZABLE_CLASS(FnMapPairsIterator);
+  SERIALIZABLE_CLASS(FnForEachPairIterator);
 
-  SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnMapPairsIterator,
-    NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>);
+  SERIALIZABLE_CLASS_CONSTRUCTOR2T(FnForEachPairIterator,
+    NaryBaseIterator<FnForEachPairIterator, FnForEachPairIteratorState>);
 
   void serialize( ::zorba::serialization::Archiver& ar);
 
-  FnMapPairsIterator(
+  FnForEachPairIterator(
     static_context* sctx,
     const QueryLoc& loc,
     std::vector<PlanIter_t>& children)
     : 
-    NaryBaseIterator<FnMapPairsIterator, FnMapPairsIteratorState>(sctx, loc, children)
+    NaryBaseIterator<FnForEachPairIterator, FnForEachPairIteratorState>(sctx, loc, children)
   {}
 
-  virtual ~FnMapPairsIterator();
+  virtual ~FnForEachPairIterator();
 
   uint32_t getStateSizeOfSubtree() const;
 

=== modified file 'src/runtime/pregenerated/iterator_enum.h'
--- src/runtime/pregenerated/iterator_enum.h	2013-04-05 21:00:15 +0000
+++ src/runtime/pregenerated/iterator_enum.h	2013-06-04 18:53:34 +0000
@@ -130,7 +130,7 @@
   TYPE_FunctionLookupIterator,
   TYPE_FunctionNameIterator,
   TYPE_FunctionArityIterator,
-  TYPE_FnMapPairsIterator,
+  TYPE_FnForEachPairIterator,
   TYPE_FnFoldLeftIterator,
   TYPE_ActivateICIterator,
   TYPE_DeactivateICIterator,

=== modified file 'src/runtime/spec/hof/fn_hof_functions.xml'
--- src/runtime/spec/hof/fn_hof_functions.xml	2013-04-16 06:45:24 +0000
+++ src/runtime/spec/hof/fn_hof_functions.xml	2013-06-04 18:53:34 +0000
@@ -105,19 +105,19 @@
   
   <!--
   /*******************************************************************************
-    fn:map-pairs
+    fn:for-each-pair
   ********************************************************************************/
   -->
-  <zorba:iterator name="FnMapPairsIterator" generateOpenImpl="true" generateGetStateSize="true">
+  <zorba:iterator name="FnForEachPairIterator" generateOpenImpl="true" generateGetStateSize="true">
     <zorba:description author="Zorba Team">
       Applies the function item $f to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order.
     </zorba:description>
 
     <zorba:function generateDECL="false">
-      <zorba:signature localname="map-pairs" prefix="fn" version="3.0">
+      <zorba:signature localname="for-each-pair" prefix="fn" version="3.0">
+        <zorba:param>item()*</zorba:param>
+        <zorba:param>item()*</zorba:param>
         <zorba:param>function()*</zorba:param>
-        <zorba:param>item()*</zorba:param>
-        <zorba:param>item()*</zorba:param>
         <zorba:output>item()*</zorba:output>
       </zorba:signature>
     </zorba:function>
@@ -144,25 +144,25 @@
     </zorba:description>
 
     <zorba:member type="bool" name="theIsFoldRight"/>
-  
+
     <zorba:constructor>
       <zorba:parameter type="bool" name="aIsFoldRight"/>
     </zorba:constructor>
 
     <zorba:function generateDECL="false" generateCodegen="false">
       <zorba:signature localname="fold-left" prefix="fn" version="3.0">
+        <zorba:param>item()*</zorba:param>
+        <zorba:param>item()*</zorba:param>
         <zorba:param>function()*</zorba:param>
-        <zorba:param>item()*</zorba:param>
-        <zorba:param>item()*</zorba:param>
         <zorba:output>item()*</zorba:output>
       </zorba:signature>
     </zorba:function>
-    
+
     <zorba:function generateDECL="false" generateCodegen="false">
       <zorba:signature localname="fold-right" prefix="fn" version="3.0">
+        <zorba:param>item()*</zorba:param>
+        <zorba:param>item()*</zorba:param>
         <zorba:param>function()*</zorba:param>
-        <zorba:param>item()*</zorba:param>
-        <zorba:param>item()*</zorba:param>
         <zorba:output>item()*</zorba:output>
       </zorba:signature>
     </zorba:function>
@@ -174,7 +174,7 @@
       <zorba:member type="uint32_t" name="theUDFStateOffset"/>
       <zorba:member type="store::Item_t" name="theFnItem"/>
     </zorba:state>
-  
+
   </zorba:iterator>
-  
+
 </zorba:iterators>

=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h	2013-04-05 21:00:15 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h	2013-06-04 18:53:34 +0000
@@ -266,7 +266,7 @@
 
     class FunctionArityIterator;
 
-    class FnMapPairsIterator;
+    class FnForEachPairIterator;
 
     class FnFoldLeftIterator;
 
@@ -1128,8 +1128,8 @@
     virtual void beginVisit ( const FunctionArityIterator& ) = 0;
     virtual void endVisit   ( const FunctionArityIterator& ) = 0;
 
-    virtual void beginVisit ( const FnMapPairsIterator& ) = 0;
-    virtual void endVisit   ( const FnMapPairsIterator& ) = 0;
+    virtual void beginVisit ( const FnForEachPairIterator& ) = 0;
+    virtual void endVisit   ( const FnForEachPairIterator& ) = 0;
 
     virtual void beginVisit ( const FnFoldLeftIterator& ) = 0;
     virtual void endVisit   ( const FnFoldLeftIterator& ) = 0;

=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp	2013-04-05 21:00:15 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp	2013-06-04 18:53:34 +0000
@@ -1537,18 +1537,18 @@
 // </FunctionArityIterator>
 
 
-// <FnMapPairsIterator>
-void PrinterVisitor::beginVisit ( const FnMapPairsIterator& a) {
-  thePrinter.startBeginVisit("FnMapPairsIterator", ++theId);
+// <FnForEachPairIterator>
+void PrinterVisitor::beginVisit ( const FnForEachPairIterator& a) {
+  thePrinter.startBeginVisit("FnForEachPairIterator", ++theId);
   printCommons( &a, theId );
   thePrinter.endBeginVisit( theId );
 }
 
-void PrinterVisitor::endVisit ( const FnMapPairsIterator& ) {
+void PrinterVisitor::endVisit ( const FnForEachPairIterator& ) {
   thePrinter.startEndVisit();
   thePrinter.endEndVisit();
 }
-// </FnMapPairsIterator>
+// </FnForEachPairIterator>
 
 
 // <FnFoldLeftIterator>

=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h	2013-04-05 21:00:15 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h	2013-06-04 18:53:34 +0000
@@ -409,8 +409,8 @@
     void beginVisit( const FunctionArityIterator& );
     void endVisit  ( const FunctionArityIterator& );
 
-    void beginVisit( const FnMapPairsIterator& );
-    void endVisit  ( const FnMapPairsIterator& );
+    void beginVisit( const FnForEachPairIterator& );
+    void endVisit  ( const FnForEachPairIterator& );
 
     void beginVisit( const FnFoldLeftIterator& );
     void endVisit  ( const FnFoldLeftIterator& );

=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt	2013-05-31 07:21:49 +0000
+++ test/fots/CMakeLists.txt	2013-06-04 18:53:34 +0000
@@ -366,80 +366,21 @@
 EXPECTED_FOTS_FAILURE (xs-error xs-error-041 1170470)
 EXPECTED_FOTS_FAILURE (xs-error xs-error-042 1170470)
 EXPECTED_FOTS_FAILURE (xs-error xs-error-049 1170470)
-EXPECTED_FOTS_FAILURE (fn-filter filter-001 1182910) #Changes in F&O spec
-EXPECTED_FOTS_FAILURE (fn-filter filter-002 1182910)
-EXPECTED_FOTS_FAILURE (fn-filter filter-003 1182910)
-EXPECTED_FOTS_FAILURE (fn-filter filter-004 1182910)
-EXPECTED_FOTS_FAILURE (fn-filter filter-005 1182910)
-EXPECTED_FOTS_FAILURE (fn-filter fn-filter-013 1182910)
-EXPECTED_FOTS_FAILURE (fn-filter fn-filter-014 1182910)
-EXPECTED_FOTS_FAILURE (fn-filter fn-filter-017 1182910)
-EXPECTED_FOTS_FAILURE (fn-filter fn-filter-020 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-001 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-002 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-003 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-004 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-005 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-006 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-007 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-008 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-015 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-016 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-017 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-018 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-019 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-020 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-001 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-002 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-003 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-004 1182910)
 EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-005 1182910)
 EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-006 1182910)
 EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-007 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-013 1182910)
 EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-014 1182910)
 EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-015 1182910)
 EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-016 1182910)
 EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-017 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-018 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-019 1182910)
-EXPECTED_FOTS_FAILURE (fn-fold-right fold-right-020 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each for-each-001 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each for-each-002 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each for-each-003 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each for-each-004 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each for-each-005 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each for-each-006 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each for-each-007 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each for-each-008 1182910)
-EXPECTED_FOTS_FAILURE (fn-function-lookup fn-function-lookup-423 1182910)
 EXPECTED_FOTS_FAILURE (fn-function-lookup fn-function-lookup-424 1182910)
 EXPECTED_FOTS_FAILURE (fn-function-lookup fn-function-lookup-426 1182910)
-EXPECTED_FOTS_FAILURE (fn-function-lookup fn-function-lookup-428 1182910)
 EXPECTED_FOTS_FAILURE (fn-function-lookup fn-function-lookup-430 1182910)
-EXPECTED_FOTS_FAILURE (fn-function-lookup fn-function-lookup-431 1182910)
-EXPECTED_FOTS_FAILURE (fn-function-lookup fn-function-lookup-432 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair for-each-pair-001 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair for-each-pair-002 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair for-each-pair-003 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair for-each-pair-004 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair for-each-pair-005 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair for-each-pair-006 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair for-each-pair-007 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair for-each-pair-008 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair fn-for-each-pair-008 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair fn-for-each-pair-017 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair fn-for-each-pair-025 1182910)
 EXPECTED_FOTS_FAILURE (fn-for-each-pair fn-for-each-pair-026 1182910)
-EXPECTED_FOTS_FAILURE (fn-for-each-pair fn-for-each-pair-027 1182910)
 EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-062 1182910)
-EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-423 1182910)
 EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-424 1182910)
 EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-426 1182910)
-EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-428 1182910)
 EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-430 1182910)
-EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-431 1182910)
-EXPECTED_FOTS_FAILURE (prod-NamedFunctionRef function-literal-432 1182910)
 EXPECTED_FOTS_FAILURE (misc-HigherOrderFunctions xqhof3 0) #this is a test-case that was updated in FOTS
 EXPECTED_FOTS_FAILURE (prod-CompNamespaceConstructor nscons-042 0)
 

=== modified file 'test/rbkt/ExpQueryResults/zorba/introspection/introsp-fn-7.xml.res'
--- test/rbkt/ExpQueryResults/zorba/introspection/introsp-fn-7.xml.res	2013-03-04 21:00:58 +0000
+++ test/rbkt/ExpQueryResults/zorba/introspection/introsp-fn-7.xml.res	2013-06-04 18:53:34 +0000
@@ -1,1 +1,1 @@
-QName abs adjust-date-to-timezone adjust-dateTime-to-timezone adjust-time-to-timezone analyze-string available-environment-variables avg base-uri boolean ceiling codepoint-equal codepoints-to-string collection compare concat contains count current-date current-dateTime current-time data dateTime day-from-date day-from-dateTime days-from-duration deep-equal default-collation distinct-values doc doc-available document-uri element-with-id empty encode-for-uri ends-with environment-variable error escape-html-uri exactly-one exists false filter floor fold-left fold-right format-date format-dateTime format-integer format-number format-time function-arity function-lookup function-name generate-id has-children head hours-from-dateTime hours-from-duration hours-from-time id idref implicit-timezone in-scope-prefixes index-of innermost insert-before iri-to-uri lang last local-name local-name-from-QName lower-case map map-pairs matches max min minutes-from-dateTime minutes-from-duration minutes-from-time month-from-date month-from-dateTime months-from-duration name namespace-uri namespace-uri-for-prefix namespace-uri-from-QName nilled node-name normalize-space normalize-unicode not number one-or-more outermost parse-xml parse-xml-fragment path position prefix-from-QName put remove replace resolve-QName resolve-uri reverse root round round-half-to-even seconds-from-dateTime seconds-from-duration seconds-from-time serialize starts-with static-base-uri string string-join string-length string-to-codepoints subsequence substring substring-after substring-before sum tail timezone-from-date timezone-from-dateTime timezone-from-time tokenize trace translate true unordered unparsed-text unparsed-text-available unparsed-text-lines upper-case uri-collection year-from-date year-from-dateTime years-from-duration zero-or-one acos asin atan atan2 cos exp exp10 log log10 pi pow sin sqrt tan base-uri boundary-space-policy construction-mode copy-namespaces-mode default-collation default-collection-type default-function-namespace default-order function-annotations function-arguments-count function-names in-scope-attribute-declarations in-scope-attribute-groups in-scope-element-declarations in-scope-element-groups in-scope-schema-types in-scope-variables option ordering-mode statically-known-collations statically-known-document-type statically-known-documents statically-known-namespace-binding statically-known-namespaces xpath10-compatibility-mode
+QName abs adjust-date-to-timezone adjust-dateTime-to-timezone adjust-time-to-timezone analyze-string available-environment-variables avg base-uri boolean ceiling codepoint-equal codepoints-to-string collection compare concat contains count current-date current-dateTime current-time data dateTime day-from-date day-from-dateTime days-from-duration deep-equal default-collation distinct-values doc doc-available document-uri element-with-id empty encode-for-uri ends-with environment-variable error escape-html-uri exactly-one exists false filter floor fold-left fold-right for-each for-each-pair format-date format-dateTime format-integer format-number format-time function-arity function-lookup function-name generate-id has-children head hours-from-dateTime hours-from-duration hours-from-time id idref implicit-timezone in-scope-prefixes index-of innermost insert-before iri-to-uri lang last local-name local-name-from-QName lower-case matches max min minutes-from-dateTime minutes-from-duration minutes-from-time month-from-date month-from-dateTime months-from-duration name namespace-uri namespace-uri-for-prefix namespace-uri-from-QName nilled node-name normalize-space normalize-unicode not number one-or-more outermost parse-xml parse-xml-fragment path position prefix-from-QName put remove replace resolve-QName resolve-uri reverse root round round-half-to-even seconds-from-dateTime seconds-from-duration seconds-from-time serialize starts-with static-base-uri string string-join string-length string-to-codepoints subsequence substring substring-after substring-before sum tail timezone-from-date timezone-from-dateTime timezone-from-time tokenize trace translate true unordered unparsed-text unparsed-text-available unparsed-text-lines upper-case uri-collection year-from-date year-from-dateTime years-from-duration zero-or-one acos asin atan atan2 cos exp exp10 log log10 pi pow sin sqrt tan base-uri boundary-space-policy construction-mode copy-namespaces-mode default-collation default-collection-type default-function-namespace default-order function-annotations function-arguments-count function-names in-scope-attribute-declarations in-scope-attribute-groups in-scope-element-declarations in-scope-element-groups in-scope-schema-types in-scope-variables option ordering-mode statically-known-collations statically-known-document-type statically-known-documents statically-known-namespace-binding statically-known-namespaces xpath10-compatibility-mode
\ No newline at end of file

=== modified file 'test/rbkt/Queries/zorba/spec/XQuery_3.0.html'
--- test/rbkt/Queries/zorba/spec/XQuery_3.0.html	2013-02-07 17:24:36 +0000
+++ test/rbkt/Queries/zorba/spec/XQuery_3.0.html	2013-06-04 18:53:34 +0000
@@ -1,10 +1,11 @@
-<!--XSLT Processor: SAXON 9.1.0.5 from Saxonica SAXON 9.1.0.5--><html xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns="http://www.w3.org/1999/xhtml"; lang="EN" xml:lang="EN">
+<!--XSLT Processor: SAXON 9.3.0.5 from Saxonica SAXON EE 9.3.0.5--><html xmlns="http://www.w3.org/1999/xhtml"; lang="EN" xml:lang="EN">
   <head>
-    <meta name="generator" content="HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 15.6), see www.w3.org"/>
+    <meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see www.w3.org"/>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     <title>XPath and XQuery Functions and Operators 3.0</title>
     <style type="text/css">
 /**/
+/* from xsl:query.xsl (C) */          
 code           { font-family: monospace; }
 
 div.constraint,
@@ -28,6 +29,7 @@
                  color: #8F8F8F;
                }
     
+/* from xsl:query.xsl (D) */          
 div.exampleInner pre { margin-left: 1em;
                        margin-top: 0em; margin-bottom: 0em}
 div.exampleOuter {border: 4px double gray;
@@ -166,6 +168,7 @@
                  }
 
 
+/* from xsl-query.xsl (B) */    
 table.small                             { font-size: x-small; }
 a.judgment:visited, a.judgment:link     { font-family: sans-serif;
                                           color: black; 
@@ -176,7 +179,7 @@
                                           text-decoration: none }
 /**/
 </style>
-    <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-WD.css"/>
+    <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-CR.css"/>
   </head>
   <body>
     <div class="head">
@@ -189,12 +192,12 @@
         <a name="title" id="title"/>XPath and XQuery Functions and
 Operators 3.0</h1>
       <h2>
-        <a name="w3c-doctype" id="w3c-doctype"/>W3C Working Draft 13
-December 2011</h2>
+        <a name="w3c-doctype" id="w3c-doctype"/>W3C Candidate
+Recommendation 21 May 2013</h2>
       <dl>
         <dt>This version:</dt>
         <dd>
-          <a href="http://www.w3.org/TR/2011/WD-xpath-functions-30-20111213/";>http://www.w3.org/TR/2011/WD-xpath-functions-30-20111213/</a>
+          <a href="http://www.w3.org/TR/2013/CR-xpath-functions-30-20130521/";>http://www.w3.org/TR/2013/CR-xpath-functions-30-20130521/</a>
         </dd>
         <dt>Latest version:</dt>
         <dd>
@@ -202,6 +205,8 @@
         </dd>
         <dt>Previous versions:</dt>
         <dd>
+          <a href="http://www.w3.org/TR/2013/CR-xpath-functions-30-20130108/";>http://www.w3.org/TR/2013/CR-xpath-functions-30-20130108/</a>
+          <a href="http://www.w3.org/TR/2011/WD-xpath-functions-30-20111213/";>http://www.w3.org/TR/2011/WD-xpath-functions-30-20111213/</a>
           <a href="http://www.w3.org/TR/2011/WD-xpath-functions-30-20110614/";>http://www.w3.org/TR/2011/WD-xpath-functions-30-20110614/</a>
           <a href="http://www.w3.org/TR/2010/WD-xpath-functions-30-20101214/";>http://www.w3.org/TR/2010/WD-xpath-functions-30-20101214/</a>
           <a href="http://www.w3.org/TR/2009/WD-xpath-functions-11-20091215/";>http://www.w3.org/TR/2009/WD-xpath-functions-11-20091215/</a>
@@ -214,11 +219,11 @@
           <strong>translations</strong>
         </a>.</p>
       <p>This document is also available in these non-normative formats:
-<a href="http://www.w3.org/TR/2011/WD-xpath-functions-30-20111213/xpath-functions-30.xml";>
-XML</a> and <a href="http://www.w3.org/TR/2011/WD-xpath-functions-30-20111213/xpath-functions-30-diff.html";>Change
+<a href="http://www.w3.org/TR/2013/CR-xpath-functions-30-20130521/xpath-functions-30.xml";>
+XML</a> and <a href="http://www.w3.org/TR/2013/CR-xpath-functions-30-20130521/xpath-functions-30-diff.html";>Change
 markings relative to previous Working Draft</a>.</p>
       <p class="copyright">
-        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright";>Copyright</a> © 2011 <a href="http://www.w3.org/";>
+        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright";>Copyright</a> © 2013 <a href="http://www.w3.org/";>
           <acronym title="World Wide Web Consortium">W3C</acronym>
         </a>
         <sup>®</sup>
@@ -227,8 +232,8 @@
         </a>, <a href="http://www.ercim.eu/";>
           <acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym>
         </a>,
-<a href="http://www.keio.ac.jp/";>Keio</a>), All Rights Reserved.
-W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer";>liability</a>,
+<a href="http://www.keio.ac.jp/";>Keio</a>, <a href="http://ev.buaa.edu.cn/";>Beihang</a>), All Rights Reserved. W3C
+<a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer";>liability</a>,
 <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks";>trademark</a>
 and <a href="http://www.w3.org/Consortium/Legal/copyright-documents";>document
 use</a> rules apply.</p>
@@ -273,21 +278,40 @@
 progressed to Recommendation together (XQuery 3.0, XQueryX 3.0,
 XSLT 3.0, Data Model 3.0, Functions and Operators 3.0,
 Serialization 3.0, XPath 3.0).</p>
-      <p>This is a <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#last-call";>Last
-Call Working Draft</a> as described in the <a href="http://www.w3.org/2005/10/Process-20051014/tr.html";>Process
-Document</a>. It was jointly developed by the W3C <a href="http://www.w3.org/XML/Query/";>XML Query Working Group</a> and the
-W3C <a href="http://www.w3.org/Style/XSL/";>XSL Working Group</a>,
-each of which is part of the <a href="http://www.w3.org/XML/Activity";>XML Activity</a>. Comments on this
-document will be formally accepted at least through 10 February
-2012. The Working Groups expect to advance this specification to
-<a href="http://www.w3.org/2005/10/Process-20051014/tr.html#RecsW3C";>Recommendation</a>
+      <p>W3C publishes a <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#RecsCR";>Candidate
+Recommendation</a>, as described in the <a href="http://www.w3.org/2005/10/Process-20051014/tr.html";>Process
+Document</a>, to indicate that the document is believed to be
+stable and to encourage implementation by the developer community.
+The publication of this document constitutes a <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#cfi";>call for
+implementations</a> of this specification.</p>
+      <p>This document was jointly developed by the W3C <a href="http://www.w3.org/XML/Query/";>XML Query Working Group</a> and the
+W3C <a href="http://www.w3.org/Style/XSL/";>XSLT Working Group</a>,
+each of which is part of the <a href="http://www.w3.org/XML/Activity";>XML Activity</a>. It will remain a
+Candidate Recommendation until at least 08 April 2013. The Working
+Groups expect to advance this specification to <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#RecsW3C";>Recommendation</a>
 Status.</p>
-      <p>This Last Call Working Draft makes a number of substantive
-technical changes (as well as many editorial changes), including
-new features, adopted since the previous Working Draft was
-published. Please note that this Working Draft of XPath and XQuery
-Functions and Operators 3.0 represents the second version of
-<a href="http://www.w3.org/TR/2010/REC-xpath-functions-20101214/";>a
+      <p>Once the entrance criteria for Proposed Recommendation have been
+achieved, the Director will be requested to advance this document
+to <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#RecsPR";>Proposed
+Recommendation</a> status. Working closely with the developer
+community, we expect to show evidence of implementations by
+approximately 31 July 2013.</p>
+      <p>This updated Candidate Recommendation is being published to
+allow document reviewers and implementors to see in context all
+changes that have been made during the CR review period. The most
+important changes are to the names of the functions formerly named
+"fn:map" and "fn:map-pairs" (renamed "fn:for-each" and
+"fn:for-each-pair", respectively), and to the order of arguments
+for these two functions as well as fn:filter, fn:fold-left, and
+fn:fold-right. The motivation for the change is partly usability,
+and partly concern about possible conflicts with features being
+considered for future releases. A full list of changes since the
+Candidate Recommendation of 08 January 2013 is at <a href="#substantive-changes-current-draft">
+          <b>E.4 Substantive changes
+(post Candidate Recommendation)</b>
+        </a>. Please note that this
+Candidate Recommendation of XPath and XQuery Functions and
+Operators 3.0 represents the second version of <a href="http://www.w3.org/TR/2010/REC-xpath-functions-20101214/";>a
 previous W3C Recommendation</a>.</p>
       <p>This specification is designed to be referenced normatively from
 other specifications defining a host language for it; it is not
@@ -295,18 +319,18 @@
 implementability of this specification has been tested in the
 context of its normative inclusion in host languages defined by the
 <a href="http://www.w3.org/TR/xquery-30/";>XQuery 3.0</a> and XSLT
-3.0 (expected in 2012) specifications; see the <a href="http://dev.w3.org/2011/xquery-30-test-suite/results/XQTSReport.html";>
-XQuery 3.0 implementation report</a> (and, in the future, the WGs
-expect that there will also be a member-only XSLT 3.0
+3.0 (expected in 2013) specifications; see the <a href="http://dev.w3.org/2011/QT3-test-suite/reports/QT3TSReport.html";>XQuery
+3.0 implementation report</a> (and, in the future, the WGs expect
+that there will also be a — possibly member-only — XSLT 3.0
 implementation report) for details.</p>
-      <p>This document incorporates changes made against the previous
-publication of the Working Draft. Changes to this document since
-the previous publication of the Working Draft are detailed in
-<a href="#changelog">
-          <b>F Changes since previous
-Recommendation</b>
+      <p>This document incorporates changes made against the <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#last-call";>Last
+Call Working Draft</a> of 13 December 2011. Changes to this
+document since the <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#last-call";>Last
+Call Working Draft</a> are detailed in <a href="#changelog">
+          <b>E
+Changes since previous Recommendation</b>
         </a>.</p>
-      <p>Please report errors in this document using W3C's <a href="http://www.w3.org/Bugs/Public/";>public Bugzilla system</a>
+      <p>Please report errors in this document using W3C's <a href="https://www.w3.org/Bugs/Public/";>public Bugzilla system</a>
 (instructions can be found at <a href="http://www.w3.org/XML/2005/04/qt-bugzilla";>http://www.w3.org/XML/2005/04/qt-bugzilla</a>).
 If access to that system is not feasible, you may send your
 comments to the W3C XSLT/XPath/XQuery public comments mailing list,
@@ -316,10 +340,10 @@
 Please use multiple Bugzilla entries (or, if necessary, multiple
 email messages) if you have more than one comment to make. Archives
 of the comments and responses are available at <a href="http://lists.w3.org/Archives/Public/public-qt-comments/";>http://lists.w3.org/Archives/Public/public-qt-comments/</a>.</p>
-      <p>Publication as a Working Draft does not imply endorsement by the
-W3C Membership. This is a draft document and may be updated,
-replaced or obsoleted by other documents at any time. It is
-inappropriate to cite this document as other than work in
+      <p>Publication as a Candidate Recommendation does not imply
+endorsement by the W3C Membership. This is a draft document and may
+be updated, replaced or obsoleted by other documents at any time.
+It is inappropriate to cite this document as other than work in
 progress.</p>
       <p>This document was produced by groups operating under the
 <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/";>5
@@ -386,7 +410,7 @@
         <li>
           <p>
             <a href="#func-false">false</a>  <a href="#func-filter">filter</a>  <a href="#func-floor">floor</a> 
-<a href="#func-fold-left">fold-left</a>  <a href="#func-fold-right">fold-right</a>  <a href="#func-format-date">format-date</a>  <a href="#func-format-dateTime">format-dateTime</a>  <a href="#func-format-integer">format-integer</a>  <a href="#func-format-number">format-number</a>  <a href="#func-format-time">format-time</a>  <a href="#func-function-arity">function-arity</a>  <a href="#func-function-lookup">function-lookup</a>  <a href="#func-function-name">function-name</a> </p>
+<a href="#func-fold-left">fold-left</a>  <a href="#func-fold-right">fold-right</a>  <a href="#func-for-each">for-each</a>  <a href="#func-for-each-pair">for-each-pair</a>  <a href="#func-format-date">format-date</a>  <a href="#func-format-dateTime">format-dateTime</a>  <a href="#func-format-integer">format-integer</a>  <a href="#func-format-number">format-number</a>  <a href="#func-format-time">format-time</a>  <a href="#func-function-arity">function-arity</a>  <a href="#func-function-lookup">function-lookup</a>  <a href="#func-function-name">function-name</a> </p>
         </li>
         <li>
           <p>
@@ -409,7 +433,7 @@
         </li>
         <li>
           <p>
-            <a href="#func-map">map</a>  <a href="#func-map-pairs">map-pairs</a>  <a href="#func-matches">matches</a>  <a href="#func-max">max</a>  <a href="#func-min">min</a>  <a href="#func-minutes-from-dateTime">minutes-from-dateTime</a>  <a href="#func-minutes-from-duration">minutes-from-duration</a>  <a href="#func-minutes-from-time">minutes-from-time</a>  <a href="#func-month-from-date">month-from-date</a>  <a href="#func-month-from-dateTime">month-from-dateTime</a>  <a href="#func-months-from-duration">months-from-duration</a>  <a href="#func-multiply-dayTimeDuration">multiply-dayTimeDuration</a> 
+            <a href="#func-matches">matches</a>  <a href="#func-max">max</a>  <a href="#func-min">min</a>  <a href="#func-minutes-from-dateTime">minutes-from-dateTime</a>  <a href="#func-minutes-from-duration">minutes-from-duration</a>  <a href="#func-minutes-from-time">minutes-from-time</a>  <a href="#func-month-from-date">month-from-date</a>  <a href="#func-month-from-dateTime">month-from-dateTime</a>  <a href="#func-months-from-duration">months-from-duration</a>  <a href="#func-multiply-dayTimeDuration">multiply-dayTimeDuration</a> 
 <a href="#func-multiply-yearMonthDuration">multiply-yearMonthDuration</a> </p>
         </li>
         <li>
@@ -1178,7 +1202,7 @@
     16.2 <a href="#basic-hofs">Basic higher-order
 functions</a>
         <br/>
-        16.2.1 <a href="#func-map">fn:map</a>
+        16.2.1 <a href="#func-for-each">fn:for-each</a>
         <br/>
         16.2.2 <a href="#func-filter">fn:filter</a>
         <br/>
@@ -1186,17 +1210,23 @@
         <br/>
         16.2.4 <a href="#func-fold-right">fn:fold-right</a>
         <br/>
-        16.2.5 <a href="#func-map-pairs">fn:map-pairs</a>
+        16.2.5 <a href="#func-for-each-pair">fn:for-each-pair</a>
         <br/>
 17 <a href="#constructor-functions">Constructor functions</a>
         <br/>
     17.1 <a href="#constructor-functions-for-xsd-types">Constructor
-functions for XML Schema built-in types</a>
+functions for XML Schema built-in atomic types</a>
         <br/>
     17.2 <a href="#constructor-qname-notation">Constructor
 functions for xs:QName and xs:NOTATION</a>
         <br/>
-    17.3 <a href="#constructor-functions-for-user-defined-types">Constructor
+    17.3 <a href="#constructor-functions-for-xsd-list-types">Constructor functions
+for XML Schema built-in list types</a>
+        <br/>
+    17.4 <a href="#constructor-functions-for-xsd-union-types">Constructor functions
+for XML Schema built-in union types</a>
+        <br/>
+    17.5 <a href="#constructor-functions-for-user-defined-types">Constructor
 functions for user-defined types</a>
         <br/>
 18 <a href="#casting">Casting</a>
@@ -1267,62 +1297,64 @@
         <br/>
 B <a href="#error-summary">Error summary</a>
         <br/>
-C <a href="#xpath1-compatibility">Compatibility with XPath 1.0</a>
-(Non-Normative)<br/>
-D <a href="#examples">Illustrative user-written functions</a>
-(Non-Normative)<br/>
-    D.1 <a href="#if-empty-if-absent">eg:if-empty and
+C <a href="#examples">Illustrative user-written functions</a>
+(Non-Normative)<br/>
+    C.1 <a href="#if-empty-if-absent">eg:if-empty and
 eg:if-absent</a>
         <br/>
-        D.1.1 <a href="#if-empty">eg:if-empty</a>
-        <br/>
-        D.1.2 <a href="#if-absent">eg:if-absent</a>
-        <br/>
-    D.2 <a href="#union-intersect-except-on-values">Union,
+        C.1.1 <a href="#if-empty">eg:if-empty</a>
+        <br/>
+        C.1.2 <a href="#if-absent">eg:if-absent</a>
+        <br/>
+    C.2 <a href="#union-intersect-except-on-values">Union,
 intersection and difference on sequences of values</a>
         <br/>
-        D.2.1 <a href="#value-union">eg:value-union</a>
-        <br/>
-        D.2.2 <a href="#value-intersect">eg:value-intersect</a>
-        <br/>
-        D.2.3 <a href="#value-except">eg:value-except</a>
-        <br/>
-    D.3 <a href="#index-of-node">eg:index-of-node</a>
-        <br/>
-    D.4 <a href="#string-pad">eg:string-pad</a>
-        <br/>
-    D.5 <a href="#func-distinct-nodes-stable">eg:distinct-nodes-stable</a>
-        <br/>
-    D.6 <a href="#highest-lowest">Finding minima and
+        C.2.1 <a href="#value-union">eg:value-union</a>
+        <br/>
+        C.2.2 <a href="#value-intersect">eg:value-intersect</a>
+        <br/>
+        C.2.3 <a href="#value-except">eg:value-except</a>
+        <br/>
+    C.3 <a href="#index-of-node">eg:index-of-node</a>
+        <br/>
+    C.4 <a href="#string-pad">eg:string-pad</a>
+        <br/>
+    C.5 <a href="#func-distinct-nodes-stable">eg:distinct-nodes-stable</a>
+        <br/>
+    C.6 <a href="#highest-lowest">Finding minima and
 maxima</a>
         <br/>
-        D.6.1 <a href="#highest">eg:highest</a>
-        <br/>
-        D.6.2 <a href="#lowest">eg:lowest</a>
-        <br/>
-    D.7 <a href="#sorting">Sorting</a>
-        <br/>
-E <a href="#impl-def">Checklist of implementation-defined
+        C.6.1 <a href="#highest">eg:highest</a>
+        <br/>
+        C.6.2 <a href="#lowest">eg:lowest</a>
+        <br/>
+    C.7 <a href="#sorting">Sorting</a>
+        <br/>
+D <a href="#impl-def">Checklist of implementation-defined
 features</a> (Non-Normative)<br/>
-F <a href="#changelog">Changes since previous Recommendation</a>
+E <a href="#changelog">Changes since previous Recommendation</a>
 (Non-Normative)<br/>
-    F.1 <a href="#substantive-changes-2009-12-15">Substantive
+    E.1 <a href="#substantive-changes-2009-12-15">Substantive
 changes (15 December 2009)</a>
         <br/>
-    F.2 <a href="#substantive-changes-current-draft">Substantive
-changes (current draft)</a>
-        <br/>
-    F.3 <a href="#incompatibilities">Incompatibilities</a>
-        <br/>
-    F.4 <a href="#editorial-changes">Editorial changes</a>
-        <br/>
-G <a href="#quickref">Function and Operator Quick Reference</a>
-(Non-Normative)<br/>
-    G.1 <a href="#quickref-section">Functions and Operators by
-Section</a>
-        <br/>
-    G.2 <a href="#quickref-alpha">Functions and Operators
-Alphabetically</a>
+    E.2 <a href="#substantive-changes-2012-06-18">Substantive
+changes (18 June 2012)</a>
+        <br/>
+    E.3 <a href="#substantive-changes-2013-01-08">Substantive
+changes (Candidate Recommendation)</a>
+        <br/>
+    E.4 <a href="#substantive-changes-current-draft">Substantive
+changes (post Candidate Recommendation)</a>
+        <br/>
+    E.5 <a href="#editorial-changes">Editorial changes</a>
+        <br/>
+F <a href="#back-compatibility">Compatibility with Previous
+Versions</a> (Non-Normative)<br/>
+    F.1 <a href="#xpath1-compatibility">Compatibility between XPath
+2.0 and XPath 1.0</a>
+        <br/>
+    F.2 <a href="#xpath2-compatibility">Compatibility between XPath
+3.0 and XPath 2.0</a>
         <br/>
       </p>
     </div>
@@ -1421,14 +1453,15 @@
             <p class="prefix">
               <b>Note:</b>
             </p>
-            <p>At the time of writing there is a Candidate Recommendation of
-XML Schema 1.1 that introduces some new data types including
-<code>xs:dateTimeStamp</code>. Furthermore, XSD 1.1 includes the
-option of supporting revised definitions of types such as
-<code>xs:NCName</code> based on the rules in XML 1.1 rather than
-1.0. The rules affecting support for XSD 1.0 versus XSD 1.1 and XML
-1.0 versus XML 1.1 are likely to be refined in later drafts of this
-specification.</p>
+            <p>The XML Schema 1.1 recommendation introduces one new concrete
+data type: <code>xs:dateTimeStamp</code>; it also incorporates the
+types <code>xs:dayTimeDuration</code>,
+<code>xs:yearMonthDuration</code>, and
+<code>xs:anyAtomicType</code> which were previously defined as part
+of <a href="#xpath-datamodel-30">[XQuery and XPath Data Model (XDM)
+3.0]</a>. Furthermore, XSD 1.1 includes the option of supporting
+revised definitions of types such as <code>xs:NCName</code> based
+on the rules in XML 1.1 rather than 1.0.</p>
           </div>
           <p>In this document, text labeled as an example or as a Note is
 provided for explanatory purposes and is not normative.</p>
@@ -1460,8 +1493,8 @@
           <ul>
             <li>
               <p>
-                <code>http://www.w3.org/2001/XMLSchema</code> for constructors
--- associated with <code>xs</code>.</p>
+                <code>http://www.w3.org/2001/XMLSchema</code> for constructors —
+associated with <code>xs</code>.</p>
               <p>The section <a href="#constructor-functions">
                   <b>17 Constructor
 functions</b>
@@ -1515,6 +1548,15 @@
               </div>
             </li>
             <li>
+              <p>
+                <code>http://www.w3.org/2010/xslt-xquery-serialization</code> —
+associated with <code>output</code>.</p>
+              <p>There are no functions in this namespace: it is used for
+serialization parameters, as described in <a href="#xslt-xquery-serialization-30">[XSLT and XQuery Serialization
+3.0]</a>
+              </p>
+            </li>
+            <li>
               <p>Functions defined with the <code>op</code> prefix are described
 here to underpin the definitions of the operators in <a href="#xpath-30">[XML Path Language (XPath) 3.0]</a>, <a href="#xquery-30">[XQuery 3.0: An XML Query Language]</a> and <a href="#xslt-30">[XSL Transformations (XSLT) Version 3.0]</a>. These
 functions are not available directly to users, and there is no
@@ -1777,18 +1819,18 @@
 or unions rather than types derived by extension or
 restriction.</p>
           <p>The first diagram and its corresponding table illustrate the
-"item" type hierarchy. In XDM, items include node types, function
-types, and built-in atomic types.</p>
-          <div class="note">
-            <p class="prefix">
-              <b>Note:</b>
-            </p>
-            <p>This diagram fails to reveal that the graph of the subtype
-relationship between types is actually a lattice rather than a
-hierarchy. This is particularly evident with function types, and
-with union types: in both cases, a type may be an immediate subtype
-of several other types.</p>
-          </div>
+relationship of various item types. Item types in the data model
+form a lattice rather than a hierarchy: in the relationship defined
+by the <code>derived-from(A, B)</code> function, some types are
+derived from more than one other type. Examples include functions
+(<code>function(xs:string) as xs:int</code> is substitutable for
+<code>function(xs:NCName) as xs:int</code> and also for
+<code>function(xs:string) as xs:decimal</code>), and union types
+(<code>A</code> is substitutable for <code>union(A, B)</code> and
+also for <code>union(A, C)</code>. In XDM, item types include node
+types, function types, and built-in atomic types. The diagram,
+which shows only hierarchic relationships, is therefore a
+simplification of the full model.</p>
           <img src="XPathTypeHierarchy-1-items.png" alt="Type hierarchy graphic, item hierarchy"/>
           <p>In the table, each type whose name is indented is derived from
 the type whose name appears nearest above it with one less level of
@@ -2197,9 +2239,6 @@
               </tr>
             </tbody>
           </table>
-          <p>When XSD 1.1 is supported, one additional type needs to be added
-to these diagrams: the type <code>xs:dateTimeStamp</code>, which is
-derived from <code>xs:dateTime</code>.</p>
         </div>
         <div class="div2">
           <h3>
@@ -2463,25 +2502,24 @@
                 </a>
 is called <b>context-independent</b>.</span>
             </p>
-            <p>Functions that are context-dependent cannot be used as literal
-function items, nor can they be partially applied. For example,
-<code>position#0</code> is not valid as a literal function item,
-and <a href="#func-starts-with">
-                <code>fn:starts-with(?, ?,
-"http://example.com/collation";)</code>
-              </a> is not a valid partial
-function application. In the latter case this is because, in
-theory, the same URI might refer to different collations depending
-on the static context in which the collation URI appears. It is
-possible to circumvent this problem by writing a user-defined
-function as a simple wrapper for a call on <a href="#func-starts-with">
-                <code>fn:starts-with</code>
-              </a>, and writing a
-partial application of this user-defined function. In this way the
-static context for the call on <a href="#func-starts-with">
-                <code>fn:starts-with</code>
-              </a> is made
-unambiguous.</p>
+            <p>A function that is context-dependent can be used as a named
+function reference, can be partially applied, and can be found
+using <a href="#func-function-lookup">
+                <code>fn:function-lookup</code>
+              </a>. The
+principle in such cases is that the static context used for the
+function evaluation is taken from the static context of the named
+function reference, partial function application, or the call on
+<a href="#func-function-lookup">
+                <code>fn:function-lookup</code>
+              </a>; and
+the dynamic context for the function evaluation is taken from the
+dynamic context of the evaluation of the named function reference,
+partial function application, or the call of <a href="#func-function-lookup">
+                <code>fn:function-lookup</code>
+              </a>. In
+effect, the static and dynamic part of the context thus act as part
+of the closure of the function item.</p>
             <p>Context-dependent functions fall into a number of
 categories:</p>
             <ol class="enumar">
@@ -2608,6 +2646,19 @@
 different results.</p>
               </li>
             </ol>
+            <p>The <a href="#func-function-lookup">
+                <code>fn:function-lookup</code>
+              </a>
+function is a special case because it is potentially dependent on
+everything in the static and dynamic context. This is because the
+static and dynamic context of the call to <a href="#func-function-lookup">
+                <code>fn:function-lookup</code>
+              </a> are
+used as the static and dynamic context of the function that
+<a href="#func-function-lookup">
+                <code>fn:function-lookup</code>
+              </a>
+returns.</p>
             <p>
               <span class="termdef">
                 <a name="dt-implicit-arguments" id="dt-implicit-arguments"/>[Definition] For a <a title="context-dependent" class="termref" href="#dt-context-dependent">
@@ -2859,16 +2910,25 @@
             <dt class="label">Error Conditions</dt>
             <dd>
               <p>The following errors may be raised when <code>$arg</code> is
-omitted: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                <sup>
-                  <small>DM30</small>
-                </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
             <dt class="label">Notes</dt>
             <dd>
@@ -2958,16 +3018,25 @@
             <dt class="label">Error Conditions</dt>
             <dd>
               <p>The following errors may be raised when <code>$arg</code> is
-omitted: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                <sup>
-                  <small>DM30</small>
-                </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
             <dt class="label">Notes</dt>
             <dd>
@@ -3054,16 +3123,16 @@
             </dd>
             <dt class="label">Error Conditions</dt>
             <dd>
-              <p>An error is raised [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup> by the
-zero-argument version of the function if the context item is
+              <p>A <span>dynamic</span> error is raised [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                  <small>XP30</small>
+                </sup> by
+the zero-argument version of the function if the context item is
 <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
                 <sup>
                   <small>DM30</small>
                 </sup>.</p>
-              <p>An error is raised [<a href="#ERRFOTY0014" title="err:FOTY0014">err:FOTY0014</a>] if <code>$arg</code> is a function
-item.</p>
+              <p>A <span>type</span> error is raised [<a href="#ERRFOTY0014" title="err:FOTY0014">err:FOTY0014</a>] if <code>$arg</code> is a
+function item.</p>
             </dd>
             <dt class="label">Examples</dt>
             <dd>
@@ -3162,20 +3231,14 @@
             </dd>
             <dt class="label">Error Conditions</dt>
             <dd>
-              <p>An error is raised [<a href="#ERRFOTY0012" title="err:FOTY0012">err:FOTY0012</a>] if an item in the sequence
+              <p>A <span>type</span> error is raised [<a href="#ERRFOTY0012" title="err:FOTY0012">err:FOTY0012</a>] if an item in the sequence
 <code>$arg</code> is a node that does not have a typed value.</p>
-              <p>An error is raised [<a href="#ERRFOTY0013" title="err:FOTY0013">err:FOTY0013</a>] if an item in the sequence
+              <p>A <span>type</span> error is raised [<a href="#ERRFOTY0013" title="err:FOTY0013">err:FOTY0013</a>] if an item in the sequence
 <code>$arg</code> is a function item.</p>
-              <p>The following errors may be raised when <code>$arg</code> is
-omitted: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+              <p>A <span>dynamic</span> error is raised if <code>$arg</code> is
+omitted and the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
                 <sup>
                   <small>DM30</small>
-                </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
                 </sup>.</p>
             </dd>
             <dt class="label">Notes</dt>
@@ -3258,17 +3321,7 @@
             <dd>
               <p>The zero-argument version of the function returns the base URI
 of the context node: it is equivalent to calling
-<code>fn:base-uri(.)</code>. This may result in an error being
-raised: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                <sup>
-                  <small>DM30</small>
-                </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+<code>fn:base-uri(.)</code>.</p>
               <p>The single-argument version of the function behaves as
 follows:</p>
               <ol class="enumar">
@@ -3304,17 +3357,26 @@
             </dd>
             <dt class="label">Error Conditions</dt>
             <dd>
-              <p>If <code>$arg</code> is not specified, the following errors may
-be raised: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                <sup>
-                  <small>DM30</small>
-                </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+              <p>The following errors may be raised when <code>$arg</code> is
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
           </dl>
         </div>
@@ -3387,16 +3449,25 @@
             <dt class="label">Error Conditions</dt>
             <dd>
               <p>The following errors may be raised when <code>$arg</code> is
-omitted: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                <sup>
-                  <small>DM30</small>
-                </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
             <dt class="label">Notes</dt>
             <dd>
@@ -3603,7 +3674,8 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>This function always raises an error.</p>
+                <p>This function always raises a <span>dynamic</span> error. By
+default, it raises [<a href="#ERRFOER0000" title="err:FOER0000">err:FOER0000</a>]</p>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
@@ -3612,6 +3684,10 @@
                 <p>The type "none" is a special type defined in <a href="#xquery-semantics">[XQuery 1.0 and XPath 2.0 Formal Semantics]</a>
 and is not available to the user. It indicates that the function
 never returns and ensures that it has the correct static type.</p>
+                <p>Any QName may be used as an error code; there are no reserved
+names or namespaces. The error is always classified as a dynamic
+error, even if the error code used is one that is normally used for
+static errors or type errors.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -4013,7 +4089,7 @@
 following options:</p>
               <ul>
                 <li>
-                  <p>Raising an error [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>] via an overflow trap.</p>
+                  <p>Raising a <span>dynamic</span> error [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>] via an overflow trap.</p>
                 </li>
                 <li>
                   <p>Returning <code>INF</code> or <code>-INF</code>.</p>
@@ -4032,7 +4108,7 @@
 following options:</p>
               <ul>
                 <li>
-                  <p>Raising an error [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>] via an underflow trap.</p>
+                  <p>Raising a <span>dynamic</span> error [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>] via an underflow trap.</p>
                 </li>
                 <li>
                   <p>Returning <code>0.0E0</code> or <code>+/- 2**Emin</code> or a
@@ -4046,9 +4122,9 @@
               <p>For <code>xs:decimal</code> operations, overflow behavior
 <a title="must" class="termref" href="#must">
                   <span class="arrow">·</span>must<span class="arrow">·</span>
-                </a> raise an error
-[<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>]. On
-underflow, <code>0.0</code> must be returned.</p>
+                </a> raise a
+<span>dynamic</span> error [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>]. On underflow, <code>0.0</code>
+must be returned.</p>
             </li>
             <li>
               <p>For <code>xs:integer</code> operations, implementations that
@@ -4060,7 +4136,7 @@
                   <p>They <a title="may" class="termref" href="#may">
                       <span class="arrow">·</span>may<span class="arrow">·</span>
                     </a> choose to
-always raise an error [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>].</p>
+always raise a <span>dynamic</span> error [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>].</p>
                 </li>
                 <li>
                   <p>They <a title="may" class="termref" href="#may">
@@ -4322,21 +4398,21 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOAR0001" title="err:FOAR0001">err:FOAR0001</a>] for <code>xs:decimal</code> and
-<code>xs:integer</code> operands, if the divisor is (positive or
-negative) zero.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOAR0001" title="err:FOAR0001">err:FOAR0001</a>] for <code>xs:decimal</code>
+and <code>xs:integer</code> operands, if the divisor is (positive
+or negative) zero.</p>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
                 <p>For <code>xs:float</code> and <code>xs:double</code> operands,
-floating point division is performed as specified in <a href="#">[ieee754]</a>. A positive number divided by positive zero
-returns <code>INF</code>. A negative number divided by positive
-zero returns <code>-INF</code>. Division by negative zero returns
-<code>-INF</code> and <code>INF</code>, respectively. Positive or
-negative zero divided by positive or negative zero returns
-<code>NaN</code>. Also, <code>INF</code> or <code>-INF</code>
-divided by <code>INF</code> or <code>-INF</code> returns
-<code>NaN</code>.</p>
+floating point division is performed as specified in <a href="#ieee754-2008">[IEEE 754-2008]</a>. A positive number divided by
+positive zero returns <code>INF</code>. A negative number divided
+by positive zero returns <code>-INF</code>. Division by negative
+zero returns <code>-INF</code> and <code>INF</code>, respectively.
+Positive or negative zero divided by positive or negative zero
+returns <code>NaN</code>. Also, <code>INF</code> or
+<code>-INF</code> divided by <code>INF</code> or <code>-INF</code>
+returns <code>NaN</code>.</p>
               </dd>
             </dl>
           </div>
@@ -4400,9 +4476,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOAR0001" title="err:FOAR0001">err:FOAR0001</a>] if the divisor is (positive or
-negative) zero.</p>
-                <p>An error is raised [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>] if either operand is
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOAR0001" title="err:FOAR0001">err:FOAR0001</a>] if the divisor is (positive
+or negative) zero.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>] if either operand is
 <code>NaN</code> or if <code>$arg1</code> is <code>INF</code> or
 <code>-INF</code>.</p>
               </dd>
@@ -4507,16 +4583,16 @@
 infinity, nor positive or negative zero, nor <code>NaN</code> is
 involved, the result obeys <code>(a idiv b)*b+(a mod b)</code> =
 <code>a</code>. Division is truncating division, analogous to
-integer division, not <a href="#">[ieee754]</a> rounding division
-i.e. additional digits are truncated, not rounded to the required
-precision.</p>
+integer division, not <a href="#ieee754-2008">[IEEE 754-2008]</a>
+rounding division i.e. additional digits are truncated, not rounded
+to the required precision.</p>
                   </li>
                 </ul>
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOAR0001" title="err:FOAR0001">err:FOAR0001</a>] for <code>xs:integer</code> and
-<code>xs:decimal</code> operands, if <code>$arg2</code> is
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOAR0001" title="err:FOAR0001">err:FOAR0001</a>] for <code>xs:integer</code>
+and <code>xs:decimal</code> operands, if <code>$arg2</code> is
 zero.</p>
               </dd>
               <dt class="label">Examples</dt>
@@ -5397,29 +5473,30 @@
 give the same result as calling the single-argument version with
 the context item (<code>.</code>). That is,
 <code>fn:number()</code> is equivalent to
-<code>fn:number(.)</code>.</p>
+<code>fn:number(.)</code>, as defined by the rules that follow.</p>
                 <p>If <code>$arg</code> is the empty sequence or if
-<code>$arg</code> or the context item cannot be converted to an
-<code>xs:double</code>, the <code>xs:double</code> value
-<code>NaN</code> is returned.</p>
-                <p>Otherwise, <code>$arg</code>, or the context item after
-atomization, is converted to an <code>xs:double</code> following
-the rules of <a href="#casting-to-double">
-                    <b>18.1.2.2 Casting to
-xs:double</b>
-                  </a>. If the conversion to <code>xs:double</code>
-fails, the <code>xs:double</code> value <code>NaN</code> is
-returned.</p>
+<code>$arg</code> cannot be converted to an <code>xs:double</code>,
+the <code>xs:double</code> value <code>NaN</code> is returned.</p>
+                <p>Otherwise, <code>$arg</code> is converted to an
+<code>xs:double</code> following the rules of <a href="#casting-to-double">
+                    <b>18.1.2.2 Casting to xs:double</b>
+                  </a>. If
+the conversion to <code>xs:double</code> fails, the
+<code>xs:double</code> value <code>NaN</code> is returned.</p>
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                    <small>XP</small>
+                <p>A <span>dynamic</span> error is raised [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                    <small>XP30</small>
                   </sup> if
 <code>$arg</code> is omitted and the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
                   <sup>
                     <small>DM30</small>
                   </sup>.</p>
+                <p>As a consequence of the rules given above, a type error occurs
+if the context item cannot be atomized, or if the result of
+atomizing the context item is a sequence containing more than one
+atomic value.</p>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
@@ -5427,6 +5504,12 @@
 of positive infinity; XSD 1.0 does not. It is <a title="implementation-defined" class="termref" href="#implementation-defined">
                     <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
                   </a> whether XSD 1.1 is supported.</p>
+                <p>Generally <code>fn:number</code> returns <code>NaN</code> rather
+than raising a dynamic error if the argument cannot be converted to
+<code>xs:double</code>. However, a type error is raised in the
+usual way if the supplied argument cannot be atomized or if the
+result of atomization does not match the required argument
+type.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -5489,7 +5572,7 @@
                       </tr>
                       <tr>
                         <td valign="baseline">
-                          <code class="arg">$language</code>
+                          <code class="arg">$lang</code>
                         </td>
                         <td valign="baseline">
                           <code class="as"> as </code>
@@ -5503,7 +5586,17 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on default language.</p>
+                <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
 <a title="context-independent" class="termref" href="#dt-context-independent">
@@ -5522,18 +5615,16 @@
 output. If the value of <code>$value</code> is negative, the rules
 below are applied to the absolute value of <code>$value</code>, and
 a minus sign is prepended to the result.</p>
-                <p>The value of <code>$picture</code>
-                  <strong>must</strong> match
-the regular expression:</p>
-                <p>
-                  <code>^((\p{Nd}|#|[^\p{N}\p{L}])+?)(([co](\([^()]\))?)?[at]?)$</code>
-                </p>
-                <p>The substring that matches the first capturing group in this
-regular expression are referred to as the primary format token. The
-substring that matches the second capturing group (which may be
-empty) is referred to as the format modifier. A picture thus
-consists of a primary format token, followed by an optional format
-modifier.</p>
+                <p>The value of <code>$picture</code> consists of a primary format
+token, optionally followed by a format modifier. The primary format
+token is always present and <strong>must not</strong> be
+zero-length. If the string contains one or more semicolons then
+everything that precedes the last semicolon is taken as the primary
+format token and everything that follows is taken as the format
+modifier; if the string contains no semicolon then the entire
+picture is taken as the primary format token, and the format
+modifier is taken to be absent (which is equivalent to supplying a
+zero-length string).</p>
                 <p>The primary format token is classified as one of the
 following:</p>
                 <ul>
@@ -5550,12 +5641,12 @@
                             <span class="arrow">·</span>character<span class="arrow">·</span>
                           </a> in
 Unicode category Nd. All <var>mandatory-digit-signs</var> within
-the format token must be from the same digit family, where a digit
-family is a sequence of ten consecutive characters in Unicode
-category Nd, having digit values 0 through 9. Within the format
-token, these digits are interchangeable: a three-digit number may
-thus be indicated equivalently by <code>000</code>,
-<code>001</code>, or <code>999</code>.</p>
+the format token <strong>must</strong> be from the same digit
+family, where a digit family is a sequence of ten consecutive
+characters in Unicode category Nd, having digit values 0 through 9.
+Within the format token, these digits are interchangeable: a
+three-digit number may thus be indicated equivalently by
+<code>000</code>, <code>001</code>, or <code>999</code>.</p>
                       </li>
                       <li>
                         <p>a <var>grouping-separator-sign</var> is a non-alphanumeric
@@ -5565,6 +5656,22 @@
 No, Lu, Ll, Lt, Lm or Lo.</p>
                       </li>
                     </ul>
+                    <p>If the primary format token contains at least one Unicode digit
+then it is taken as a decimal digit pattern, and in this case it
+<strong>must</strong> match the regular expression
+<code>^((\p{Nd}|#|[^\p{N}\p{L}])+?)$</code>. If it contains a digit
+but does not match this pattern, a <span>dynamic</span> error is
+raised [<a href="#ERRFODF1310" title="err:FODF1310">err:FODF1310</a>].</p>
+                    <div class="note">
+                      <p class="prefix">
+                        <b>Note:</b>
+                      </p>
+                      <p>If a semicolon is to be used as a grouping separator, then the
+primary format token as a whole must be followed by another
+semicolon, to ensure that the grouping separator is not mistaken as
+a separator between the primary format token and the format
+modifier.</p>
+                    </div>
                     <p>There <strong>must</strong> be at least one
 <var>mandatory-digit-sign</var>. There may be zero or more
 <var>optional-digit-signs</var>, and (if present) these
@@ -5687,12 +5794,14 @@
 that can be formatted using this format token; indeed, for some
 numbering sequences there may be intrinsic limits. For example, the
 format token <code>&amp;#x2460;</code> (circled digit one, ①) has a
-range of 1 to 20 imposed by the Unicode character repertoire. For
-the numbering sequences described above any upper bound imposed by
-the implementation <strong>must not</strong> be less than 1000 (one
-thousand) and any lower bound must not be greater than 1. Numbers
-that fall outside this range <strong>must</strong> be formatted
-using the format token <code>1</code>.</p>
+range <span>imposed by the Unicode character repertoire — 1 to 20
+in Unicode versions prior to 4.0, increased in subsequent
+versions</span>. For the numbering sequences described above any
+upper bound imposed by the implementation <strong>must not</strong>
+be less than 1000 (one thousand) and any lower bound must not be
+greater than 1. Numbers that fall outside this range
+<strong>must</strong> be formatted using the format token
+<code>1</code>.</p>
                 <p>The above expansions of numbering sequences for format tokens
 such as <code>a</code> and <code>i</code> are indicative but not
 prescriptive. There are various conventions in use for how
@@ -5710,23 +5819,27 @@
 sequences, for example different languages using the Cyrillic
 alphabet use different sequences of characters, each starting with
 the letter #x410 (Cyrillic capital letter A). In such cases, the
-<code>$language</code> argument specifies which language's
-conventions are to be used. <span>If the argument is specified, the
-value <strong>should</strong> be a string that is castable to the
-type <code>xs:language</code>
-                  </span>.</p>
+<code>$lang</code> argument specifies which language's conventions
+are to be used. <span>If the argument is specified, the value
+<strong>should</strong> be either an empty sequence or a value that
+would be valid for the <code>xml:lang</code> attribute (see
+<a href="#REC-xml">[REC-xml]</a>). Note that this permits the
+identification of sublanguages based on country codes (from ISO
+3166-1) as well as identification of dialects and regions within a
+country.</span>.</p>
                 <p>The set of languages for which numbering is supported is
 <a title="implementation-defined" class="termref" href="#implementation-defined">
                     <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-                  </a>. If the <code>$language</code> argument is
-absent, or is set to an empty sequence, or is invalid, or is not a
-language supported by the implementation, then the number is
-formatted using a default language; the default language is
-<a title="implementation-defined" class="termref" href="#implementation-defined">
-                    <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-                  </a>.</p>
-                <p>The format modifier, if present, is one <span>or more</span> of
-the following, in order:</p>
+                  </a>. If the <code>$lang</code> argument is absent,
+or is set to an empty sequence, or is invalid, or is not a language
+supported by the implementation, then the number is formatted using
+<span>the default language from the dynamic context</span>.</p>
+                <p>The format modifier <span>
+                    <strong>must</strong> be a string that
+matches the regular expression
+<code>^([co](\(.+\))?)?[at]?$</code>.</span> That is, if it is
+present it must consist of one <span>or more</span> of the
+following, in order:</p>
                 <ul>
                   <li>
                     <p>either <code>c</code> or <code>o</code>, optionally followed by
@@ -5748,17 +5861,24 @@
 ...</code>, and when used with the format token <code>w</code>
 outputs the sequence <code>first second third fourth
 ...</code>.</p>
-                <p>In some languages, ordinal numbers vary depending on the
-grammatical context, for example they may have different genders
-and may decline with the noun that they qualify. In such cases the
-string appearing in parentheses after the letter <code>o</code> may
-be used to indicate the variation of the ordinal number required.
-The way in which the variation is indicated will depend on the
+                <p>The string of characters between the parentheses, if present, is
+used to select between other possible variations of cardinal or
+ordinal numbering sequences. The interpretation of this string is
+<a title="" class="termref" href="#">
+                    <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+                  </a>. No error occurs if the implementation does
+not define any interpretation for the defined string.</p>
+                <p>For example, in some languages, ordinal numbers vary depending
+on the grammatical context: they may have different genders and may
+decline with the noun that they qualify. In such cases the string
+appearing in parentheses after the letter <code>o</code> may be
+used to indicate the variation of the ordinal number required. The
+way in which the variation is indicated will depend on the
 conventions of the language. For inflected languages that vary the
-ending of the word, the preferred approach is to indicate the
-required ending, preceded by a hyphen: for example in German,
-appropriate values are <code>o(-e)</code>, <code>o(-er)</code>,
-<code>o(-es)</code>, <code>o(-en)</code>.</p>
+ending of the word, the <strong>recommended</strong> approach is to
+indicate the required ending, preceded by a hyphen: for example in
+German, appropriate values are <code>o(-e)</code>,
+<code>o(-er)</code>, <code>o(-es)</code>, <code>o(-en)</code>.</p>
                 <p>It is <a title="implementation-defined" class="termref" href="#implementation-defined">
                     <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
                   </a> what combinations of values of the format
@@ -5769,16 +5889,16 @@
 numbers are generated instead.</p>
                 <div class="exampleOuter">
                   <div class="exampleHeader">
-                    <a name="d5e6102" id="d5e6102"/>Example: Ordinal Numbering in Italian</div>
-                  <p>The specification <code>"1o(-º)"</code> with
-<code>$language</code> equal to <code>it</code>, if supported,
-should produce the sequence:</p>
+                    <a name="d5e6328" id="d5e6328"/>Example: Ordinal Numbering in Italian</div>
+                  <p>The specification <code>"1;o(-º)"</code> with <code>$lang</code>
+equal to <code>it</code>, if supported, should produce the
+sequence:</p>
                   <div class="exampleInner">
                     <pre>
 1º 2º 3º 4º ...
 </pre>
                   </div>
-                  <p>The specification <code>"Wwo"</code> with <code>$language</code>
+                  <p>The specification <code>"Ww;o"</code> with <code>$lang</code>
 equal to <code>it</code>, if supported, should produce the
 sequence:</p>
                   <div class="exampleInner">
@@ -5803,6 +5923,25 @@
                     </a>
                   </span>.</p>
               </dd>
+              <dt class="label">Error Conditions</dt>
+              <dd>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODF1310" title="err:FODF1310">err:FODF1310</a>] if the format token is
+invalid, that is, if it violates any mandatory rules (indicated by
+an emphasized <strong>must</strong> or <strong>required</strong>
+keyword in the above rules). For example, the error is raised if
+the primary format token contains a digit but does not match the
+required regular expression.</p>
+              </dd>
+              <dt class="label">Notes</dt>
+              <dd>
+                <p>Note the careful distinction between conditions that are errors
+and conditions where fallback occurs. The principle is that an
+error in the syntax of the format picture will be reported by all
+processors, while a construct that is recognized by some
+implementations but not others will never result in an error, but
+will instead cause a fallback representation of the integer to be
+used.</p>
+              </dd>
               <dt class="label">Examples</dt>
               <dd>
                 <p>The expression <code>format-integer(123, '0000')</code> returns
@@ -5811,16 +5950,18 @@
                   <code>format-integer(123, 'w')</code> might return <code>"one
 hundred and twenty-three"</code>
                 </p>
-                <p>The expression <code>format-integer(21, '1o', 'en')</code>
+                <p>The expression <code>format-integer(21, '1;o', 'en')</code>
 returns <code>"21st"</code>.</p>
                 <p>
-                  <code>format-integer(14, 'Wwo(-e)', 'de')</code> might return
+                  <code>format-integer(14, 'Ww;o(-e)', 'de')</code> might return
 <code>"Vierzehnte"</code>
                 </p>
                 <p>The expression <code>format-integer(7, 'a')</code> returns
 <code>"g"</code>.</p>
                 <p>The expression <code>format-integer(57, 'I')</code> returns
 <code>"LVII"</code>.</p>
+                <p>The expression <code>format-integer(1234, '#;##0;')</code>
+returns <code>"1;234"</code>.</p>
               </dd>
             </dl>
           </div>
@@ -5873,9 +6014,11 @@
             <p>The static context provides a set of decimal formats. One of the
 decimal formats is unnamed, the others (if any) are identified by a
 QName. There is always an unnamed decimal format available, but its
-contents are implementation-defined.</p>
-            <p>Each decimal format provides a set of named variables, described
-in the following table:</p>
+contents are <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>.</p>
+            <p>Each decimal format provides a set of named
+<span>properties</span>, described in the following table:</p>
             <table summary="A table [this is bad style]" border="1">
               <thead>
                 <tr>
@@ -5958,13 +6101,15 @@
                   <td valign="top">mandatory-digit-sign</td>
                   <td valign="top">A single <a title="character" class="termref" href="#character">
                       <span class="arrow">·</span>character<span class="arrow">·</span>
-                    </a>, which must be defined in Unicode as a
-digit</td>
-                  <td valign="top">Defines the character (typically "0") used in the
-picture string to represent a mandatory digit, and in the formatted
-number to represent the digit zero; by implication, this also
-defines the characters used to represent the digits one to
-nine.</td>
+                    </a>, which must be <span>a character in Unicode
+category Nd with decimal digit value 0 (zero)</span>
+                  </td>
+                  <td valign="top">Defines the characters used in the picture string
+to represent a mandatory digit: for example, if the
+mandatory-digit-sign is "0" then any of the digits "0" to "9" may
+be used (interchangeably) in the picture string to represent a
+mandatory digit, and in the formatted number the characters "0" to
+"9" will be used to represent the digits one to nine.</td>
                 </tr>
                 <tr>
                   <td valign="top">optional-digit-sign</td>
@@ -5997,17 +6142,20 @@
 <var>mandatory-digit-sign</var>.</span>
             </p>
             <p>It is a constraint that, for any named or unnamed decimal
-format, the variables representing characters used in a <a title="picture string" class="termref" href="#dt-picture-string">
+format, the <span>properties</span> representing characters used in
+a <a title="picture string" class="termref" href="#dt-picture-string">
                 <span class="arrow">·</span>picture
 string<span class="arrow">·</span>
               </a> must have distinct values.
-These variables are <var>decimal-separator-sign</var>,
+These <span>properties</span> are
+<var>decimal-separator-sign</var>,
 <var>grouping-separator-sign</var>, <var>percent-sign</var>,
 <var>per-mille-sign</var>, <var>optional-digit-sign</var>, and
 <var>pattern-separator-sign</var>. Furthermore, none of these
-variables may be equal to any <a title="character" class="termref" href="#character">
+<span>properties</span> may be equal to any <a title="character" class="termref" href="#character">
                 <span class="arrow">·</span>character<span class="arrow">·</span>
-              </a> in the <a title="digit family" class="termref" href="#dt-decimal-digit-family">
+              </a> in the
+<a title="digit family" class="termref" href="#dt-decimal-digit-family">
                 <span class="arrow">·</span>decimal
 digit family<span class="arrow">·</span>
               </a>.</p>
@@ -6089,7 +6237,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on decimal-formats and namespaces.</p>
+It depends on decimal formats, and namespaces.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -6120,10 +6268,23 @@
 the <code>xs:double</code> value <code>NaN</code>.</p>
                 <p>The value of <code>$decimal-format-name</code>, <span>if present
 and non-empty,</span>
-                  <strong>must</strong> be a lexical QName,
-which is expanded using the <span>statically known
-namespaces</span>. The default namespace is not used (no prefix
-means no namespace).</p>
+                  <strong>must</strong>
+                  <span>be a string which
+after removal of leading and trailing whitespace is in the form of
+an an <code>EQName</code> as defined in the XPath 3.0 grammar, that
+is one of the following</span>:</p>
+                <ul>
+                  <li>
+                    <p>A lexical QName, which is expanded using the <span>statically
+known namespaces</span>. The default namespace is not used (no
+prefix means no namespace).</p>
+                  </li>
+                  <li>
+                    <p>A <code>URIQualifiedName</code> using the syntax
+<code>Q{uri}local</code>, where the URI can be zero-length to
+indicate a name in no namespace.</p>
+                  </li>
+                </ul>
                 <p>The decimal format that is used is the decimal format in the
 static context whose name matches <code>$decimal-format-name</code>
 if supplied, or the default decimal format in the static context
@@ -6151,9 +6312,11 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODF1280" title="err:FODF1280">err:FODF1280</a>] if the name specified as the
-<code>$decimal-format-name</code> argument is not a valid lexical
-QName, or if its prefix <span>is not found in the statically known
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODF1280" title="err:FODF1280">err:FODF1280</a>] if the name specified as the
+<code>$decimal-format-name</code> argument is <span>neither a valid
+lexical QName nor a valid <code>URIQualifiedName</code>
+                  </span>, or
+if it uses a prefix <span>that is not found in the statically known
 namespaces</span>, or if the static context does not contain a
 declaration of a decimal-format with a matching expanded QName. If
 the processor is able to detect the error statically (for example,
@@ -6168,8 +6331,25 @@
               </dd>
               <dt class="label">Examples</dt>
               <dd>
-                <p>The expression <code>format-number(12345.6, '#.###,00')</code>
-returns <code>"12.345,00"</code>.</p>
+                <p>The following examples assume a default decimal format in which
+the chosen digits are the ASCII digits 0-9, the decimal separator
+is ".", the grouping separator is ",", the minus-sign is "-", and
+the percent-sign is "%".</p>
+                <p>The expression <code>format-number(12345.6, '#,###.00')</code>
+returns <code>"12,345.60"</code>.</p>
+                <p>The expression <code>format-number(12345678.9,
+'9,999.99')</code> returns <code>"12,345,678.90"</code>.</p>
+                <p>The expression <code>format-number(123.9, '9999')</code> returns
+<code>"0124"</code>.</p>
+                <p>The expression <code>format-number(0.14, '01%')</code> returns
+<code>"14%"</code>.</p>
+                <p>The expression <code>format-number(-6, '000')</code> returns
+<code>"-006"</code>.</p>
+                <p>The following example assumes the existence of a decimal format
+named 'ch' in which the grouping separator is <code>ʹ</code> and
+the decimal separator is <code>·</code>:</p>
+                <p>The expression <code>format-number(1234.5678, '#ʹ##0·00',
+'ch')</code> returns <code>"1ʹ234·57"</code>.</p>
               </dd>
             </dl>
           </div>
@@ -6184,8 +6364,11 @@
               <p>This differs from the <code>format-number</code> function
 previously defined in XSLT 2.0 in that any digit can be used in the
 picture string to represent a mandatory digit: for example the
-picture strings '000', '001', and '999' are equivalent. This is to
-align <code>format-number</code> (which previously used '000') with
+picture strings '000', '001', and '999' are equivalent. <span>The
+digits used must all be from the same decimal digit family,
+specifically, the sequence of ten consecutive digits starting with
+the <var>mandatory-digit-sign</var>.</span> This change is to align
+<code>format-number</code> (which previously used '000') with
 <code>format-dateTime</code> (which used '001').</p>
             </div>
             <p>
@@ -6195,7 +6378,8 @@
 sequence of <a title="character" class="termref" href="#character">
                   <span class="arrow">·</span>characters<span class="arrow">·</span>
                 </a>, in which the characters assigned to the
-variables <var>decimal-separator-sign</var>,
+<span>properties</span>
+                <var>decimal-separator-sign</var>,
 <var>grouping-sign</var>, <var>decimal-digit-family</var>,
 <var>optional-digit-sign</var> and
 <var>pattern-separator-sign</var> are classified as active
@@ -6208,15 +6392,19 @@
 <var>decimal-separator-sign</var> if there is one, or the entire
 sub-picture otherwise. The <var>fractional part</var> of the
 sub-picture is defined as the part that appears to the right of the
-<var>decimal-separator-sign</var> if there is one; it is a
-zero-length string otherwise.</p>
-            <p>An error is raised [<a href="#ERRFODF1310" title="err:FODF1310">err:FODF1310</a>] if the <a title="picture string" class="termref" href="#dt-picture-string">
-                <span class="arrow">·</span>picture string<span class="arrow">·</span>
-              </a> does
-not conform to the following rules. Note that in these rules the
-words "preceded" and "followed" refer to characters anywhere in the
-string, they are not to be read as "immediately preceded" and
-"immediately followed".</p>
+<var>decimal-separator-sign</var>
+              <span>if there is one, or the
+part that appears to the right of the rightmost active character
+otherwise. The fractional part may be zero-length.</span>
+            </p>
+            <p>A <span>dynamic</span> error is raised [<a href="#ERRFODF1310" title="err:FODF1310">err:FODF1310</a>] if the <a title="picture string" class="termref" href="#dt-picture-string">
+                <span class="arrow">·</span>picture
+string<span class="arrow">·</span>
+              </a> does not conform to the
+following rules. Note that in these rules the words "preceded" and
+"followed" refer to characters anywhere in the string, they are not
+to be read as "immediately preceded" and "immediately
+followed".</p>
             <ul>
               <li>
                 <p>A picture-string consists either of a sub-picture, or of two
@@ -6267,12 +6455,12 @@
             <p>This phase of the algorithm analyses the <a title="picture string" class="termref" href="#dt-picture-string">
                 <span class="arrow">·</span>picture
 string<span class="arrow">·</span>
-              </a> and the variables from the
-selected decimal format in the static context, and it has the
-effect of setting the values of various variables, which are used
-in the subsequent formatting phase. These variables are listed
-below. Each is shown with its initial setting and its data
-type.</p>
+              </a> and the
+<span>properties</span> from the selected decimal format in the
+static context, and it has the effect of setting the values of
+various variables, which are used in the subsequent formatting
+phase. These variables are listed below. Each is shown with its
+initial setting and its data type.</p>
             <p>Several variables are associated with each sub-picture. If there
 are two sub-pictures, then these rules are applied to one
 sub-picture to obtain the values that apply to positive numbers,
@@ -6336,6 +6524,16 @@
 characters that appear within the fractional part of the
 sub-picture and to the left of the
 <var>grouping-separator-sign</var>.</p>
+                <div class="note">
+                  <p class="prefix">
+                    <b>Note:</b>
+                  </p>
+                  <p>There is no need to extrapolate grouping positions on the
+fractional side, because the number of digits in the output will
+never exceed the number of <var>optional-digit-sign</var> and
+<var>decimal-digit-family</var> in the fractional part of the
+sub-picture.</p>
+                </div>
               </li>
               <li>
                 <p>The <var>minimum-fractional-part-size</var> is set to the number
@@ -6350,8 +6548,8 @@
               </li>
               <li>
                 <p>The <var>suffix</var> is set to contain all passive characters
-to the right of the rightmost active character in the fractional
-part of the sub-picture.</p>
+to the right of the rightmost active character in the
+sub-picture.</p>
               </li>
             </ul>
             <div class="note">
@@ -6531,6 +6729,15 @@
 information is outside the scope of this specification.</p>
             </li>
             <li>
+              <p>IEEE defines various rounding algorithms for inexact results,
+and states that the choice of rounding direction, and the
+mechanisms for influencing this choice, are language-defined. In
+this specification, the rounding direction and any mechanisms for
+influencing it are <a title="implementation-defined" class="termref" href="#implementation-defined">
+                  <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+                </a>.</p>
+            </li>
+            <li>
               <p>Certain operations (such as taking the square root of a negative
 number) are defined in IEEE to signal the invalid operation
 exception and return a quiet NaN. In this specification, such
@@ -7791,8 +7998,8 @@
                     <b>4.2 Arithmetic operators on numeric
 values</b>
                   </a>.</p>
-                <p>If <code>$arg</code> is <code>NaN</code> then the result is
-<code>NaN</code>.</p>
+                <p>If <span>either argument</span> is <code>NaN</code> then the
+result is <code>NaN</code>.</p>
                 <p>If <code>$y</code> is positive and <code>$x</code> is positive
 and finite, then (subject to rules for overflow, underflow and
 approximation) the value of <code>atan2($y, $x)</code> is
@@ -7998,7 +8205,7 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOCH0001" title="err:FOCH0001">err:FOCH0001</a>] if any of the codepoints in
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOCH0001" title="err:FOCH0001">err:FOCH0001</a>] if any of the codepoints in
 <code>$arg</code> is not a permitted XML character.</p>
               </dd>
               <dt class="label">Examples</dt>
@@ -8162,9 +8369,9 @@
 functions. Functions that allow specification of a collation do so
 with an argument whose type is <code>xs:string</code> but whose
 lexical form must conform to an <code>xs:anyURI</code>. If the
-collation is specified using a relative URI, it is assumed to be
-relative to the value of the <span>Dynamic Base URI property from
-the dynamic context</span>. This specification also defines the
+collation is specified using a relative URI reference, <span>it is
+resolved relative to the value of the Static Base URI property from
+the static context</span>. This specification also defines the
 manner in which a default collation is determined if the collation
 argument is not specified in calls of functions that use a
 collation but allow it to be omitted.</p>
@@ -8307,7 +8514,7 @@
 CollationA is used.</p>
                   </li>
                   <li>
-                    <p>Otherwise, an error is raised [<a href="#ERRFOCH0002" title="err:FOCH0002">err:FOCH0002</a>].</p>
+                    <p>Otherwise, a <span>dynamic</span> error is raised [<a href="#ERRFOCH0002" title="err:FOCH0002">err:FOCH0002</a>].</p>
                   </li>
                 </ul>
               </li>
@@ -8321,7 +8528,7 @@
 CollationB is used.</p>
                   </li>
                   <li>
-                    <p>Otherwise, an error is raised [<a href="#ERRFOCH0002" title="err:FOCH0002">err:FOCH0002</a>].</p>
+                    <p>Otherwise, a <span>dynamic</span> error is raised [<a href="#ERRFOCH0002" title="err:FOCH0002">err:FOCH0002</a>].</p>
                   </li>
                 </ul>
               </li>
@@ -8398,7 +8605,7 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
 <a title="context-dependent" class="termref" href="#dt-context-dependent">
@@ -8408,6 +8615,16 @@
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
 It depends on collations.</p>
+                <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -9118,8 +9335,8 @@
                   <sup>
                     <small>DM30</small>
                   </sup>,
-an error is raised: [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                    <small>XP</small>
+a <span>dynamic</span> error is raised: [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                    <small>XP30</small>
                   </sup>.</p>
               </dd>
               <dt class="label">Notes</dt>
@@ -9207,8 +9424,8 @@
                   <sup>
                     <small>DM30</small>
                   </sup>
-then an error is raised: [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                    <small>XP</small>
+then a <span>dynamic</span> error is raised: [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                    <small>XP30</small>
                   </sup>.</p>
               </dd>
               <dt class="label">Notes</dt>
@@ -9333,7 +9550,7 @@
                 </ul>
                 <p>Normalization forms NFC, NFD, NFKC, and NFKD, and the algorithms
 to be used for converting a string to each of these forms, are
-defined in <a href="#Unicode-Normalization">[Unicode Normaliation
+defined in <a href="#Unicode-Normalization">[Unicode Normalization
 Forms]</a>.</p>
                 <p>The motivation for normalization form FULLY-NORMALIZED is
 explained in <a href="#charmod-normalization">[Character Model for
@@ -9343,7 +9560,7 @@
                 <ul>
                   <li>
                     <p>A string is <b>fully-normalized</b> if (a) it is in
-normalization form NFC as defined in <a href="#Unicode-Normalization">[Unicode Normaliation Forms]</a>, and (b)
+normalization form NFC as defined in <a href="#Unicode-Normalization">[Unicode Normalization Forms]</a>, and (b)
 it does not start with a composing character.</p>
                   </li>
                   <li>
@@ -9354,7 +9571,7 @@
                         <p>the second character in the canonical decomposition mapping of
 some character that is not listed in the Composition Exclusion
 Table defined in <a href="#Unicode-Normalization">[Unicode
-Normaliation Forms]</a>;</p>
+Normalization Forms]</a>;</p>
                       </li>
                       <li>
                         <p>of non-zero canonical combining class (as defined in <a href="#Unicode">[The Unicode Standard]</a>).</p>
@@ -9381,12 +9598,25 @@
 with <a title="implementation-defined" class="termref" href="#implementation-defined">
                     <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
                   </a> semantics.</p>
+                <p>It is <a title="" class="termref" href="#">
+                    <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+                  </a> which version of Unicode (and therefore, of
+the normalization algorithms and their underlying data) is
+supported by the implementation. See <a href="#Unicode-Normalization">[Unicode Normalization Forms]</a> for
+details of the stability policy regarding changes to the
+normalization rules in future versions of Unicode. If the input
+string contains codepoints that are unassigned in the relevant
+version of Unicode, or for which no normalization rules are
+defined, the <code>fn:normalize-unicode</code> function leaves such
+codepoints unchanged. If the implementation supports the requested
+normalization form then it <strong>must</strong> be able to handle
+every input string without raising an error.</p>
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOCH0003" title="err:FOCH0003">err:FOCH0003</a>] if the effective value of the
-<code>$normalizationForm</code> argument is not one of the values
-supported by the implementation.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOCH0003" title="err:FOCH0003">err:FOCH0003</a>] if the effective value of
+the <code>$normalizationForm</code> argument is not one of the
+values supported by the implementation.</p>
               </dd>
             </dl>
           </div>
@@ -9903,7 +10133,7 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
 <a title="context-dependent" class="termref" href="#dt-context-dependent">
@@ -9913,6 +10143,16 @@
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
 It depends on collations.</p>
+                <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -9944,8 +10184,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error <strong>may</strong> be raised [<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if the specified collation
-does not support collation units.</p>
+                <p>A <span>dynamic</span> error <strong>may</strong> be raised
+[<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if
+the specified collation does not support collation units.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -10041,7 +10282,7 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
 <a title="context-dependent" class="termref" href="#dt-context-dependent">
@@ -10051,6 +10292,16 @@
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
 It depends on collations.</p>
+                <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -10082,8 +10333,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error <strong>may</strong> be raised [<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if the specified collation
-does not support collation units.</p>
+                <p>A <span>dynamic</span> error <strong>may</strong> be raised
+[<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if
+the specified collation does not support collation units.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -10180,7 +10432,7 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
 <a title="context-dependent" class="termref" href="#dt-context-dependent">
@@ -10190,6 +10442,16 @@
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
 It depends on collations.</p>
+                <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -10221,8 +10483,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error <strong>may</strong> be raised [<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if the specified collation
-does not support collation units.</p>
+                <p>A <span>dynamic</span> error <strong>may</strong> be raised
+[<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if
+the specified collation does not support collation units.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -10318,7 +10581,7 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
 <a title="context-dependent" class="termref" href="#dt-context-dependent">
@@ -10328,6 +10591,16 @@
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
 It depends on collations.</p>
+                <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -10359,8 +10632,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error <strong>may</strong> be raised [<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if the specified collation
-does not support collation units.</p>
+                <p>A <span>dynamic</span> error <strong>may</strong> be raised
+[<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if
+the specified collation does not support collation units.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -10453,7 +10727,7 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
 <a title="context-dependent" class="termref" href="#dt-context-dependent">
@@ -10463,6 +10737,16 @@
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
 It depends on collations.</p>
+                <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -10494,8 +10778,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error <strong>may</strong> be raised [<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if the specified collation
-does not support collation units.</p>
+                <p>A <span>dynamic</span> error <strong>may</strong> be raised
+[<a href="#ERRFOCH0004" title="err:FOCH0004">err:FOCH0004</a>] if
+the specified collation does not support collation units.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -10632,6 +10917,9 @@
                 <p>
                   <code>[10] Char ::= [^.\?*+{}()|^$#x5B#x5D]</code>
                 </p>
+                <p>The XSD 1.1 grammar for regular expressions uses the same
+production rule, but renumbered and renamed <code>[73]
+NormalChar</code>; it is affected in the same way.</p>
                 <p>The characters <code>#x5B</code> and <code>#x5D</code>
 correspond to "<code>[</code>" and "<code>]</code>"
 respectively.</p>
@@ -10653,6 +10941,17 @@
                   <code>[11] charClass ::= charClassEsc | charClassExpr |
 WildCardEsc | "^" | "$"</code>
                 </p>
+                <p>Using XSD 1.1 as the baseline the equivalent is to change the
+production:</p>
+                <p>
+                  <code>[74] charClass ::= SingleCharEsc | charClassEsc |
+charClassExpr | WildCardEsc</code>
+                </p>
+                <p>to read:</p>
+                <p>
+                  <code>[74] charClass ::= SingleCharEsc | charClassEsc |
+charClassExpr | WildCardEsc | "^" | "$"</code>
+                </p>
               </li>
               <li>
                 <p>
@@ -10700,6 +10999,8 @@
                   <code>[4] quantifier ::= ( [?*+] | ( '{' quantity '}' ) )
 '?'?</code>
                 </p>
+                <p>(In the XSD 1.1 version of the regular expression grammar, this
+rule is unchanged, but is renumbered [67])</p>
                 <div class="note">
                   <p class="prefix">
                     <b>Note:</b>
@@ -10716,34 +11017,45 @@
                 <p>Sub-expressions (groups) within the regular expression are
 recognized. The regular expression syntax defined by <a href="#xmlschema-2">[XML Schema Part 2: Datatypes Second Edition]</a>
 allows a regular expression to contain parenthesized
-sub-expressions, but attaches no special significance to them. The
-<a href="#func-replace">
-                    <code>fn:replace</code>
-                  </a> function
-described below allows access to the parts of the input string that
-matched a sub-expression (called captured substrings). The
-sub-expressions are numbered according to the position of the
-opening parenthesis in left-to-right order within the top-level
-regular expression: the first opening parenthesis identifies
-captured substring 1, the second identifies captured substring 2,
-and so on. 0 identifies the substring captured by the entire
-regular expression. If a sub-expression matches more than one
-substring (because it is within a construct that allows
-repetition), then only the <em>last</em> substring that it matched
-will be captured.</p>
+sub-expressions, but attaches no special significance to them.
+<span>Some operations associated with regular expressions (for
+example, back-references, and the <a href="#func-replace">
+                      <code>fn:replace</code>
+                    </a> function) allow access
+to the parts of the input string that matched a sub-expression
+(called captured substrings).</span> The sub-expressions are
+numbered according to the position of the opening parenthesis in
+left-to-right order within the top-level regular expression: the
+first opening parenthesis identifies captured substring 1, the
+second identifies captured substring 2, and so on. 0 identifies the
+substring captured by the entire regular expression.</p>
+                <p>When parentheses are used in a part of the regular expression
+that is matched more than once (because it is within a construct
+that allows repetition), then only the last substring that it
+matched will be captured. Note that this rule is not sufficient in
+all cases to ensure an unambiguous result, especially in cases
+where (a) the regular expression contains nested repeating
+constructs, and/or (b) the repeating construct matches a
+zero-length string. In such cases it is implementation-dependent
+which substring is captured. For example given the regular
+expression <code>(a*)+</code> and the input string
+<code>"aaaa"</code>, an implementation might legitimately capture
+either <code>"aaaa"</code> or a zero length string as the content
+of the captured subgroup.</p>
                 <p>Non-capturing groups are also recognized. These are indicated by
-the syntax <code>(?:xxxx)</code>. Specifically, the production rule
-for <code>atom</code> in <a href="#xmlschema-2">[XML Schema Part 2:
-Datatypes Second Edition]</a> is changed from:</p>
-                <p>
-                  <code>[9] atom ::= Char | charClass | ( '(' regExp ')'
-)</code>
-                </p>
-                <p>to:</p>
-                <p>
-                  <code>[9] atom ::= Char | charClass | ( '(' '?:'? regExp ')'
-)</code>
-                </p>
+the syntax <code>(?:xxxx)</code>. The production rule for
+<code>atom</code> in <a href="#xmlschema-2">[XML Schema Part 2:
+Datatypes Second Edition]</a> is changed to replace the
+alternative:</p>
+                <p>
+                  <code>( '(' regExp ')' )</code>
+                </p>
+                <p>with:</p>
+                <p>
+                  <code>( '(' '?:'? regExp ')' )</code>
+                </p>
+                <p>(For the new versions of the XSD 1.0 and XSD 1.1 production
+rules for <code>atom</code>, see below.)</p>
                 <p>The presence of the optional <code>?:</code> has no effect on
 the set of strings that match the regular expression, but causes
 the left parenthesis not to be counted by operations that number
@@ -10775,7 +11087,9 @@
                 <p>If no string is matched by the <code>N</code>th capturing
 subexpression, the back-reference is interpreted as matching a
 zero-length string.</p>
-                <p>Back-references change the following production:</p>
+                <p>Combining this change with the introduction of non-capturing
+groups (see above), back-references change the following
+production:</p>
                 <p>
                   <span>
                     <code>[9] atom ::= Char | charClass | ( '(' regExp ')'
@@ -10785,8 +11099,8 @@
                 <p>to</p>
                 <p>
                   <span>
-                    <code>[9] atom ::= Char | charClass | ( '(' regExp ')' ) |
-backReference</code>
+                    <code>[9] atom ::= Char | charClass | ( '(' '?:'? regExp
+')' ) | backReference</code>
                   </span>
                 </p>
                 <p>
@@ -10795,6 +11109,27 @@
 [1-9][0-9]*</code>
                   </span>
                 </p>
+                <p>With respect to the XSD 1.1 version of the regular expression
+grammar, the effect is to change:</p>
+                <p>
+                  <span>
+                    <code>[72] atom ::= NormalChar | charClass | ( '(' regExp
+')' )</code>
+                  </span>
+                </p>
+                <p>to</p>
+                <p>
+                  <span>
+                    <code>[72] atom ::= NormalChar | charClass | ( '(' '?:'?
+regExp ')' ) | backReference</code>
+                  </span>
+                </p>
+                <p>
+                  <span>
+                    <code>[72a] backReference ::= "\"
+[1-9][0-9]*</code>
+                  </span>
+                </p>
                 <div class="note">
                   <p class="prefix">
                     <b>Note:</b>
@@ -10820,6 +11155,23 @@
                   <code>[24]SingleCharEsc ::= '\'
 [nrt\|.?*+(){}$#x2D#x5B#x5D#x5E]</code>
                 </p>
+                <p>(In the XSD 1.1 version of the regular expression grammar, the
+production rule for <code>SingleCharEsc</code> is unchanged, but is
+renumbered [84])</p>
+              </li>
+              <li>
+                <p>A regular expression that uses a Unicode block name that is not
+defined in the version(s) of Unicode supported by the processor
+(for example <code>\p{IsBadBlockName}</code>) is deemed to be
+invalid [<a href="#ERRFORX0002" title="err:FORX0002">err:FORX0002</a>].</p>
+                <div class="note">
+                  <p class="prefix">
+                    <b>Note:</b>
+                  </p>
+                  <p>XSD 1.0 does not say how this situation should be handled; XSD
+1.1 says that it should be handled by treating all characters as
+matching.</p>
+                </div>
               </li>
             </ul>
             <div class="note">
@@ -10842,7 +11194,8 @@
 of a letter within the string indicates that the option is on; its
 absence indicates that the option is off. Letters may appear in any
 order and may be repeated. If there are characters present that are
-not defined here as flags, then an error is raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>].</p>
+not defined here as flags, then a <span>dynamic</span> error is
+raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>].</p>
               <p>The following options are defined:</p>
               <ul>
                 <li>
@@ -10850,11 +11203,12 @@
                     <code>s</code>: If present, the match operates in "dot-all"
 mode. (Perl calls this the single-line mode.) If the <code>s</code>
 flag is not specified, the meta-character <code>.</code> matches
-any character except a newline (<code>#x0A</code>) character. In
-dot-all mode, the meta-character <code>.</code> matches any
-character whatsoever. Suppose the input contains "hello" and
-"world" on two lines. This will not be matched by the regular
-expression "hello.*world" unless dot-all mode is enabled.</p>
+any character except a newline (<code>#x0A</code>) <span>or
+carriage return (<code>#x0D</code>)</span> character. In dot-all
+mode, the meta-character <code>.</code> matches any character
+whatsoever. Suppose the input contains "hello" and "world" on two
+lines. This will not be matched by the regular expression
+"hello.*world" unless dot-all mode is enabled.</p>
                 </li>
                 <li>
                   <p>
@@ -10884,13 +11238,7 @@
                   <p>
                     <a href="#func-lower-case">
                       <code>fn:lower-case(C1) eq
-fn:lower-case(C2)</code>
-                    </a>
-                  </p>
-                  <p>or</p>
-                  <p>
-                    <a href="#func-upper-case">
-                      <code>fn:upper-case(C1) eq
+fn:lower-case(C2) or fn:upper-case(C1) eq
 fn:upper-case(C2)</code>
                     </a>
                   </p>
@@ -10904,7 +11252,9 @@
 both "z" and "Z".</p>
                     </li>
                     <li>
-                      <p>A character range (<code>charRange</code>) represents the set
+                      <p>A character range (<span>production <code>charRange</code> in
+the XSD 1.0 grammar, replaced by productions <code>charRange</code>
+and <code>singleChar</code> in XSD 1.1</span>) represents the set
 containing all the characters that it would match in the absence of
 the "<code>i</code>" flag, together with their case-variants. For
 example, the regular expression "[A-Z]" will match all the letters
@@ -11109,13 +11459,13 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFORX0002" title="err:FORX0002">err:FORX0002</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0002" title="err:FORX0002">err:FORX0002</a>] if the value of
 <code>$pattern</code> is invalid according to the rules described
 in <a href="#regex-syntax">
                     <b>5.6.1 Regular expression
 syntax</b>
                   </a>.</p>
-                <p>An error is raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>] if the value of
 <code>$flags</code> is invalid according to the rules described in
 <a href="#flags">
                     <b>5.6.1.1 Flags</b>
@@ -11127,7 +11477,7 @@
 used as anchors, the string is considered to match the pattern if
 any substring matches the pattern. But if anchors are used, the
 anchors must match the start/end of the string (in string mode), or
-the start/end of a line (in multiline mode).</p>
+the start/end of a line (in multi-line mode).</p>
                 <p>This is different from the behavior of patterns in <a href="#xmlschema-2">[XML Schema Part 2: Datatypes Second Edition]</a>,
 where regular expressions are <em>implicitly</em> anchored.</p>
                 <p>Regular expression matching is defined on the basis of Unicode
@@ -11355,29 +11705,29 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFORX0002" title="err:FORX0002">err:FORX0002</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0002" title="err:FORX0002">err:FORX0002</a>] if the value of
 <code>$pattern</code> is invalid according to the rules described
 in section <a href="#regex-syntax">
                     <b>5.6.1 Regular expression
 syntax</b>
                   </a>.</p>
-                <p>An error is raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>] if the value of
 <code>$flags</code> is invalid according to the rules described in
 section <a href="#regex-syntax">
                     <b>5.6.1 Regular expression
 syntax</b>
                   </a>.</p>
-                <p>An error is raised [<a href="#ERRFORX0003" title="err:FORX0003">err:FORX0003</a>] if the pattern matches a
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0003" title="err:FORX0003">err:FORX0003</a>] if the pattern matches a
 zero-length string, that is, if the expression <a href="#func-matches">
                     <code>fn:matches("", $pattern, $flags)</code>
                   </a>
 returns <code>true</code>. It is not an error, however, if a
 captured substring is zero-length.</p>
-                <p>An error is raised [<a href="#ERRFORX0004" title="err:FORX0004">err:FORX0004</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0004" title="err:FORX0004">err:FORX0004</a>] if the value of
 <code>$replacement</code> contains a "<code>$</code>" character
 that is not immediately followed by a digit <code>0-9</code> and
 not immediately preceded by a "\".</p>
-                <p>An error is raised [<a href="#ERRFORX0004" title="err:FORX0004">err:FORX0004</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0004" title="err:FORX0004">err:FORX0004</a>] if the value of
 <code>$replacement</code> contains a "<code>\</code>" character
 that is not part of a "<code>\\</code>" pair, unless it is
 immediately followed by a "<code>$</code>" character.</p>
@@ -11520,19 +11870,19 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFORX0002" title="err:FORX0002">err:FORX0002</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0002" title="err:FORX0002">err:FORX0002</a>] if the value of
 <code>$pattern</code> is invalid according to the rules described
 in section <a href="#regex-syntax">
                     <b>5.6.1 Regular expression
 syntax</b>
                   </a>.</p>
-                <p>An error is raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>] if the value of
 <code>$flags</code> is invalid according to the rules described in
 section <a href="#regex-syntax">
                     <b>5.6.1 Regular expression
 syntax</b>
                   </a>.</p>
-                <p>an error is raised [<a href="#ERRFORX0003" title="err:FORX0003">err:FORX0003</a>] if the supplied
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0003" title="err:FORX0003">err:FORX0003</a>] if the supplied
 <code>$pattern</code> matches a zero-length string, that is, if
 <a href="#func-matches">
                     <code>fn:matches("", $pattern,
@@ -11555,8 +11905,8 @@
                 <p>The expression <code>fn:tokenize("1,15,,24,50,", ",")</code>
 returns <code>("1", "15", "", "24", "50", "")</code>.</p>
                 <p>
-                  <code>fn:tokenize("abba", ".?")</code> raises the error
-[<a href="#ERRFORX0003" title="err:FORX0003">err:FORX0003</a>].</p>
+                  <code>fn:tokenize("abba", ".?")</code> raises the
+<span>dynamic</span> error [<a href="#ERRFORX0003" title="err:FORX0003">err:FORX0003</a>].</p>
                 <p>The expression <code>fn:tokenize("Some unparsed &lt;br&gt; HTML
 &lt;BR&gt; text", "\s*&lt;br&gt;\s*", "i")</code> returns
 <code>("Some unparsed", "HTML", "text")</code>.</p>
@@ -11737,6 +12087,13 @@
 example, a Basic XSLT Processor), in which case the elements will
 all be annotated as <code>xs:untyped</code> and the attributes as
 <code>xs:untypedAtomic</code>.</p>
+                <div class="note">
+                  <p class="prefix">
+                    <b>Note:</b>
+                  </p>
+                  <p>A free-standing copy of this schema can be found at <a href="analyze-string.xsd">analyze-string.xsd</a>
+                  </p>
+                </div>
                 <div class="exampleInner">
                   <pre>
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
@@ -11776,25 +12133,33 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFORX0002" title="err:FORX0002">err:FORX0002</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0002" title="err:FORX0002">err:FORX0002</a>] if the value of
 <code>$pattern</code> is invalid according to the rules described
 in section <a href="#regex-syntax">
                     <b>5.6.1 Regular expression
 syntax</b>
                   </a>.</p>
-                <p>An error is raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>] if the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0001" title="err:FORX0001">err:FORX0001</a>] if the value of
 <code>$flags</code> is invalid according to the rules described in
 section <a href="#regex-syntax">
                     <b>5.6.1 Regular expression
 syntax</b>
                   </a>.</p>
-                <p>An error is raised [<a href="#ERRFORX0003" title="err:FORX0003">err:FORX0003</a>] if the supplied
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORX0003" title="err:FORX0003">err:FORX0003</a>] if the supplied
 <code>$pattern</code> matches a zero-length string, that is, if
 <a href="#func-matches">
                     <code>fn:matches("", $pattern,
 $flags)</code>
                   </a> returns <code>true</code>.</p>
               </dd>
+              <dt class="label">Notes</dt>
+              <dd>
+                <p>The declarations and definitions in the above schema are not
+automatically available in the static context of the
+<code>fn:analyze-string</code> call (or of any other expression).
+The contents of the static context are host-language defined, and
+in some host languages are implementation-defined.</p>
+              </dd>
               <dt class="label">Examples</dt>
               <dd>
                 <p>In the following examples, the result document is shown in
@@ -11922,7 +12287,7 @@
             </dd>
             <dt class="label">Properties</dt>
             <dd>
-              <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+              <p>The one-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                   <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                 </a>,
 <a title="context-dependent" class="termref" href="#dt-context-dependent">
@@ -11931,8 +12296,8 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                   <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                 </a>.
-It depends on base-uri.</p>
-              <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+It depends on static base uri.</p>
+              <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                   <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                 </a>,
 <a title="context-independent" class="termref" href="#dt-context-independent">
@@ -11975,23 +12340,23 @@
             <dd>
               <p>The first form of this function resolves <code>$relative</code>
 against the value of the base-uri property from the static context.
-An error is raised [<a href="#ERRFONS0005" title="err:FONS0005">err:FONS0005</a>] if the base-uri property is not
-initialized in the static context.</p>
-              <p>An error is raised [<a href="#ERRFORG0002" title="err:FORG0002">err:FORG0002</a>] if <code>$relative</code> is not a
-valid IRI according to the rules of RFC3987, extended with an
+A <span>dynamic</span> error is raised [<a href="#ERRFONS0005" title="err:FONS0005">err:FONS0005</a>] if the base-uri property is
+not initialized in the static context.</p>
+              <p>A <span>dynamic</span> error is raised [<a href="#ERRFORG0002" title="err:FORG0002">err:FORG0002</a>] if <code>$relative</code> is
+not a valid IRI according to the rules of RFC3987, extended with an
 implementation-defined subset of the extensions permitted in LEIRI,
 or if it is not a suitable relative reference to use as input to
 the RFC3986 resolution algorithm extended to handle additional
 unreserved characters.</p>
-              <p>An error is raised [<a href="#ERRFORG0002" title="err:FORG0002">err:FORG0002</a>] if <code>$base</code> is not a
-valid IRI according to the rules of RFC3987, extended with an
+              <p>A <span>dynamic</span> error is raised [<a href="#ERRFORG0002" title="err:FORG0002">err:FORG0002</a>] if <code>$base</code> is not
+a valid IRI according to the rules of RFC3987, extended with an
 implementation-defined subset of the extensions permitted in LEIRI,
 or if it is not a suitable IRI to use as input to the chosen
 resolution algorithm (for example, if it is a relative IRI
 reference, if it is a non-hierarchic URI, or if it contains a
-fragment identifier), then .</p>
-              <p>An error is raised [<a href="#ERRFORG0009" title="err:FORG0009">err:FORG0009</a>] if the chosen resolution algorithm
-fails for any other reason.</p>
+fragment identifier).</p>
+              <p>A <span>dynamic</span> error is raised [<a href="#ERRFORG0009" title="err:FORG0009">err:FORG0009</a>] if the chosen resolution
+algorithm fails for any other reason.</p>
             </dd>
             <dt class="label">Notes</dt>
             <dd>
@@ -14141,7 +14506,7 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOCA0005" title="err:FOCA0005">err:FOCA0005</a>] if <code>$arg2</code> is
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOCA0005" title="err:FOCA0005">err:FOCA0005</a>] if <code>$arg2</code> is
 <code>NaN</code>.</p>
               </dd>
               <dt class="label">Notes</dt>
@@ -14222,7 +14587,7 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOCA0005" title="err:FOCA0005">err:FOCA0005</a>] if <code>$arg2</code> is
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOCA0005" title="err:FOCA0005">err:FOCA0005</a>] if <code>$arg2</code> is
 <code>NaN</code>.</p>
               </dd>
               <dt class="label">Notes</dt>
@@ -14511,7 +14876,7 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOCA0005" title="err:FOCA0005">err:FOCA0005</a>] if <code>$arg2</code> is
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOCA0005" title="err:FOCA0005">err:FOCA0005</a>] if <code>$arg2</code> is
 <code>NaN</code>.</p>
               </dd>
               <dt class="label">Notes</dt>
@@ -14590,7 +14955,7 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOCA0005" title="err:FOCA0005">err:FOCA0005</a>] if <code>$arg2</code> is
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOCA0005" title="err:FOCA0005">err:FOCA0005</a>] if <code>$arg2</code> is
 <code>NaN</code>.</p>
               </dd>
               <dt class="label">Notes</dt>
@@ -14775,7 +15140,8 @@
               </a> return
 00:00:00 in case of time underflow. It <a title="must" class="termref" href="#must">
                 <span class="arrow">·</span>must<span class="arrow">·</span>
-              </a> raise an error [<a href="#ERRFODT0001" title="err:FODT0001">err:FODT0001</a>] in case of overflow.</p>
+              </a> raise a <span>dynamic</span> error [<a href="#ERRFODT0001" title="err:FODT0001">err:FODT0001</a>] in case of
+overflow.</p>
           </div>
         </div>
         <div class="div2">
@@ -14911,8 +15277,8 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFORG0008" title="err:FORG0008">err:FORG0008</a>] if the two arguments both have
-timezones and the timezones are different.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORG0008" title="err:FORG0008">err:FORG0008</a>] if the two arguments both
+have timezones and the timezones are different.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -15241,7 +15607,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -15306,7 +15672,7 @@
               <dd>
                 <p>Defines the semantics of the "lt" operator on
 <code>xs:dateTime</code> values. Also used in the definition of the
-"le" operator.</p>
+<span>"ge"</span> operator.</p>
               </dd>
               <dt class="label">Signature</dt>
               <dd>
@@ -15332,7 +15698,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -15364,7 +15730,7 @@
               <dd>
                 <p>Defines the semantics of the "gt" operator on
 <code>xs:dateTime</code> values. Also used in the definition of the
-"ge" operator.</p>
+<span>"le"</span> operator.</p>
               </dd>
               <dt class="label">Signature</dt>
               <dd>
@@ -15406,7 +15772,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -15459,7 +15825,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -15503,7 +15869,7 @@
               <dd>
                 <p>Defines the semantics of the "lt" operator on
 <code>xs:date</code> values. Also used in the definition of the
-"le" operator.</p>
+<span>"ge"</span> operator.</p>
               </dd>
               <dt class="label">Signature</dt>
               <dd>
@@ -15556,7 +15922,7 @@
               <dd>
                 <p>Defines the semantics of the "gt" operator on
 <code>xs:date</code> values. Also used in the definition of the
-"ge" operator.</p>
+<span>"le"</span> operator.</p>
               </dd>
               <dt class="label">Signature</dt>
               <dd>
@@ -15582,7 +15948,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -15647,7 +16013,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -15677,7 +16043,7 @@
 date components are <code>1972-12-31T08:00:00+09:00</code> and
 <code>1972-12-31T17:00:00-06:00</code>. These normalize to
 <code>1972-12-30T23:00:00Z</code> and
-<code>1972-12-31T23:00:00</code>. ).</em>
+<code>1972-12-31T23:00:00Z</code>. ).</em>
                 </p>
                 <p>The expression <code>op:time-equal(xs:time("21:30:00+10:30"),
 xs:time("06:00:00-05:00"))</code> returns <code>true()</code>.</p>
@@ -15712,7 +16078,7 @@
               <dd>
                 <p>Defines the semantics of the "lt" operator on
 <code>xs:time</code> values. Also used in the definition of the
-"le" operator.</p>
+<span>"ge"</span> operator.</p>
               </dd>
               <dt class="label">Signature</dt>
               <dd>
@@ -15738,7 +16104,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -15786,7 +16152,7 @@
               <dd>
                 <p>Defines the semantics of the "gt" operator on
 <code>xs:time</code> values. Also used in the definition of the
-"ge" operator.</p>
+<span>"le"</span> operator.</p>
               </dd>
               <dt class="label">Signature</dt>
               <dd>
@@ -15812,7 +16178,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -15886,7 +16252,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -15911,7 +16277,7 @@
                 <p>
                   <code>op:gYearMonth-equal(xs:gYearMonth("1978-03"),
 xs:gYearMonth("1986-03Z"))</code> returns <code>false()</code>. The
-starting instants are <code>1986-03-01T00:00:00-05:00</code> and
+starting instants are <code>1978-03-01T00:00:00-05:00</code> and
 <code>1986-03-01T00:00:00Z</code>, respectively.</p>
               </dd>
             </dl>
@@ -15956,7 +16322,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -16027,7 +16393,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -16102,7 +16468,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -16174,7 +16540,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -17202,7 +17568,7 @@
                     <code class="function">fn:adjust-dateTime-to-timezone</code>(<code class="arg">$arg</code>
                     <code class="as"> as </code>
                     <code class="type">xs:dateTime?</code>)<code class="as"> as </code>
-                    <code class="return-type">xs:dateTime</code>
+                    <code class="return-type">xs:dateTime?</code>
                   </div>
                 </div>
                 <div class="exampleInner">
@@ -17225,7 +17591,7 @@
                         <td valign="baseline">
                           <code class="as"> as </code>
                           <code class="type">xs:dayTimeDuration?</code>)<code class="as"> as </code>
-                          <code class="return-type">xs:dateTime</code>
+                          <code class="return-type">xs:dateTime?</code>
                         </td>
                       </tr>
                     </table>
@@ -17243,7 +17609,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
                 <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
@@ -17279,9 +17645,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODT0003" title="err:FODT0003">err:FODT0003</a>] if <code>$timezone</code> is less
-than <code>-PT14H</code> or greater than <code>PT14H</code> or is
-not an integral number of minutes.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODT0003" title="err:FODT0003">err:FODT0003</a>] if <code>$timezone</code> is
+less than <code>-PT14H</code> or greater than <code>PT14H</code> or
+is not an integral number of minutes.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -17383,7 +17749,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
                 <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
@@ -17436,9 +17802,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODT0003" title="err:FODT0003">err:FODT0003</a>] if <code>$timezone</code> is less
-than <code>-PT14H</code> or greater than <code>PT14H</code> or is
-not an integral number of minutes.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODT0003" title="err:FODT0003">err:FODT0003</a>] if <code>$timezone</code> is
+less than <code>-PT14H</code> or greater than <code>PT14H</code> or
+is not an integral number of minutes.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -17537,7 +17903,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
                 <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
                     <span class="arrow">·</span>deterministic<span class="arrow">·</span>
                   </a>,
@@ -17590,9 +17956,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODT0003" title="err:FODT0003">err:FODT0003</a>] if <code>$timezone</code> is less
-than <code>-PT14H</code> or greater than <code>PT14H</code> or if
-does not contain an integral number of minutes.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODT0003" title="err:FODT0003">err:FODT0003</a>] if <code>$timezone</code> is
+less than <code>-PT14H</code> or greater than <code>PT14H</code> or
+if does not contain an integral number of minutes.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -17787,9 +18153,8 @@
               </a> return P0M or PT0S in case of duration
 underflow and 00:00:00 in case of time underflow. It <a title="must" class="termref" href="#must">
                 <span class="arrow">·</span>must<span class="arrow">·</span>
-              </a> raise an error
-[<a href="#ERRFODT0001" title="err:FODT0001">err:FODT0001</a>] in
-case of overflow.</p>
+              </a> raise a
+<span>dynamic</span> error [<a href="#ERRFODT0001" title="err:FODT0001">err:FODT0001</a>] in case of overflow.</p>
             <p>The value spaces of the two totally ordered subtypes of
 <code>xs:duration</code> described in <a href="#duration-subtypes">
                 <b>8.1 Two totally ordered subtypes of
@@ -17810,7 +18175,8 @@
 case of numeric underflow and P0M or PT0S in case of duration
 underflow. It <a title="must" class="termref" href="#must">
                 <span class="arrow">·</span>must<span class="arrow">·</span>
-              </a> raise an error [<a href="#ERRFODT0002" title="err:FODT0002">err:FODT0002</a>] in case of overflow.</p>
+              </a> raise a <span>dynamic</span> error [<a href="#ERRFODT0002" title="err:FODT0002">err:FODT0002</a>] in case of
+overflow.</p>
           </div>
           <div class="div3">
             <h4>
@@ -17867,7 +18233,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -17940,7 +18306,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -18029,7 +18395,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -18962,15 +19328,27 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
-                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
-                  </a>,
-<a title="context-dependent" class="termref" href="#dt-context-dependent">
-                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
-                  </a>,
-and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
-                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
-                  </a>.</p>
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on default calendar, and default language, and default
+place, and implicit timezone.</p>
+                <p>The five-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -19056,15 +19434,27 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
-                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
-                  </a>,
-<a title="context-dependent" class="termref" href="#dt-context-dependent">
-                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
-                  </a>,
-and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
-                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
-                  </a>.</p>
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on default calendar, and default language, and default
+place, and implicit timezone.</p>
+                <p>The five-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -19150,15 +19540,27 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
-                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
-                  </a>,
-<a title="context-dependent" class="termref" href="#dt-context-dependent">
-                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
-                  </a>,
-and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
-                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
-                  </a>.</p>
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on default calendar, and default language, and default
+place, and implicit timezone.</p>
+                <p>The five-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on implicit timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -19219,11 +19621,14 @@
               </a>.</p>
             <p>In general, the use of an invalid <code>$picture</code>,
 <code>$language</code>, <code>$calendar</code>, or
-<code>$place</code> argument results in a dynamic error. By
-contrast, use of an option in any of these arguments that is valid
-but not supported by the implementation is not an error, and in
-these cases the implementation is required to output the value in a
-fallback representation.</p>
+<code>$place</code> argument results in a dynamic error
+<span>([<a href="#ERRFOFD1340" title="err:FOFD1340">err:FOFD1340</a>])</span>. By contrast, use of an
+option in any of these arguments that is valid but not supported by
+the implementation is not an error, and in these cases the
+implementation is required to output the value in a fallback
+representation. <span>More detailed rules are given
+below.</span>
+            </p>
             <div class="div4">
               <h5>
                 <a name="date-picture-string" id="date-picture-string"/>9.8.4.1 The picture string</h5>
@@ -19370,11 +19775,11 @@
                   </tr>
                 </tbody>
               </table>
-              <p>An error is reported [<a href="#ERRFOFD1340" title="err:FOFD1340">err:FOFD1340</a>] if the syntax of the picture is
-incorrect.</p>
-              <p>An error is reported [<a href="#ERRFOFD1350" title="err:FOFD1350">err:FOFD1350</a>] if a component specifier within
-the picture refers to components that are not available in the
-given type of <code>$value</code>, for example if the picture
+              <p>A <span>dynamic</span> error is reported [<a href="#ERRFOFD1340" title="err:FOFD1340">err:FOFD1340</a>] if the syntax of the picture
+is incorrect.</p>
+              <p>A <span>dynamic</span> error is reported [<a href="#ERRFOFD1350" title="err:FOFD1350">err:FOFD1350</a>] if a component specifier
+within the picture refers to components that are not available in
+the given type of <code>$value</code>, for example if the picture
 supplied to the <a href="#func-format-time">
                   <code>fn:format-time</code>
                 </a> refers to the
@@ -19403,8 +19808,9 @@
 respectively. Components that can be output by name include (but
 are not limited to) months, days of the week, timezones, and eras.
 If the processor cannot output these components by name for the
-chosen calendar and language then it must use an
-implementation-defined fallback representation.</p>
+chosen calendar and language then it must use an <a title="implementation-defined" class="termref" href="#implementation-defined">
+                      <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+                    </a> fallback representation.</p>
                 </li>
               </ul>
               <p>If a comma is to be used as a grouping separator within the
@@ -19432,8 +19838,10 @@
                     <td valign="top">either <code>a</code> or <code>t</code>
                     </td>
                     <td valign="top">indicates alphabetic or traditional numbering
-respectively, the default being implementation-defined. This has
-the same meaning as in the second argument of <a href="#func-format-integer">
+respectively, the default being <a title="implementation-defined" class="termref" href="#implementation-defined">
+                        <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+                      </a>. This has the same meaning as in the second
+argument of <a href="#func-format-integer">
                         <code>fn:format-integer</code>
                       </a>.</td>
                   </tr>
@@ -19507,9 +19915,11 @@
 output. In the case of fractional seconds in particular,
 <code>[f001]</code> requests three decimal digits,
 <code>[f01]</code> requests two digits, but <code>[f1]</code> will
-produce an implementation-defined number of digits. If exactly one
-digit is required, this can be achieved using the component
-specifier <code>[f1,1-1]</code>.</p>
+produce an <a title="implementation-defined" class="termref" href="#implementation-defined">
+                    <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+                  </a> number of digits. If exactly one digit is
+required, this can be achieved using the component specifier
+<code>[f1,1-1]</code>.</p>
               </div>
               <p>If the minimum and maximum width are unspecified, then the
 output uses as many characters as are required to represent the
@@ -19687,7 +20097,7 @@
                     <td>-5</td>
                     <td>+0</td>
                     <td>+5:30</td>
-                    <td>+13:00</td>
+                    <td>+13</td>
                   </tr>
                   <tr>
                     <td>[Z0:00]</td>
@@ -19792,12 +20202,14 @@
 component.</p>
               <p>The <code>$language</code> argument specifies the language to be
 used for the result string of the function. The value of the
-argument <strong>must</strong> be either the empty sequence or a
-value that would be valid for the <code>xml:lang</code> attribute
-(see [XML]). Note that this permits the identification of
-sublanguages based on country codes (from <a href="#ISO3166">[ISO
-3166-1]</a>) as well as identification of dialects and of regions
-within a country.</p>
+argument <span>
+                  <strong>should</strong>
+                </span> be either the empty
+sequence or a value that would be valid for the
+<code>xml:lang</code> attribute (see [XML]). Note that this permits
+the identification of sublanguages based on country codes (from
+<a href="#ISO3166">[ISO 3166-1]</a>) as well as identification of
+dialects and of regions within a country.</p>
               <p>If the <code>$language</code> argument is omitted or is set to
 an empty sequence, or if it is set to an invalid value or a value
 that the implementation does not recognize, then the processor uses
@@ -19836,14 +20248,19 @@
 supplied in the <code>$value</code> argument <strong>must</strong>
 be converted to a value in the specified calendar and then
 converted to a string using the conventions of that calendar.</p>
-              <p>A calendar value <strong>must</strong> be a valid lexical QName.
-If the QName does not have a prefix, then it identifies a calendar
-with the designator specified below. If the QName has a prefix,
-then the QName is expanded into an expanded-QName using the
-<span>statically known namespaces</span>; the expanded-QName
-identifies the calendar; the behavior in this case is <a title="implementation-defined" class="termref" href="#implementation-defined">
+              <p>The calendar value if present <strong>must</strong> be a valid
+<span>
+                  <code>EQName</code> (<span>dynamic</span> error: [<a href="#ERRFOFD1340" title="err:FOFD1340">err:FOFD1340</a>])</span>. If
+it is a lexical <code>QName</code> then it is expanded into an
+expanded QName using the <span>statically known namespaces</span>;
+if it has no prefix then it represents an expanded-QName in no
+namespace. If the expanded QName is in no namespace, then it
+<strong>must</strong> identify a calendar with a designator
+specified below (<span>dynamic error: [<a href="#ERRFOFD1340" title="err:FOFD1340">err:FOFD1340</a>])</span>. If the expanded
+QName is in a namespace then it identifies the calendar in an
+<a title="implementation-defined" class="termref" href="#implementation-defined">
                   <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-                </a>.</p>
+                </a> way.</p>
               <p>If the <code>$calendar</code> argument is omitted or is set to
 an empty sequence then the default calendar defined in the dynamic
 context is used.</p>
@@ -20018,6 +20435,15 @@
 zero-length string (for positive years). For dates before 1
 January, AD 1, year numbers in the ISO and AD calendars are off by
 one from each other: ISO year 0000 is 1 BC, -0001 is 2 BC, etc.</p>
+              <p>ISO 8601 does not define a numbering for weeks within a month.
+When the <code>w</code> component is used, the convention to be
+adopted is that each Monday-to-Sunday week is considered to fall
+within a particular month if its Thursday occurs in that month; the
+weeks that fall in a particular month under this definition are
+numbered starting from 1. Thus, for example, 29 January 2013 falls
+in week 5 because the Thursday of the week (31 January 2013) is the
+fifth Thursday in January, and 1 February 2013 is also in week 5
+for the same reason.</p>
               <div class="note">
                 <p class="prefix">
                   <b>Note:</b>
@@ -20052,12 +20478,12 @@
 numbered zero. In <a href="#xmlschema-2">[XML Schema Part 2:
 Datatypes Second Edition]</a> (version 1.0), the value space for
 <code>xs:date</code> and <code>xs:dateTime</code> does not include
-a year zero: however, a future edition is expected to endorse the
-ISO 8601 convention. This means that the date on which Julius
-Caesar was assassinated has the ISO 8601 lexical representation
--0043-03-13, but will be formatted as 15 March 44 BCE in the Julian
-calendar or 13 March 44 BCE in the Gregorian calendar (dependant on
-the chosen localization of the names of months and eras).</p>
+a year zero: however, <span>XSD 1.1 endorses</span> the ISO 8601
+convention. This means that the date on which Julius Caesar was
+assassinated has the ISO 8601 lexical representation -0043-03-13,
+but will be formatted as 15 March 44 BCE in the Julian calendar or
+13 March 44 BCE in the Gregorian calendar (dependant on the chosen
+localization of the names of months and eras).</p>
               </div>
               <p>The intended use of the <code>$place</code> argument is to
 identify the place where an event represented by the
@@ -20067,8 +20493,10 @@
 is set to an empty sequence, then the default place defined in the
 dynamic context is used.</span> If the value is supplied, and is
 not the empty sequence, then it <strong>should</strong>
-                <span>either be a country code or an Olson timezone
-name.</span>
+                <span>either be a country code or an Olson timezone name.</span>
+                <span>If the value does not take this form, or if its value is not
+recognized by the implementation, then the default place defined in
+the dynamic context is used.</span>
               </p>
               <ul>
                 <li>
@@ -20122,7 +20550,7 @@
 Examples of date and time formatting</h4>
             <div class="exampleOuter">
               <div class="exampleHeader">
-                <a name="d5e25744" id="d5e25744"/>Example: Gregorian calendar</div>
+                <a name="d5e26542" id="d5e26542"/>Example: Gregorian calendar</div>
               <p>The following examples show a selection of dates and times and
 the way they might be formatted. These examples assume the use of
 the Gregorian calendar as the default calendar.</p>
@@ -20328,7 +20756,7 @@
             </div>
             <div class="exampleOuter">
               <div class="exampleHeader">
-                <a name="d5e26000" id="d5e26000"/>Example: Non-Gregorian calendars</div>
+                <a name="d5e26798" id="d5e26798"/>Example: Non-Gregorian calendars</div>
               <p>The following examples use calendars other than the Gregorian
 calendar.</p>
               <p>These examples use non-Latin characters which might not display
@@ -20495,10 +20923,10 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>] if <code>$qname</code> does not
-have the correct lexical form for an instance of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>] if <code>$qname</code> does
+not have the correct lexical form for an instance of
 <code>xs:QName</code>.</p>
-                <p>An error is raised [<a href="#ERRFONS0004" title="err:FONS0004">err:FONS0004</a>] if <code>$qname</code> has a
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFONS0004" title="err:FONS0004">err:FONS0004</a>] if <code>$qname</code> has a
 prefix and there is no namespace binding for <code>$element</code>
 that matches this prefix.</p>
               </dd>
@@ -20578,15 +21006,16 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>] if <code>$paramQName</code> does
-not have the correct lexical form for an instance of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>] if <code>$paramQName</code>
+does not have the correct lexical form for an instance of
 <code>xs:QName</code>.</p>
-                <p>An error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>] if <code>$paramURI</code> is the
-zero-length string or the empty sequence, and the value of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>] if <code>$paramURI</code> is
+the zero-length string or the empty sequence, and the value of
 <code>$paramQName</code> contains a colon (<code>:</code>).</p>
-                <p>An error <strong>may</strong> be raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>] if <code>$paramURI</code> is
-not a valid URI (XML Namespaces 1.0) or IRI (XML Namespaces
-1.1).</p>
+                <p>A <span>dynamic</span> error <strong>may</strong> be raised
+[<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>] if
+<code>$paramURI</code> is not a valid URI (XML Namespaces 1.0) or
+IRI (XML Namespaces 1.1).</p>
               </dd>
               <dt class="label">Notes</dt>
               <dt class="label">Examples</dt>
@@ -21497,16 +21926,25 @@
             <dt class="label">Error Conditions</dt>
             <dd>
               <p>The following errors may be raised when <code>$arg</code> is
-omitted: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                <sup>
-                  <small>DM30</small>
-                </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
           </dl>
         </div>
@@ -21584,12 +22022,25 @@
             <dt class="label">Error Conditions</dt>
             <dd>
               <p>The following errors may be raised when <code>$arg</code> is
-omitted: if the context item is absent [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
           </dl>
         </div>
@@ -21669,12 +22120,25 @@
             <dt class="label">Error Conditions</dt>
             <dd>
               <p>The following errors may be raised when <code>$arg</code> is
-omitted: if the context item is absent [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
           </dl>
         </div>
@@ -21774,13 +22238,26 @@
             </dd>
             <dt class="label">Error Conditions</dt>
             <dd>
-              <p>When <code>$arg</code> is omitted the following errors may be
-raised: if the context item is absent [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+              <p>The following errors may be raised when <code>$arg</code> is
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
             <dt class="label">Examples</dt>
             <dd>
@@ -22019,13 +22496,26 @@
             </dd>
             <dt class="label">Error Conditions</dt>
             <dd>
-              <p>When <code>$arg</code> is omitted the following errors may be
-raised : if the context item is absent [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+              <p>The following errors may be raised when <code>$arg</code> is
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
             <dt class="label">Examples</dt>
             <dd>
@@ -22141,75 +22631,100 @@
 the string <code>"/"</code>.</p>
               <p>Otherwise, the function constructs a string that consists of a
 sequence of steps, one for each ancestor-or-self of
-<code>$arg</code> other than the document node. Each step consists
-of the character <code>"/"</code> followed by a string whose form
+<code>$arg</code> other than the <span>root</span> node. <span>This
+string is prefixed by
+<code>"Q{http://www.w3.org/2005/xpath-functions}root()"</code> if
+the root node is not a document node.</span> Each step consists of
+the character <code>"/"</code> followed by a string whose form
 depends on the kind of node selected by that step, as follows:</p>
               <ol class="enumar">
                 <li>
-                  <p>For an element node, <code>"{uri}":{local}[{position}]</code>,
-where <code>{uri}</code> is the namespace URI of the node name or
-the empty string if the node is in no namespace,
-<code>{local}</code> is the local part of the node name, and
-<code>{position}</code> is an integer representing the position of
-the selected node among its like-named siblings.</p>
+                  <p>For an element node,
+<code>Q{<em>uri</em>}<em>local</em>[<em>position</em>]</code>,
+where <code>
+                      <em>uri</em>
+                    </code> is the namespace URI of the node
+name or the empty string if the node is in no namespace,
+<code>
+                      <em>local</em>
+                    </code> is the local part of the node name, and
+<code>
+                      <em>position</em>
+                    </code> is an integer representing the
+position of the selected node among its like-named siblings.</p>
                 </li>
                 <li>
                   <p>For an attribute node:</p>
                   <ol class="enumla">
                     <li>
-                      <p>if the node is in no namespace, <code>@{local}</code>, where
-<code>{local}</code> is the local part of the node name</p>
+                      <p>if the node is in no namespace, <code>@<em>local</em>
+                        </code>,
+where <code>
+                          <em>local</em>
+                        </code> is the local part of the node
+name</p>
                     </li>
                     <li>
-                      <p>otherwise, <code>@"{uri}":{local}</code>, where
-<code>{uri}</code> is the namespace URI of the node name, and
-<code>{local}</code> is the local part of the node name</p>
+                      <p>otherwise, <code>@Q{<em>uri</em>}<em>local</em>
+                        </code>, where
+<code>
+                          <em>uri</em>
+                        </code> is the namespace URI of the node name,
+and <code>
+                          <em>local</em>
+                        </code> is the local part of the node
+name</p>
                     </li>
                   </ol>
                 </li>
                 <li>
-                  <p>For a text node: <code>text()[{position}]</code> where
-<code>{position}</code> is an integer representing the position of
-the selected node among its text node siblings</p>
+                  <p>For a text node: <code>text()[<em>position</em>]</code> where
+<code>
+                      <em>position</em>
+                    </code> is an integer representing the
+position of the selected node among its text node siblings</p>
                 </li>
                 <li>
-                  <p>For a comment node: <code>comment()[{position}]</code> where
-<code>{position}</code> is an integer representing the position of
-the selected node among its comment node siblings</p>
+                  <p>For a comment node: <code>comment()[<em>position</em>]</code>
+where <code>
+                      <em>position</em>
+                    </code> is an integer representing the
+position of the selected node among its comment node siblings</p>
                 </li>
                 <li>
                   <p>For a processing-instruction node:
-<code>processing-instruction({local})[{position}]</code> where
-<code>{local}</code> is the name of the processing instruction node
-and <code>{position}</code> is an integer representing the position
-of the selected node among its like-named processing-instruction
-node siblings</p>
+<code>processing-instruction(<em>local</em>)[<em>position</em>]</code>
+where <code>
+                      <em>local</em>
+                    </code> is the name of the processing
+instruction node and <code>
+                      <em>position</em>
+                    </code> is an integer
+representing the position of the selected node among its like-named
+processing-instruction node siblings</p>
                 </li>
                 <li>
                   <p>For a namespace node:</p>
                   <ol class="enumla">
                     <li>
                       <p>If the namespace node has a name:
-<code>namespace::{prefix}</code>, where <code>{prefix}</code> is
-the local part of the name of the namespace node (which represents
-the namespace prefix).</p>
+<code>namespace::<em>prefix</em>
+                        </code>, where
+<code>
+                          <em>prefix</em>
+                        </code> is the local part of the name of the
+namespace node (which represents the namespace prefix).</p>
                     </li>
                     <li>
                       <p>If the namespace node has no name (that is, it represents the
 default namespace):
-<code>namespace::*["http://www.w3.org/2005/xpath-functions":local-name()=""]</code>
+<code>namespace::*[Q{http://www.w3.org/2005/xpath-functions}local-name()=""]</code>
                       </p>
                     </li>
                   </ol>
                 </li>
               </ol>
             </dd>
-            <dt class="label">Error Conditions</dt>
-            <dd>
-              <p>An error is raised [<a href="#ERRFODC0001" title="err:FODC0001">err:FODC0001</a>] if <code>$arg</code>, or the
-context item if the second argument is absent, is a node in a tree
-whose root is not a document node.</p>
-            </dd>
             <dt class="label">Examples</dt>
             <dd>
               <p>let <code>$e</code> :=</p>
@@ -22227,17 +22742,34 @@
               <p>The expression <code>fn:path($e)</code> returns
 <code>'/'</code>.</p>
               <p>The expression <code>fn:path($e/*:p)</code> returns
-<code>'/"http://example.com/one":p[1]'</code>.</p>
+<code>'/Q{http://example.com/one}p[1]'</code>.</p>
               <p>The expression <code>fn:path($e/*:p/@xml:lang)</code> returns
-<code>'/"http://example.com/one":p[1]/@"http://www.w3.org/XML/1998/namespace":lang'</code>.</p>
+<code>'/Q{http://example.com/one}p[1]/@Q{http://www.w3.org/XML/1998/namespace}lang'</code>.</p>
               <p>The expression <code>fn:path($e/*:p/@author)</code> returns
-<code>'/"http://example.com/one":p[1]/@author'</code>.</p>
+<code>'/Q{http://example.com/one}p[1]/@author'</code>.</p>
               <p>The expression <code>fn:path($e/*:p/*:br[2])</code> returns
-<code>'/"http://example.com/one":p[1]/"http://example.com/one":br[2]'</code>.</p>
+<code>'/Q{http://example.com/one}p[1]/Q{http://example.com/one}br[2]'</code>.</p>
               <p>The expression
 <code>fn:path($e//text()[starts-with(normalize-space(),
 'Tochter')])</code> returns
-<code>'/"http://example.com/one":p[1]/text()[2]'</code>.</p>
+<code>'/Q{http://example.com/one}p[1]/text()[2]'</code>.</p>
+              <p>let <code>$emp</code> :=</p>
+              <div class="exampleInner">
+                <pre>
+            &lt;employee xml:id="ID21256"&gt;
+               &lt;empnr&gt;E21256&lt;/empnr&gt;
+               &lt;first&gt;John&lt;/first&gt;
+               &lt;last&gt;Brown&lt;/last&gt;
+            &lt;/employee&gt;
+         
+</pre>
+              </div>
+              <p>The expression <code>fn:path($emp)</code> returns
+<code>'Q{http://www.w3.org/2005/xpath-functions}root()'</code>.</p>
+              <p>The expression <code>fn:path($emp/@xml:id)</code> returns
+<code>'Q{http://www.w3.org/2005/xpath-functions}root()/@Q{http://www.w3.org/XML/1998/namespace}id'</code>.</p>
+              <p>The expression <code>fn:path($emp/empnr)</code> returns
+<code>'Q{http://www.w3.org/2005/xpath-functions}root()/Q{}empnr[1]'</code>.</p>
             </dd>
           </dl>
         </div>
@@ -22294,25 +22826,36 @@
 (<code>.</code>). The behavior of the function if the argument is
 omitted is exactly the same as if the context item had been passed
 as the argument.</p>
-              <p>The result of the function call
-<code>fn:has-children($node)</code> is defined to be the same as
-the result of the expression <a href="#func-exists">
+              <p>
+                <span>Provided that the supplied argument <code>$node</code>
+matches the expected type <code>node()?</code>,</span> the result
+of the function call <code>fn:has-children($node)</code> is defined
+to be the same as the result of the expression <a href="#func-exists">
                   <code>fn:exists($node/child::node())</code>
                 </a>.</p>
             </dd>
             <dt class="label">Error Conditions</dt>
             <dd>
               <p>The following errors may be raised when <code>$node</code> is
-omitted: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                <sup>
-                  <small>DM30</small>
-                </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                  <small>XP</small>
-                </sup>.</p>
+omitted:</p>
+              <ul>
+                <li>
+                  <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                    <sup>
+                      <small>DM30</small>
+                    </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                      <small>XP30</small>
+                    </sup>
+                  </p>
+                </li>
+                <li>
+                  <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                      <small>XP30</small>
+                    </sup>.</p>
+                </li>
+              </ul>
             </dd>
             <dt class="label">Notes</dt>
             <dd>
@@ -22432,7 +22975,7 @@
               <p>The effect of the function call
 <code>fn:outermost($nodes)</code> is defined to be equivalent to
 the result of the expression <code>$nodes[not(ancestor::node()
-intersect $nodes)]</code>.</p>
+intersect $nodes)]/.</code>.</p>
               <p>That is, the function takes as input a sequence of nodes, and
 returns every node within the sequence that <span>does not have
 another node within the sequence as an ancestor</span>; the nodes
@@ -22445,7 +22988,7 @@
 does not correctly account for attribute nodes, as these are not
 descendants of their parent element.</p>
               <p>The motivation for the function was based on XSLT streaming use
-cases; there are cases where the <a href="#xslt-30">[XSL
+cases. There are cases where the <a href="#xslt-30">[XSL
 Transformations (XSLT) Version 3.0]</a> streaming rules allow the
 construct <code>outermost(//section)</code> but do not allow
 <code>//section</code>; the function can therefore be useful in
@@ -23340,16 +23883,27 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
-                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
-                  </a>,
-<a title="context-dependent" class="termref" href="#dt-context-dependent">
-                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
-                  </a>,
-and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
-                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
-                  </a>.
-It depends on collations.</p>
+                <p>The one-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and implicit timezone.</p>
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri, and implicit
+timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -23508,16 +24062,27 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
-                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
-                  </a>,
-<a title="context-dependent" class="termref" href="#dt-context-dependent">
-                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
-                  </a>,
-and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
-                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
-                  </a>.
-It depends on collations.</p>
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and implicit timezone.</p>
+                <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri, and implicit
+timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -23635,16 +24200,27 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
-                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
-                  </a>,
-<a title="context-dependent" class="termref" href="#dt-context-dependent">
-                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
-                  </a>,
-and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
-                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
-                  </a>.
-It depends on collations.</p>
+                <p>The two-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and implicit timezone.</p>
+                <p>The three-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri, and implicit
+timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -23695,8 +24271,21 @@
 eq node-name($i2))</code>.</p>
                       </li>
                       <li>
-                        <p>The two nodes are both annotated as having simple content or
-both nodes are annotated as having complex content.</p>
+                        <p>Either both nodes are both annotated as having simple content or
+both nodes are annotated as having complex content. For this
+purpose "simple content" means either a simple type or a complex
+type with simple content; "complex content" means a complex type
+whose variety is mixed, element-only, or empty.</p>
+                        <div class="note">
+                          <p class="prefix">
+                            <b>Note:</b>
+                          </p>
+                          <p>It is a consequence of this rule that validating a document
+<var>D</var> against a schema will usually (but not necessarily)
+result in a document that is not deep-equal to <var>D</var>. The
+exception is when the schema allows all elements to have mixed
+content.</p>
+                        </div>
                       </li>
                       <li>
                         <p>The two nodes have the same number of attributes, and for every
@@ -23708,25 +24297,27 @@
                         <p>One of the following conditions holds:</p>
                         <ul>
                           <li>
-                            <p>Both element nodes have a type annotation that is simple
-content, and the typed value of <code>$i1</code> is deep-equal to
-the typed value of <code>$i2</code>.</p>
-                          </li>
-                          <li>
-                            <p>Both element nodes have a type annotation that is complex
-content with elementOnly content, and each child element of
-<code>$i1</code> is deep-equal to the corresponding child element
-of <code>$i2</code>.</p>
-                          </li>
-                          <li>
-                            <p>Both element nodes have a type annotation that is complex
-content with mixed content, and the sequence
+                            <p>Both element nodes are annotated as having simple content
+<span>(as defined in 3(b) above)</span>, and the typed value of
+<code>$i1</code> is deep-equal to the typed value of
+<code>$i2</code>.</p>
+                          </li>
+                          <li>
+                            <p>Both element nodes have a type annotation that is <span>a
+complex type with variety element-only, and the sequence
+<code>$i1/*</code> is deep-equal to the sequence
+<code>$i2/*</code>.</span>
+                            </p>
+                          </li>
+                          <li>
+                            <p>Both element nodes have a type annotation that is <span>a
+complex type with variety mixed</span>, and the sequence
 <code>$i1/(*|text())</code> is deep-equal to the sequence
 <code>$i2/(*|text())</code>.</p>
                           </li>
                           <li>
-                            <p>Both element nodes have a type annotation that is complex
-content with empty content.</p>
+                            <p>Both element nodes have a type annotation that is <span>a
+complex type with variety empty</span>.</p>
                           </li>
                         </ul>
                       </li>
@@ -23787,8 +24378,8 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOTY0015" title="err:FOTY0015">err:FOTY0015</a>] if either input sequence contains
-a function item.</p>
+                <p>A <span>type</span> error is raised [<a href="#ERRFOTY0015" title="err:FOTY0015">err:FOTY0015</a>] if either input sequence
+contains a function item.</p>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
@@ -23950,8 +24541,8 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFORG0003" title="err:FORG0003">err:FORG0003</a>] if <code>$arg</code> contains more
-than one item.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORG0003" title="err:FORG0003">err:FORG0003</a>] if <code>$arg</code>
+contains more than one item.</p>
               </dd>
             </dl>
           </div>
@@ -23994,8 +24585,8 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFORG0004" title="err:FORG0004">err:FORG0004</a>] if <code>$arg</code> is an empty
-sequence.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORG0004" title="err:FORG0004">err:FORG0004</a>] if <code>$arg</code> is an
+empty sequence.</p>
               </dd>
             </dl>
           </div>
@@ -24038,8 +24629,8 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFORG0005" title="err:FORG0005">err:FORG0005</a>] if <code>$arg</code> is an empty
-sequence or a sequence containing more than one item.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFORG0005" title="err:FORG0005">err:FORG0005</a>] if <code>$arg</code> is an
+empty sequence or a sequence containing more than one item.</p>
               </dd>
             </dl>
           </div>
@@ -24546,16 +25137,27 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
-                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
-                  </a>,
-<a title="context-dependent" class="termref" href="#dt-context-dependent">
-                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
-                  </a>,
-and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
-                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
-                  </a>.
-It depends on collations.</p>
+                <p>The zero-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and implicit timezone.</p>
+                <p>The one-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri, and implicit
+timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -24696,16 +25298,27 @@
               </dd>
               <dt class="label">Properties</dt>
               <dd>
-                <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
-                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
-                  </a>,
-<a title="context-dependent" class="termref" href="#dt-context-dependent">
-                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
-                  </a>,
-and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
-                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
-                  </a>.
-It depends on collations.</p>
+                <p>The zero-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and implicit timezone.</p>
+                <p>The one-argument form of this function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                    <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                  </a>,
+<a title="context-dependent" class="termref" href="#dt-context-dependent">
+                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
+                  </a>,
+and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
+                    <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
+                  </a>.
+It depends on collations, and static base uri, and implicit
+timezone.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -24961,7 +25574,8 @@
                 <p>The expression <code>fn:sum((1 to 100)[. lt 0], 0)</code>
 returns <code>0</code>.</p>
                 <p>
-                  <code>fn:sum(($d1, 9E1))</code> raises an error [<a href="#ERRFORG0006" title="err:FORG0006">err:FORG0006</a>].</p>
+                  <code>fn:sum(($d1, 9E1))</code> raises a <span>type</span> error
+[<a href="#ERRFORG0006" title="err:FORG0006">err:FORG0006</a>].</p>
                 <p>The expression <code>fn:sum(($d1, $d2), "ein Augenblick")</code>
 returns <code>xs:yearMonthDuration("P20Y10M")</code>. <em>(There is
 no requirement that the <code>$zero</code> value should be the same
@@ -25174,20 +25788,29 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODC0001" title="err:FODC0001">err:FODC0001</a>] if <code>$node</code>, or the
-context item if the second argument is absent, is a node in a tree
-whose root is not a document node.</p>
-                <p>If the second argument is the context item, or is omitted, the
-following errors may be raised: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                  <sup>
-                    <small>DM30</small>
-                  </sup>,
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                    <small>XP</small>
-                  </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                    <small>XP</small>
-                  </sup>.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0001" title="err:FODC0001">err:FODC0001</a>] if <code>$node</code>, or
+the context item if the second argument is absent, is a node in a
+tree whose root is not a document node.</p>
+                <p>The following errors may be raised when <code>$node</code> is
+omitted:</p>
+                <ul>
+                  <li>
+                    <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                      <sup>
+                        <small>DM30</small>
+                      </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                        <small>XP30</small>
+                      </sup>
+                    </p>
+                  </li>
+                  <li>
+                    <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                        <small>XP30</small>
+                      </sup>.</p>
+                  </li>
+                </ul>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
@@ -25403,20 +26026,29 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODC0001" title="err:FODC0001">err:FODC0001</a>] if <code>$node</code>, or the
-context item if the second argument is omitted, is a node in a tree
-whose root is not a document node.</p>
-                <p>If the second argument is the context item, or is omitted, the
-following errors may be raised: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                  <sup>
-                    <small>DM30</small>
-                  </sup>,
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                    <small>XP</small>
-                  </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                    <small>XP</small>
-                  </sup>.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0001" title="err:FODC0001">err:FODC0001</a>] if <code>$node</code>, or
+the context item if the second argument is omitted, is a node in a
+tree whose root is not a document node.</p>
+                <p>The following errors may be raised when <code>$node</code> is
+omitted:</p>
+                <ul>
+                  <li>
+                    <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                      <sup>
+                        <small>DM30</small>
+                      </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                        <small>XP30</small>
+                      </sup>
+                    </p>
+                  </li>
+                  <li>
+                    <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                        <small>XP30</small>
+                      </sup>.</p>
+                  </li>
+                </ul>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
@@ -25606,20 +26238,29 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODC0001" title="err:FODC0001">err:FODC0001</a>] if <code>$node</code>, or the
-context item if the second argument is omitted, is a node in a tree
-whose root is not a document node.</p>
-                <p>If the second argument is the context item, or is omitted, the
-following errors may be raised: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                  <sup>
-                    <small>DM30</small>
-                  </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                    <small>XP</small>
-                  </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                    <small>XP</small>
-                  </sup>.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0001" title="err:FODC0001">err:FODC0001</a>] if <code>$node</code>, or
+the context item if the second argument is omitted, is a node in a
+tree whose root is not a document node.</p>
+                <p>The following errors may be raised when <code>$node</code> is
+omitted:</p>
+                <ul>
+                  <li>
+                    <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                      <sup>
+                        <small>DM30</small>
+                      </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                        <small>XP30</small>
+                      </sup>
+                    </p>
+                  </li>
+                  <li>
+                    <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                        <small>XP30</small>
+                      </sup>.</p>
+                  </li>
+                </ul>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
@@ -25727,16 +26368,25 @@
               <dt class="label">Error Conditions</dt>
               <dd>
                 <p>The following errors may be raised when <code>$arg</code> is
-omitted: if the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
-                  <sup>
-                    <small>DM30</small>
-                  </sup>
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                    <small>XP</small>
-                  </sup>; if
-the context item is not a node [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-                    <small>XP</small>
-                  </sup>.</p>
+omitted:</p>
+                <ul>
+                  <li>
+                    <p>If the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                      <sup>
+                        <small>DM30</small>
+                      </sup>,
+<span>dynamic error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                        <small>XP30</small>
+                      </sup>
+                    </p>
+                  </li>
+                  <li>
+                    <p>If the context item is not a node, <span>type error</span>
+[<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+                        <small>XP30</small>
+                      </sup>.</p>
+                  </li>
+                </ul>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
@@ -25807,15 +26457,15 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on available-documents.</p>
+It depends on available documents, and static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
                 <p>If <code>$uri</code> is the empty sequence, the result is an
 empty sequence.</p>
                 <p>If <code>$uri</code> is a relative URI reference, it is resolved
-relative to the value of the <span>Dynamic Base URI property from
-the dynamic context</span>. The resulting absolute URI is promoted
+relative to the value of the <span>Static Base URI property from
+the static context</span>. The resulting absolute URI is promoted
 to an <code>xs:string</code>.</p>
                 <p>If the <b>Available documents</b> described in <a href="http://www.w3.org/TR/xpath-30/#eval_context";>Section 2.1.2 Dynamic
 Context</a>
@@ -25842,7 +26492,7 @@
 determinism. The manner in which any such option is provided is
 implementation-defined. If the user has not selected such an
 option, a call of the function must either return a deterministic
-result or must raise an error [<a href="#ERRFODC0003" title="err:FODC0003">err:FODC0003</a>].</p>
+result or must raise a <span>dynamic</span> error [<a href="#ERRFODC0003" title="err:FODC0003">err:FODC0003</a>].</p>
                 <div class="note">
                   <p class="prefix">
                     <b>Note:</b>
@@ -25875,14 +26525,15 @@
                   </a>.</p>
                 <p>One possible processing model for this function is as follows.
 The resource identified by the URI Reference is retrieved. If the
-resource cannot be retrieved, an error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>]. The data
-resulting from the retrieval action is then parsed as an XML
-document and a tree is constructed in accordance with the <a href="#xpath-datamodel-30">[XQuery and XPath Data Model (XDM) 3.0]</a>.
+resource cannot be retrieved, a <span>dynamic</span> error is
+raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>]. The data resulting from the
+retrieval action is then parsed as an XML document and a tree is
+constructed in accordance with the <a href="#xpath-datamodel-30">[XQuery and XPath Data Model (XDM) 3.0]</a>.
 If the top-level media type is known and is "text", the content is
 parsed in the same way as if the media type were text/xml;
 otherwise, it is parsed in the same way as if the media type were
-application/xml. If the contents cannot be parsed successfully, an
-error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>]. Otherwise, the result of the
+application/xml. If the contents cannot be parsed successfully, a
+<span>dynamic</span> error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>]. Otherwise, the result of the
 function is the document node at the root of the resulting tree.
 This tree is then optionally validated against a schema.</p>
                 <p>Various aspects of this processing are <a title="implementation-defined" class="termref" href="#implementation-defined">
@@ -25924,16 +26575,17 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error <strong>may</strong> be raised [<a href="#ERRFODC0005" title="err:FODC0005">err:FODC0005</a>] if <code>$uri</code> is not
-a valid URI.</p>
-                <p>An error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if the <b>available documents</b>
-provides no mapping for the absolutized URI.</p>
-                <p>An error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if the resource cannot be
+                <p>A <span>dynamic</span> error <strong>may</strong> be raised
+[<a href="#ERRFODC0005" title="err:FODC0005">err:FODC0005</a>] if
+<code>$uri</code> is not a valid URI.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if the <b>available
+documents</b> provides no mapping for the absolutized URI.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if the resource cannot be
 retrieved or cannot be parsed successfully as XML.</p>
-                <p>An error is raised [<a href="#ERRFODC0003" title="err:FODC0003">err:FODC0003</a>] if the implementation is not able
-to guarantee that the result of the function will be deterministic,
-and the user has not indicated that an unstable result is
-acceptable.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0003" title="err:FODC0003">err:FODC0003</a>] if the implementation is not
+able to guarantee that the result of the function will be
+deterministic, and the user has not indicated that an unstable
+result is acceptable.</p>
               </dd>
             </dl>
           </div>
@@ -25972,7 +26624,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on collations.</p>
+It depends on available documents, and static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -25983,8 +26635,8 @@
                   </a>
 would return a document node, this function returns
 <code>true</code>.</p>
-                <p>An error is raised [<a href="#ERRFODC0005" title="err:FODC0005">err:FODC0005</a>] if <code>$uri</code> is not a
-valid URI according to the rules applied by the implementation of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0005" title="err:FODC0005">err:FODC0005</a>] if <code>$uri</code> is not
+a valid URI according to the rules applied by the implementation of
 <a href="#func-doc">
                     <code>fn:doc</code>
                   </a>.</p>
@@ -26044,25 +26696,25 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on available-collections.</p>
+It depends on available node collections, and static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
                 <p>This function takes an <code>xs:string</code> as argument and
 returns a sequence of nodes obtained by interpreting
 <code>$arg</code> as an <code>xs:anyURI</code> and resolving it
-according to the mapping specified in <b>Available collections</b>
-described in <a href="http://www.w3.org/TR/xpath-30/#id-xp-evaluation-context-components";>
+according to the mapping specified in <b>Available node
+collections</b> described in <a href="http://www.w3.org/TR/xpath-30/#id-xp-evaluation-context-components";>
 Section C.2 Dynamic Context Components</a>
                   <sup>
                     <small>XP30</small>
                   </sup>.</p>
-                <p>If <b>Available collections</b> provides a mapping from this
-string to a sequence of nodes, the function returns that sequence.
-If <b>Available collections</b> maps the string to an empty
-sequence, then the function returns an empty sequence.</p>
+                <p>If <b>Available node collections</b> provides a mapping from
+this string to a sequence of nodes, the function returns that
+sequence. If <b>Available node collections</b> maps the string to
+an empty sequence, then the function returns an empty sequence.</p>
                 <p>If <code>$arg</code> is not specified, the function returns the
-sequence of the nodes in the default collection in the dynamic
+sequence of the nodes in the default node collection in the dynamic
 context. See <a href="http://www.w3.org/TR/xpath-30/#id-xp-evaluation-context-components";>
 Section C.2 Dynamic Context Components</a>
                   <sup>
@@ -26084,34 +26736,34 @@
                     <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
                   </a>. If the user has not selected such an option,
 a call to this function must either return a deterministic result
-or must raise an error [<a href="#ERRFODC0003" title="err:FODC0003">err:FODC0003</a>].</p>
+or must raise a <span>dynamic</span> error [<a href="#ERRFODC0003" title="err:FODC0003">err:FODC0003</a>].</p>
                 <p>There is no requirement that the returned nodes should be in
 document order, nor is there a requirement that the result should
 contain no duplicates.</p>
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if no URI is supplied and the
-value of the default collection is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if no URI is supplied and
+the value of the default collection is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
                   <sup>
                     <small>DM30</small>
                   </sup>.</p>
-                <p>An error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if <b>available collections</b>
-provides no mapping for the absolutized URI.</p>
-                <p>An error is raised [<a href="#ERRFODC0004" title="err:FODC0004">err:FODC0004</a>] if <code>$arg</code> is not a
-valid <code>xs:anyURI</code>.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if <b>available node
+collections</b> provides no mapping for the absolutized URI.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0004" title="err:FODC0004">err:FODC0004</a>] if <code>$arg</code> is not
+a valid <code>xs:anyURI</code>.</p>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
                 <p>This function provides a facility for users to work with a
-collection of documents which may be contained in a directory or
-rows of a Relational table or other implementation-specific
-construct. An implementation may also use external variables to
-identify external resources, but <code>fn:collection</code>
-provides functionality not provided by external variables.
-Specifying resources using URIs is useful because URIs are dynamic,
-can be parameterized, and do not rely on an external
-environment.</p>
+collection of documents which may be contained in a directory, or
+in the rows of a relational table, or in some other
+implementation-specific construct. An implementation may also use
+external variables to identify external resources, but
+<code>fn:collection</code> provides functionality not provided by
+external variables. Specifying resources using URIs is useful
+because URIs are dynamic, can be parameterized, and do not rely on
+an external environment.</p>
               </dd>
             </dl>
           </div>
@@ -26122,7 +26774,7 @@
               <dt class="label">Summary</dt>
               <dd>
                 <p>Returns a sequence of <code>xs:anyURI</code> values representing
-the document URIs of the documents in a collection.</p>
+the URIs in a resource collection.</p>
               </dd>
               <dt class="label">Signatures</dt>
               <dd>
@@ -26152,66 +26804,63 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on available-collections.</p>
+It depends on available resource collections, and static base
+uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
-                <p>A collection, as returned by the <code>fn:collection</code>
-function, is in general a sequence of nodes. Some of these nodes
-may be document nodes, and some of these document nodes may have a
-non-empty document URI, accessible using the
-<code>fn:document-uri</code> function. The
-<code>fn:uri-collection</code> function returns a sequence of URIs,
-being the document URIs of those nodes in the collection that are
-document nodes and that have a document URI (other nodes in the
-collection are ignored). That is, in the absence of errors,
-<code>fn:uri-collection(X)</code> returns the same set of URIs as
-<a href="#func-collection">
-                    <code>fn:collection(X)/fn:document-uri()</code>
-                  </a>,
-though not necessarily in the same order.</p>
-                <p>The purpose in providing the function, however, is to allow the
-URIs of the documents in a collection to be retrieved without
-incurring the cost (which might be significant in some
-implementations) of dereferencing the URIs to obtain the actual
-nodes. Where required, the returned URIs can then be dereferenced
-by calling the <code>fn:doc</code> function.</p>
-                <p>The zero-argument form of the function returns the document URIs
-of the document nodes in the default collection.</p>
-                <p>The single-argument form returns the document URIs of the
-document nodes in the collection with a given collection URI. If
-the value of the argument is an empty sequence, the action is as
-for the zero-argument form of the function. If the argument is a
-relative URI reference, it is resolved against the <span>Dynamic
-Base URI property from the dynamic context</span>.</p>
-                <p>There is no requirement that the nodes in a collection should
-all be distinct, and therefore no requirement that the URIs in the
-result of this function should all be distinct.</p>
+                <p>The zero-argument form of the function returns the URIs in the
+<b>Default resource collection</b> described in <a href="http://www.w3.org/TR/xpath-30/#id-xp-evaluation-context-components";>
+Section C.2 Dynamic Context Components</a>
+                  <sup>
+                    <small>XP30</small>
+                  </sup>.</p>
+                <p>If the value of <code>$arg</code> is a relative
+<code>xs:anyURI</code>, it is resolved against the value of the
+base-URI property from the static context.</p>
+                <p>If <code>$arg</code> is the empty sequence, the function behaves
+as if it had been called without an argument. See above.</p>
+                <p>The single-argument form of the function returns the sequence of
+URIs corresponding to the supplied URI in the <b>Available resource
+collections</b> described in <a href="http://www.w3.org/TR/xpath-30/#id-xp-evaluation-context-components";>
+Section C.2 Dynamic Context Components</a>
+                  <sup>
+                    <small>XP30</small>
+                  </sup>.</p>
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if no URI is supplied and the
-value of the default collection is absent.</p>
-                <p>An error is raised [<a href="#ERRFODC0004" title="err:FODC0004">err:FODC0004</a>] if <b>available collections</b>
-provides no mapping for the absolutized URI.</p>
-                <p>An error is raised [<a href="#ERRFODC0004" title="err:FODC0004">err:FODC0004</a>] if <code>$arg</code> is not a
-valid <code>xs:anyURI</code>.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if no URI is supplied (that
+is, if the the function is called with no arguments, or with a
+single argument that evaluates to an empty sequence), and the value
+of the default resource collection is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+                  <sup>
+                    <small>DM30</small>
+                  </sup>.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0002" title="err:FODC0002">err:FODC0002</a>] if <b>available resource
+collections</b> provides no mapping for the absolutized URI.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0004" title="err:FODC0004">err:FODC0004</a>] if <code>$arg</code> is not
+a valid <code>xs:anyURI</code>.</p>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
-                <p>
-                  <em>This explanation of the function is confusing and needs to
-be improved: it is the subject of an open bug report (<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=14971";>#14971</a>).
-In particular, the description of how it works is not supportive
-one of the use cases, which is to access a collection of unparsed
-text files.</em>
-                </p>
-                <p>There are several reasons it might be appriopriate to retrieve
-the URIs of the documents in a collection without retrieving the
-documents themselves. For example:</p>
+                <p>There are several reasons why it might be appropriate to use
+this function in preference to the <a href="#func-collection">
+                    <code>fn:collection</code>
+                  </a> function:</p>
                 <ul>
                   <li>
-                    <p>In XSLT it allows the documents to be processed in streaming
+                    <p>It allows resources to be retrieved that are not well-formed XML
+documents: for example, the returned URIs might be referenced using
+the <a href="#func-unparsed-text">
+                        <code>fn:unparsed-text</code>
+                      </a>
+function rather than the <a href="#func-doc">
+                        <code>fn:doc</code>
+                      </a> function.</p>
+                  </li>
+                  <li>
+                    <p>In XSLT 3.0 it allows the documents to be processed in streaming
 mode using the <code>xsl:stream</code> instruction.</p>
                   </li>
                   <li>
@@ -26224,13 +26873,42 @@
                   <li>
                     <p>It allows selection of which documents to read based on their
 URI, for example they can be filtered to select those whose URIs
-end in <code>.xml</code>.</p>
+end in <code>.xml</code>, or those that use the <code>https</code>
+scheme.</p>
+                  </li>
+                  <li>
+                    <p>An application might choose to limit the number of URIs
+processed in a single run, for example it might process only the
+first 50 URIs in the collection; or it might present the URIs to
+the user and allow the user to select which of them need to be
+further processed.</p>
+                  </li>
+                  <li>
+                    <p>It allows the URIs to be modified before they are dereferenced,
+for example by adding or removing query parameters, or by
+redirecting the request to a local cache or to a mirror site.</p>
                   </li>
                 </ul>
-                <p>However, there may be collections that cannot be processed in
-this way: specifically, those that contain nodes other than
-document nodes, and those that contain document nodes having no
-document URI.</p>
+                <p>For some of these use cases, this assumes that the cost of
+calling <a href="#func-collection">
+                    <code>fn:collection</code>
+                  </a>
+might be significant (for example, it might involving retrieving
+all the documents in the collection over the network and parsing
+them). This will not necessarily be true of all
+implementations.</p>
+                <p>Some implementations might ensure that calling
+<code>fn:uri-collection</code> and then applying <a href="#func-doc">
+                    <code>fn:doc</code>
+                  </a> to each of the returned URIs
+delivers the same result as calling <a href="#func-collection">
+                    <code>fn:collection</code>
+                  </a> with the same
+argument; however, this is not guaranteed.</p>
+                <p>There is no requirement that the URIs returned by this function
+should all be distinct, and no assumptions can be made about the
+order of URIs in the sequence, unless the implementation defines
+otherwise.</p>
               </dd>
             </dl>
           </div>
@@ -26242,8 +26920,8 @@
               <dt class="label">Summary</dt>
               <dd>
                 <p>The <code>fn:unparsed-text</code> function reads an external
-resource (for example, a file) and returns its contents as a
-string.</p>
+resource (for example, a file) and returns <span>a string
+representation of the resource</span>.</p>
               </dd>
               <dt class="label">Signatures</dt>
               <dd>
@@ -26277,16 +26955,24 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on base-uri.</p>
+It depends on static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
                 <p>The <code>$href</code> argument <strong>must</strong> be a
 string in the form of a URI reference, which <strong>must</strong>
 contain no fragment identifier, and <strong>must</strong> identify
-a resource that can be read as text. If the URI is a relative URI
-reference, then it is resolved relative to the <span>Dynamic Base
-URI property from the dynamic context</span>.</p>
+a resource <span>for which a string representation is
+available</span>. If the URI is a relative URI reference, then it
+is resolved relative to the <span>Static Base URI property from the
+static context</span>.</p>
+                <p>The mapping of URIs to the string representation of a resource
+is the mapping defined in the <a href="http://www.w3.org/TR/xpath-30/#dt-available-text-resources";>available
+text resources</a>
+                  <sup>
+                    <small>XP30</small>
+                  </sup> component of the
+dynamic context.</p>
                 <p>If the value of the <code>$href</code> argument is an empty
 sequence, the function returns an empty sequence.</p>
                 <p>The <code>$encoding</code> argument, if present, is the name of
@@ -26325,25 +27011,27 @@
                     <p>UTF-8 is assumed.</p>
                   </li>
                 </ol>
-                <p>The result of the function is a string containing the text of
-the resource retrieved using the URI.</p>
+                <p>The result of the function is a string containing the
+<span>string representation</span> of the resource retrieved using
+the URI.</p>
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFOUT1170" title="err:FOUT1170">err:FOUT1170</a>] if <code>$href</code> contains a
-fragment identifier, or if it cannot be used to retrieve a resource
-containing text.</p>
-                <p>An error is raised [<a href="#ERRFOUT1190" title="err:FOUT1190">err:FOUT1190</a>] if the retrieved resource contains
-octets that cannot be decoded into Unicode <a title="character" class="termref" href="#character">
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOUT1170" title="err:FOUT1170">err:FOUT1170</a>] if <code>$href</code>
+contains a fragment identifier, or if it cannot be used to retrieve
+the <span>string representation</span> of a resource.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOUT1190" title="err:FOUT1190">err:FOUT1190</a>] <span>if the value of the
+<code>$encoding</code> argument is not a valid encoding
+name,</span> if the <a title="" class="termref" href="#">
+                    <span class="arrow">·</span>processor<span class="arrow">·</span>
+                  </a> does not support the specified encoding, if
+the <span>string representation</span> of the retrieved resource
+contains octets that cannot be decoded into Unicode <a title="character" class="termref" href="#character">
                     <span class="arrow">·</span>characters<span class="arrow">·</span>
                   </a> using
 the specified encoding, or if the resulting characters are not
-permitted XML characters. This includes the case where the
-<a title="" class="termref" href="#">
-                    <span class="arrow">·</span>processor<span class="arrow">·</span>
-                  </a> does not
-support the requested encoding.</p>
-                <p>An error is raised [<a href="#ERRFOUT1200" title="err:FOUT1200">err:FOUT1200</a>] if <code>$encoding</code> is
+permitted XML characters.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFOUT1200" title="err:FOUT1200">err:FOUT1200</a>] if <code>$encoding</code> is
 absent and the <a title="" class="termref" href="#">
                     <span class="arrow">·</span>processor<span class="arrow">·</span>
                   </a> cannot
@@ -26359,6 +27047,45 @@
                     <code>fn:resolve-uri</code>
                   </a> function before
 passing it to the <code>fn:unparsed-text</code> function.</p>
+                <p>There is no essential relationship between the sets of URIs
+accepted by the two functions <code>fn:unparsed-text</code> and
+<a href="#func-doc">
+                    <code>fn:doc</code>
+                  </a> (a URI accepted by one
+may or may not be accepted by the other), and if a URI is accepted
+by both there is no essential relationship between the results
+(different resource representations are permitted by the
+architecture of the web).</p>
+                <p>There are no constraints on the MIME type of the resource.</p>
+                <p>The fact that the resolution of URIs is defined by a mapping in
+the dynamic context means that in effect, various aspects of the
+behavior of this function are <a title="implementation-defined" class="termref" href="#implementation-defined">
+                    <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+                  </a>. Implementations may provide external
+configuration options that allow any aspect of the processing to be
+controlled by the user. In particular:</p>
+                <ul>
+                  <li>
+                    <p>The set of URI schemes that the implementation recognizes is
+implementation-defined. Implementations may allow the mapping of
+URIs to resources to be configured by the user, using mechanisms
+such as catalogs or user-written URI handlers.</p>
+                  </li>
+                  <li>
+                    <p>The handling of media types is implementation-defined.</p>
+                  </li>
+                  <li>
+                    <p>Implementations may provide user-defined error handling options
+that allow processing to continue following an error in retrieving
+a resource, or in reading its content. When errors have been
+handled in this way, the function may return a fallback document
+provided by the error handler.</p>
+                  </li>
+                  <li>
+                    <p>Implementations may provide user options that relax the
+requirement for the function to return deterministic results.</p>
+                  </li>
+                </ul>
                 <p>The rules for determining the encoding are chosen for
 consistency with <a href="#xinclude">[XML Inclusions (XInclude)
 Version 1.0 (Second Edition)]</a>. Files with an XML media type are
@@ -26406,7 +27133,8 @@
               <dd>
                 <p>The <code>fn:unparsed-text-lines</code> function reads an
 external resource (for example, a file) and returns its contents as
-a sequence of strings, one for each line of text in the file.</p>
+a sequence of strings, one for each line of text in the
+<span>string representation</span> of the resource.</p>
               </dd>
               <dt class="label">Signatures</dt>
               <dd>
@@ -26456,13 +27184,14 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on base-uri.</p>
+It depends on static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
                 <p>The <code>unparsed-text-lines</code> function reads an external
-resource (for example, a file) and returns its contents as a
-sequence of strings, separated at newline boundaries.</p>
+resource (for example, a file) and returns its <span>string
+representation</span> as a sequence of strings, separated at
+newline boundaries.</p>
                 <p>The result of the single-argument function is the same as the
 result of the expression <a href="#func-tokenize">
                     <code>fn:tokenize(fn:unparsed-text($href),
@@ -26559,7 +27288,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on base-uri.</p>
+It depends on static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -26567,8 +27296,7 @@
 whether a call on the <code>fn:unparsed-text</code> function with
 identical arguments would return a string.</p>
                 <p>If the first argument is an empty sequence, the function returns
-false. If the second argument is an empty sequence, the function
-behaves as if the second argument were omitted.</p>
+false.</p>
                 <p>In other cases, the function returns true if a call on
 <code>fn:unparsed-text</code> with the same arguments would
 succeed, and false if a call on <code>fn:unparsed-text</code> with
@@ -26642,7 +27370,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on environment-variables.</p>
+It depends on environment variables.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -26742,7 +27470,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on environment-variables.</p>
+It depends on environment variables.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -26796,7 +27524,7 @@
                     <code class="function">fn:parse-xml</code>(<code class="arg">$arg</code>
                     <code class="as"> as </code>
                     <code class="type">xs:string?</code>)<code class="as"> as </code>
-                    <code class="return-type">document-node(element(*))</code>
+                    <code class="return-type">document-node(element(*))?</code>
                   </div>
                 </div>
               </dd>
@@ -26811,7 +27539,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on base-uri.</p>
+It depends on static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -26824,7 +27552,7 @@
 whether DTD and/or schema validation is invoked, and it is
 implementation-defined whether an XML 1.0 or XML 1.1 parser is
 used.</p>
-                <p>The Dynamic Base URI property from the dynamic context of the
+                <p>The Static Base URI property from the static context of the
 <code>fn:parse-xml</code> function call is used both as the base
 URI used by the XML parser to resolve relative entity references
 within the document, and as the base URI of the document node that
@@ -26843,12 +27571,12 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODC0006" title="err:FODC0006">err:FODC0006</a>] if the content of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0006" title="err:FODC0006">err:FODC0006</a>] if the content of
 <code>$arg</code> is not a well-formed and namespace-well-formed
 XML document.</p>
-                <p>An error is raised [<a href="#ERRFODC0006" title="err:FODC0006">err:FODC0006</a>] if DTD-based validation is carried
-out and the content of <code>$arg</code> is not valid against its
-DTD.</p>
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0006" title="err:FODC0006">err:FODC0006</a>] if DTD-based validation is
+carried out and the content of <code>$arg</code> is not valid
+against its DTD.</p>
               </dd>
               <dt class="label">Notes</dt>
               <dd>
@@ -26921,7 +27649,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                     <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                   </a>.
-It depends on base-uri.</p>
+It depends on static base uri.</p>
               </dd>
               <dt class="label">Rules</dt>
               <dd>
@@ -26929,17 +27657,17 @@
 the empty sequence.</p>
                 <p>The input must be a namespace-well-formed external general
 parsed entity. More specifically, it must be a string conforming to
-the production rule <a href="http://www.w3.org/TR/REC-xml/#";>[NT IN
-xml]extParsedEnt</a>
+the production rule <a href="http://www.w3.org/TR/REC-xml/#NT-extParsedEnt";>extParsedEnt</a>
                   <sup>
                     <small>xml</small>
-                  </sup> in <a href="#REC-xml">[REC-xml]</a>, it must contain no entity references
-other that references to predefined entities, and it must satisfy
-all the rules of <a href="#REC-xml-names">[Namespaces in XML]</a>
-for namespace-well-formed documents with the exception that the
-rule requiring it to be a well-formed document is replaced by the
-rule requiring it to be a well-formed external general parsed
-entity.</p>
+                  </sup>
+in <a href="#REC-xml">[REC-xml]</a>, it must contain no entity
+references other than references to predefined entities, and it
+must satisfy all the rules of <a href="#REC-xml-names">[Namespaces
+in XML]</a> for namespace-well-formed documents with the exception
+that the rule requiring it to be a well-formed document is replaced
+by the rule requiring it to be a well-formed external general
+parsed entity.</p>
                 <p>The string is parsed to form a sequence of nodes which become
 children of the new document node, in the same way as the content
 of any element is converted into a sequence of children for the
@@ -26950,12 +27678,10 @@
 <a title="implementation-defined" class="termref" href="#implementation-defined">
                     <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
                   </a>. In particular, it is implementation-defined
-whether whether an XML 1.0 or XML 1.1 parser is used.</p>
-                <p>The Dynamic Base URI from the dynamic context of the
-<code>fn:parse-xml-fragment</code> function call is used both as
-the base URI used by the XML parser to resolve relative entity
-references within the document, and as the base URI of the document
-node that is returned.</p>
+whether an XML 1.0 or XML 1.1 parser is used.</p>
+                <p>The Static Base URI from the static context of the
+<code>fn:parse-xml-fragment</code> function call is used as the
+base URI of the document node that is returned.</p>
                 <p>The document URI of the returned node is <a title="" class="termref" href="#">
                     <span class="arrow">·</span>absent<span class="arrow">·</span>
                   </a>.</p>
@@ -26970,7 +27696,7 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
-                <p>An error is raised [<a href="#ERRFODC0006" title="err:FODC0006">err:FODC0006</a>] if the content of
+                <p>A <span>dynamic</span> error is raised [<a href="#ERRFODC0006" title="err:FODC0006">err:FODC0006</a>] if the content of
 <code>$arg</code> is not a well-formed external general parsed
 entity, if it contains entity references other than references to
 predefined entities, or if a document that incorporates this
@@ -27023,15 +27749,14 @@
 string value is a single space.</p>
                 <p>The expression <code>fn:parse-xml-fragment('&lt;xml
 version="1.0" encoding="utf8"
-standalone="yes"?&gt;&lt;/a&gt;")</code> results in an error
-[<a href="#ERRFODC0006" title="err:FODC0006">err:FODC0006</a>]
-because the "standalone" keyword is not permitted in the text
-declaration that appears at the start of an external general parsed
-entity. (Thus, it is not the case that any input accepted by the
-<a href="#func-parse-xml">
+standalone="yes"?&gt;&lt;/a&gt;")</code> results in a
+<span>dynamic</span> error [<a href="#ERRFODC0006" title="err:FODC0006">err:FODC0006</a>] because the "standalone" keyword
+is not permitted in the text declaration that appears at the start
+of an external general parsed entity. (Thus, it is not the case
+that any input accepted by the <a href="#func-parse-xml">
                     <code>fn:parse-xml</code>
-                  </a> function
-will also be accepted by <code>fn:parse-xml-fragment</code>.)</p>
+                  </a> function will also
+be accepted by <code>fn:parse-xml-fragment</code>.)</p>
               </dd>
             </dl>
           </div>
@@ -27123,6 +27848,9 @@
               </dd>
               <dt class="label">Error Conditions</dt>
               <dd>
+                <p>If the host language makes serialization an optional feature and
+the implementation does not support serialization, then a dynamic
+error [<a href="#ERRFODC0010" title="err:FODC0010">err:FODC0010</a>] is raised.</p>
                 <p>The serialization process will raise an error if
 <code>$arg</code> is an attribute or namespace node.</p>
                 <p>If any serialization error occurs, including the detection of an
@@ -27152,8 +27880,8 @@
                 <p>let <code>$params</code> :=</p>
                 <div class="exampleInner">
                   <pre>
-&lt;output:serialization-parameters&gt;
-  &lt;output:omit-xml-declaration&gt;yes&lt;/output:omit-xml-declaration&gt;
+&lt;output:serialization-parameters xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"&gt;
+  &lt;output:omit-xml-declaration value="yes"/&gt;
 &lt;/output:serialization-parameters&gt;
          
 </pre>
@@ -27177,7 +27905,7 @@
         <h2>
           <a name="context" id="context"/>15 Context functions</h2>
         <p>The following functions are defined to obtain information from
-the dynamic context.</p>
+the <span>static or</span> dynamic context.</p>
         <table summary="Function/operator summary" border="1">
           <thead>
             <tr>
@@ -27250,8 +27978,8 @@
                   <code>fn:static-base-uri</code>
                 </a>
               </td>
-              <td>Despite its name, this function returns the value of the
-Dynamic Base URI property from the dynamic context.</td>
+              <td>This function returns the value of the Static Base URI property
+from the static context.</td>
             </tr>
           </tbody>
         </table>
@@ -27296,10 +28024,10 @@
             </dd>
             <dt class="label">Error Conditions</dt>
             <dd>
-              <p>An error is raised [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup> if the
-context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+              <p>A <span>dynamic</span> error is raised [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                  <small>XP30</small>
+                </sup> if
+the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
                 <sup>
                   <small>DM30</small>
                 </sup>.</p>
@@ -27345,10 +28073,10 @@
             </dd>
             <dt class="label">Error Conditions</dt>
             <dd>
-              <p>An error is raised [<a href="http://www.w3.org/TR/xpath20/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
-                  <small>XP</small>
-                </sup> if the
-context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
+              <p>A <span>dynamic</span> error is raised [<a href="http://www.w3.org/TR/xpath-30/#ERRXPDY0002"; title="err:XPDY0002">err:XPDY0002</a>]<sup>
+                  <small>XP30</small>
+                </sup> if
+the context item is <a href="http://www.w3.org/TR/xpath-datamodel-30/#dt-absent";>absent</a>
                 <sup>
                   <small>DM30</small>
                 </sup>.</p>
@@ -27388,7 +28116,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                   <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                 </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
             </dd>
             <dt class="label">Rules</dt>
             <dd>
@@ -27401,12 +28129,11 @@
 <code>xs:dateTime</code> that is current at some time during the
 evaluation of a query or transformation in which
 <code>fn:current-dateTime</code> is executed.</p>
-              <p>This function is <a title="" class="termref" href="#">
-                  <span class="arrow">·</span>
-                  <span class="arrow">·</span>
-                </a>.
-The precise instant during the query or transformation represented
-by the value of <code>fn:current-dateTime()</code> is <a title="implementation dependent" class="termref" href="#implementation-dependent">
+              <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                  <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                </a>. The
+precise instant during the query or transformation represented by
+the value of <code>fn:current-dateTime()</code> is <a title="implementation dependent" class="termref" href="#implementation-dependent">
                   <span class="arrow">·</span>implementation dependent<span class="arrow">·</span>
                 </a>.</p>
               <p>If the implementation supports data types from XSD 1.1 then the
@@ -27461,7 +28188,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                   <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                 </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
             </dd>
             <dt class="label">Rules</dt>
             <dd>
@@ -27469,12 +28196,11 @@
 <code>xs:date</code> (with timezone) that is current at some time
 during the evaluation of a query or transformation in which
 <code>fn:current-date</code> is executed.</p>
-              <p>This function is <a title="" class="termref" href="#">
-                  <span class="arrow">·</span>
-                  <span class="arrow">·</span>
-                </a>.
-The precise instant during the query or transformation represented
-by the value of <code>fn:current-date</code> is <a title="implementation dependent" class="termref" href="#implementation-dependent">
+              <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                  <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                </a>. The
+precise instant during the query or transformation represented by
+the value of <code>fn:current-date</code> is <a title="implementation dependent" class="termref" href="#implementation-dependent">
                   <span class="arrow">·</span>implementation dependent<span class="arrow">·</span>
                 </a>.</p>
             </dd>
@@ -27523,7 +28249,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                   <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                 </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
             </dd>
             <dt class="label">Rules</dt>
             <dd>
@@ -27531,12 +28257,11 @@
 <code>xs:time</code> (with timezone) that is current at some time
 during the evaluation of a query or transformation in which
 <code>fn:current-time</code> is executed.</p>
-              <p>This function is <a title="" class="termref" href="#">
-                  <span class="arrow">·</span>
-                  <span class="arrow">·</span>
-                </a>.
-The precise instant during the query or transformation represented
-by the value of <code>fn:current-time()</code> is <a title="implementation dependent" class="termref" href="#implementation-dependent">
+              <p>This function is <a title="deterministic" class="termref" href="#dt-deterministic">
+                  <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+                </a>. The
+precise instant during the query or transformation represented by
+the value of <code>fn:current-time()</code> is <a title="implementation dependent" class="termref" href="#implementation-dependent">
                   <span class="arrow">·</span>implementation dependent<span class="arrow">·</span>
                 </a>.</p>
             </dd>
@@ -27585,7 +28310,7 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                   <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                 </a>.
-It depends on implicit-timezone.</p>
+It depends on implicit timezone.</p>
             </dd>
             <dt class="label">Rules</dt>
             <dd>
@@ -27656,8 +28381,8 @@
           <dl>
             <dt class="label">Summary</dt>
             <dd>
-              <p>Despite its name, this function returns the value of the Dynamic
-Base URI property from the dynamic context.</p>
+              <p>This function returns the value of the Static Base URI property
+from the static context.</p>
             </dd>
             <dt class="label">Signature</dt>
             <dd>
@@ -27679,39 +28404,28 @@
 and <a title="focus-dependent" class="termref" href="#dt-focus-independent">
                   <span class="arrow">·</span>focus-independent<span class="arrow">·</span>
                 </a>.
-It depends on base-uri.</p>
+It depends on static base uri.</p>
             </dd>
             <dt class="label">Rules</dt>
             <dd>
-              <p>The function returns the value of the Dynamic Base URI property
-from the dynamic context. If the property is absent, the empty
+              <p>The function returns the value of the Static Base URI property
+from the static context. If the property is absent, the empty
 sequence is returned.</p>
-              <p>Components of the dynamic context are discussed in [TITLE OF
-XP30 SPEC, TITLE OF id-xp-eval-context
-SECTION]<sup>
+              <p>Components of the static context are discussed in <a href="http://www.w3.org/TR/xpath-30/#eval_context";>Section 2.1.2 Dynamic
+Context</a>
+                <sup>
                   <small>XP30</small>
                 </sup> .</p>
             </dd>
             <dt class="label">Notes</dt>
             <dd>
-              <p>The name of this function is misleading. In Query 1.0 and XPath
-2.0, no distinction was made between the static base URI and the
-dynamic base URI; it was assumed that the location where a query is
-compiled and the location where it is executed would be the same.
-In the 3.0 specifications it is acknowledged that these locations
-may be different. References to resources used during analysis (for
-example, module location hints in XQuery) are interpreted as
-relative to the static base URI, while references to resources used
-during evaluation (for example, URIs passed to the <a href="#func-doc">
-                  <code>fn:doc</code>
-                </a> or <a href="#func-collection">
-                  <code>fn:collection</code>
-                </a> functions) are
-interpreted as relative to the dynamic base URI. Since the use
-cases for this function relate primarily to the need to locate
-resources during evaluation, it has been defined in this release to
-access the dynamic base URI, despite the choice of function
-name.</p>
+              <p>XQuery 3.0 and XSLT 3.0 give an implementation freedom to use
+different base URIs during the static analysis phase and the
+dynamic evaluation phase, that is, for compile-time and run-time
+resources respectively. In this situation, the
+<code>fn:static-base-uri</code> function should return a URI
+suitable for locating resources needed during dynamic
+evaluation.</p>
             </dd>
           </dl>
         </div>
@@ -27779,7 +28493,7 @@
                     <code class="type">xs:QName</code>, <code class="arg">$arity</code>
                     <code class="as"> as </code>
                     <code class="type">xs:integer</code>)<code class="as"> as </code>
-                    <code class="return-type">function()?</code>
+                    <code class="return-type">function(*)?</code>
                   </div>
                 </div>
               </dd>
@@ -27812,20 +28526,6 @@
                     <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
                   </a>.</p>
               </dd>
-              <dt class="label">Error Conditions</dt>
-              <dd>
-                <p>If the function that is identified is <a title="context-dependent" class="termref" href="#dt-context-dependent">
-                    <span class="arrow">·</span>context-dependent<span class="arrow">·</span>
-                  </a>,
-<code>fn:function-lookup</code> returns a function whose name and
-signature match those of the requested function, but whose
-implementation is a call on the <a href="#func-error">
-                    <code>fn:error</code>
-                  </a> function, so that any
-attempt to call the returned function fails with a dynamic error
-[<a href="#ERRFOFL0001" title="err:FOFL0001">err:FOFL0001</a>]
-occurs</p>
-              </dd>
               <dt class="label">Notes</dt>
               <dd>
                 <p>This function can be useful where there is a need to make a
@@ -27843,6 +28543,12 @@
 available, whereas getting the function using
 <code>fn:function-lookup</code> allows the caller to take fallback
 action in this situation.</p>
+                <p>If the function that is retrieved by
+<code>fn:function-lookup</code> has dependencies on the static or
+dynamic context, the context that applies is the static and/or
+dynamic context of the call to the <code>fn:function-lookup</code>
+function itself. The context thus effectively forms part of the
+closure of the returned function.</p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
@@ -27990,8 +28696,8 @@
             <tbody>
               <tr>
                 <td>
-                  <a href="#func-map">
-                    <code>fn:map</code>
+                  <a href="#func-for-each">
+                    <code>fn:for-each</code>
                   </a>
                 </td>
                 <td>Applies the function item <var>$f</var> to every item from the
@@ -28029,8 +28735,8 @@
               </tr>
               <tr>
                 <td>
-                  <a href="#func-map-pairs">
-                    <code>fn:map-pairs</code>
+                  <a href="#func-for-each-pair">
+                    <code>fn:for-each-pair</code>
                   </a>
                 </td>
                 <td>Applies the function item <var>$f</var> to successive pairs of
@@ -28042,7 +28748,8 @@
           </table>
           <div class="div3">
             <h4>
-              <a name="func-map" id="func-map"/>16.2.1 fn:map</h4>
+              <a name="func-for-each" id="func-for-each"/>16.2.1
+fn:for-each</h4>
             <dl>
               <dt class="label">Summary</dt>
               <dd>
@@ -28054,12 +28761,12 @@
               <dd>
                 <div class="exampleInner">
                   <div class="proto">
-                    <code class="function">fn:map</code>(<code class="arg">$f</code>
+                    <code class="function">fn:for-each</code>(<code class="arg">$seq</code>
+                    <code class="as"> as </code>
+                    <code class="type">item()*</code>, <code class="arg">$f</code>
                     <code class="as"> as </code>
                     <code class="type">function(item()) as
-item()*</code>, <code class="arg">$seq</code>
-                    <code class="as"> as </code>
-                    <code class="type">item()*</code>)<code class="as"> as </code>
+item()*</code>)<code class="as"> as </code>
                     <code class="return-type">item()*</code>
                   </div>
                 </div>
@@ -28081,21 +28788,21 @@
 implementation in XQuery:</p>
                 <div class="exampleInner">
                   <pre>
-declare function fn:map($f, $seq) {
+declare function fn:for-each($seq, $f) {
   if (fn:empty($seq))
   then ()
-  else $f(fn:head($seq)), fn:map($f, fn:tail($seq))
+  else $f(fn:head($seq)), fn:for-each(fn:tail($seq), $f)
 };
 </pre>
                 </div>
                 <p>or its equivalent in XSLT:</p>
                 <div class="exampleInner">
                   <pre>
-&lt;xsl:function name="fn:map"&gt;
-  &lt;xsl:param name="f"/&gt;
+&lt;xsl:function name="fn:for-each"&gt;
   &lt;xsl:param name="seq/&gt;
+  &lt;xsl:param name="f"/&gt;
   &lt;xsl:if test="fn:exists($seq)"&gt;
-    &lt;xsl:sequence select="$f(fn:head($seq)), fn:map($f, fn:tail($seq))"/&gt;
+    &lt;xsl:sequence select="$f(fn:head($seq)), fn:for-each(fn:tail($seq), $f)"/&gt;
   &lt;/xsl:if&gt;
 &lt;/xsl:function&gt;
          
@@ -28104,20 +28811,21 @@
               </dd>
               <dt class="label">Notes</dt>
               <dd>
-                <p>The function call <code>fn:map($F, $SEQ)</code> is equivalent to
-the expression <code>for $i in $SEQ return $F($i)</code>
-                  <span>,
-assuming that ordering mode is <code>ordered</code>.</span>
+                <p>The function call <code>fn:for-each($SEQ, $F)</code> is
+equivalent to the expression <code>for $i in $SEQ return
+$F($i)</code>
+                  <span>, assuming that ordering mode is
+<code>ordered</code>.</span>
                 </p>
               </dd>
               <dt class="label">Examples</dt>
               <dd>
-                <p>The expression <code>fn:map(function($a) { $a * $a }, 1 to
-5)</code> returns <code>(1, 4, 9, 16, 25)</code>.</p>
-                <p>The expression <code>fn:map(fn:string-to-codepoints#1, ("john",
-"jane"))</code> returns <code>(106, 111, 104, 110, 106, 97, 110,
-101)</code>.</p>
-                <p>The expression <code>fn:map(xs:int#1, ("23", "29"))</code>
+                <p>The expression <code>fn:for-each(1 to 5, function($a) { $a * $a
+})</code> returns <code>(1, 4, 9, 16, 25)</code>.</p>
+                <p>The expression <code>fn:for-each(("john", "jane"),
+fn:string-to-codepoints#1)</code> returns <code>(106, 111, 104,
+110, 106, 97, 110, 101)</code>.</p>
+                <p>The expression <code>fn:for-each(("23", "29"), xs:int#1)</code>
 returns <code>(23, 29)</code>.</p>
               </dd>
             </dl>
@@ -28136,12 +28844,12 @@
               <dd>
                 <div class="exampleInner">
                   <div class="proto">
-                    <code class="function">fn:filter</code>(<code class="arg">$f</code>
+                    <code class="function">fn:filter</code>(<code class="arg">$seq</code>
+                    <code class="as"> as </code>
+                    <code class="type">item()*</code>, <code class="arg">$f</code>
                     <code class="as"> as </code>
                     <code class="type">function(item()) as
-xs:boolean</code>, <code class="arg">$seq</code>
-                    <code class="as"> as </code>
-                    <code class="type">item()*</code>)<code class="as"> as </code>
+xs:boolean</code>)<code class="as"> as </code>
                     <code class="return-type">item()*</code>
                   </div>
                 </div>
@@ -28164,13 +28872,13 @@
                 <div class="exampleInner">
                   <pre>
 declare function fn:filter(
-        $f as function(item()) as xs:boolean, 
-        $seq as item()*)
+        $seq as item()*,
+        $f as function(item()) as xs:boolean)
         as item()* {
   if (fn:empty($seq))
   then ()
   else ( fn:head($seq)[$f(.) eq fn:true()], 
-         fn:filter($f, fn:tail($seq))
+         fn:filter(fn:tail($seq), $f)
        )
 };
 </pre>
@@ -28179,10 +28887,10 @@
                 <div class="exampleInner">
                   <pre>
 &lt;xsl:function name="fn:filter" as="item()*"&gt;
+  &lt;xsl:param name="seq" as="item()*"/&gt;
   &lt;xsl:param name="f" as="function(item()) as xs:boolean"/&gt;
-  &lt;xsl:param name="seq" as="item()*"/&gt;
   &lt;xsl:if test="fn:exists($seq)"&gt;
-    &lt;xsl:sequence select="fn:head($seq)[$f(.) eq fn:true()], fn:filter($f, fn:tail($seq))"/&gt;
+    &lt;xsl:sequence select="fn:head($seq)[$f(.) eq fn:true()], fn:filter(fn:tail($seq), $f)"/&gt;
   &lt;/xsl:if&gt;
 &lt;/xsl:function&gt;
          
@@ -28199,7 +28907,7 @@
               </dd>
               <dt class="label">Notes</dt>
               <dd>
-                <p>The function call <code>fn:filter($F, $SEQ)</code> has a very
+                <p>The function call <code>fn:filter($SEQ, $F)</code> has a very
 similar effect to the expression <code>$SEQ[$F(.)]</code>. There
 are some differences, however. In the case of
 <code>fn:filter</code>, the function <code>$F</code> is required to
@@ -28214,8 +28922,8 @@
               </dd>
               <dt class="label">Examples</dt>
               <dd>
-                <p>The expression <code>fn:filter(function($a) {$a mod 2 = 0}, 1 to
-10)</code> returns <code>(2, 4, 6, 8, 10)</code>.</p>
+                <p>The expression <code>fn:filter(1 to 10, function($a) {$a mod 2 =
+0})</code> returns <code>(2, 4, 6, 8, 10)</code>.</p>
               </dd>
             </dl>
           </div>
@@ -28239,27 +28947,27 @@
                         <td valign="baseline" rowspan="3">
                           <code class="function">fn:fold-left</code>(</td>
                         <td valign="baseline">
+                          <code class="arg">$seq</code>
+                        </td>
+                        <td valign="baseline">
+                          <code class="as"> as </code>
+                          <code class="type">item()*</code>,</td>
+                      </tr>
+                      <tr>
+                        <td valign="baseline">
+                          <code class="arg">$zero</code>
+                        </td>
+                        <td valign="baseline">
+                          <code class="as"> as </code>
+                          <code class="type">item()*</code>,</td>
+                      </tr>
+                      <tr>
+                        <td valign="baseline">
                           <code class="arg">$f</code>
                         </td>
                         <td valign="baseline">
                           <code class="as"> as </code>
-                          <code class="type">function(item()*, item()) as item()*</code>,</td>
-                      </tr>
-                      <tr>
-                        <td valign="baseline">
-                          <code class="arg">$zero</code>
-                        </td>
-                        <td valign="baseline">
-                          <code class="as"> as </code>
-                          <code class="type">item()*</code>,</td>
-                      </tr>
-                      <tr>
-                        <td valign="baseline">
-                          <code class="arg">$seq</code>
-                        </td>
-                        <td valign="baseline">
-                          <code class="as"> as </code>
-                          <code class="type">item()*</code>)<code class="as"> as </code>
+                          <code class="type">function(item()*, item()) as item()*</code>)<code class="as"> as </code>
                           <code class="return-type">item()*</code>
                         </td>
                       </tr>
@@ -28285,13 +28993,13 @@
                 <div class="exampleInner">
                   <pre>
 declare function fn:fold-left(
-        $f as function(item()*, item()) as item()*, 
-        $zero as item()*, 
-        $seq as item()*) 
+        $seq as item()*
+        $zero as item()*,
+        $f as function(item()*, item()) as item()*) 
         as item()* {
   if (fn:empty($seq))
   then $zero
-  else fn:fold-left($f, $f($zero, fn:head($seq)), fn:tail($seq))
+  else fn:fold-left(fn:tail($seq), $f($zero, fn:head($seq)), $f)
 };
 </pre>
                 </div>
@@ -28299,15 +29007,15 @@
                 <div class="exampleInner">
                   <pre>
 &lt;xsl:function name="fn:fold-left" as="item()*"&gt;
+  &lt;xsl:param name="seq" as="item()*"/&gt;
+  &lt;xsl:param name="zero" as="item()*"/&gt;
   &lt;xsl:param name="f" as="function(item()*, item()) as item()*"/&gt;
-  &lt;xsl:param name="zero" as="item()*"/&gt;
-  &lt;xsl:param name="seq" as="item()*"/&gt;
   &lt;xsl:choose&gt;
     &lt;xsl:when test="fn:empty($seq)"&gt;
       &lt;xsl:sequence select="$zero"/&gt;
     &lt;/xsl:when&gt;
     &lt;xsl:otherwise&gt;
-      &lt;xsl:sequence select="fn:fold-left($f, $f($zero, fn:head($seq)), fn:tail($seq))"/&gt;
+      &lt;xsl:sequence select="fn:fold-left(fn:tail($seq), $f($zero, fn:head($seq)), $f)"/&gt;
     &lt;/xsl:otherwise&gt;
   &lt;/xsl:choose&gt;
 &lt;/xsl:function&gt;
@@ -28340,33 +29048,33 @@
               </dd>
               <dt class="label">Examples</dt>
               <dd>
-                <p>The expression <code>fn:fold-left(function($a, $b) { $a + $b },
-0, 1 to 5)</code> returns <code>15</code>. <em>(This returns the
+                <p>The expression <code>fn:fold-left(1 to 5, 0, function($a, $b) {
+$a + $b })</code> returns <code>15</code>. <em>(This returns the
 sum of the items in the sequence).</em>
                 </p>
-                <p>The expression <code>fn:fold-left(function($a, $b) { $a * $b },
-1, (2,3,5,7))</code> returns <code>210</code>. <em>(This returns
-the product of the items in the sequence).</em>
+                <p>The expression <code>fn:fold-left((2,3,5,7), 1, function($a, $b)
+{ $a * $b })</code> returns <code>210</code>. <em>(This returns the
+product of the items in the sequence).</em>
                 </p>
-                <p>The expression <code>fn:fold-left(function($a, $b) { $a or $b },
-false(), (true(), false(), false()))</code> returns
+                <p>The expression <code>fn:fold-left((true(), false(), false()),
+false(), function($a, $b) { $a or $b })</code> returns
 <code>true()</code>. <em>(This returns true if any item in the
 sequence has an effective boolean value of true).</em>
                 </p>
-                <p>The expression <code>fn:fold-left(function($a, $b) { $a and $b
-}, false(), (true(), false(), false()))</code> returns
+                <p>The expression <code>fn:fold-left((true(), false(), false()),
+false(), function($a, $b) { $a and $b })</code> returns
 <code>false()</code>. <em>(This returns true only if every item in
 the sequence has an effective boolean value of true).</em>
                 </p>
-                <p>The expression <code>fn:fold-left(function($a, $b) {($b, $a)},
-(), 1 to 5)</code> returns <code>(5,4,3,2,1)</code>. <em>(This
+                <p>The expression <code>fn:fold-left(1 to 5, (), function($a, $b)
+{($b, $a)})</code> returns <code>(5,4,3,2,1)</code>. <em>(This
 reverses the order of the items in a sequence).</em>
                 </p>
-                <p>The expression <code>fn:fold-left(fn:concat(?, ".", ?), "", 1 to
-5)</code> returns <code>".1.2.3.4.5"</code>.</p>
-                <p>The expression <code>fn:fold-left(fn:concat("$f(", ?, ", ", ?,
-")"), "$zero", 1 to 5)</code> returns <code>"$f($f($f($f($f($zero,
-1), 2), 3), 4), 5)"</code>.</p>
+                <p>The expression <code>fn:fold-left(1 to 5, "", fn:concat(?, ".",
+?))</code> returns <code>".1.2.3.4.5"</code>.</p>
+                <p>The expression <code>fn:fold-left(1 to 5, "$zero",
+fn:concat("$f(", ?, ", ", ?, ")")</code> returns
+<code>"$f($f($f($f($f($zero, 1), 2), 3), 4), 5)"</code>.</p>
               </dd>
             </dl>
           </div>
@@ -28390,27 +29098,27 @@
                         <td valign="baseline" rowspan="3">
                           <code class="function">fn:fold-right</code>(</td>
                         <td valign="baseline">
+                          <code class="arg">$seq</code>
+                        </td>
+                        <td valign="baseline">
+                          <code class="as"> as </code>
+                          <code class="type">item()*</code>,</td>
+                      </tr>
+                      <tr>
+                        <td valign="baseline">
+                          <code class="arg">$zero</code>
+                        </td>
+                        <td valign="baseline">
+                          <code class="as"> as </code>
+                          <code class="type">item()*</code>,</td>
+                      </tr>
+                      <tr>
+                        <td valign="baseline">
                           <code class="arg">$f</code>
                         </td>
                         <td valign="baseline">
                           <code class="as"> as </code>
-                          <code class="type">function(item(), item()*) as item()*</code>,</td>
-                      </tr>
-                      <tr>
-                        <td valign="baseline">
-                          <code class="arg">$zero</code>
-                        </td>
-                        <td valign="baseline">
-                          <code class="as"> as </code>
-                          <code class="type">item()*</code>,</td>
-                      </tr>
-                      <tr>
-                        <td valign="baseline">
-                          <code class="arg">$seq</code>
-                        </td>
-                        <td valign="baseline">
-                          <code class="as"> as </code>
-                          <code class="type">item()*</code>)<code class="as"> as </code>
+                          <code class="type">function(item()*, item()) as item()*</code>)<code class="as"> as </code>
                           <code class="return-type">item()*</code>
                         </td>
                       </tr>
@@ -28436,13 +29144,13 @@
                 <div class="exampleInner">
                   <pre>
 declare function fn:fold-right(
-        $f as function(item(), item()*) as item()*, 
+        $seq as item()*, 
         $zero as item()*, 
-        $seq as item()*) 
+        $f as function(item(), item()*) as item()*) 
         as item()* {
   if (fn:empty($seq))
   then $zero
-  else $f(fn:head($seq), fn:fold-right($f, $zero, fn:tail($seq)))
+  else $f(fn:head($seq), fn:fold-right(fn:tail($seq), $zero, $f))
 };
 </pre>
                 </div>
@@ -28450,15 +29158,15 @@
                 <div class="exampleInner">
                   <pre>
 &lt;xsl:function name="fn:fold-right" as="item()*"&gt;
+  &lt;xsl:param name="seq" as="item()*"/&gt;
+  &lt;xsl:param name="zero" as="item()*"/&gt;
   &lt;xsl:param name="f" as="function(item(), item()*) as item()*"/&gt;
-  &lt;xsl:param name="zero" as="item()*"/&gt;
-  &lt;xsl:param name="seq" as="item()*"/&gt;
   &lt;xsl:choose&gt;
     &lt;xsl:when test="fn:empty($seq)"&gt;
       &lt;xsl:sequence select="$zero"/&gt;
     &lt;/xsl:when&gt;
     &lt;xsl:otherwise&gt;
-      &lt;xsl:sequence select="$f(fn:head($seq), fn:fold-right($f, $zero, fn:tail($seq))"/&gt;
+      &lt;xsl:sequence select="$f(fn:head($seq), fn:fold-right(fn:tail($seq), $zero, $f))"/&gt;
     &lt;/xsl:otherwise&gt;
   &lt;/xsl:choose&gt;
 &lt;/xsl:function&gt;
@@ -28496,22 +29204,22 @@
               </dd>
               <dt class="label">Examples</dt>
               <dd>
-                <p>The expression <code>fn:fold-right(function($a, $b) { $a + $b },
-0, 1 to 5)</code> returns <code>15</code>. <em>(This returns the
+                <p>The expression <code>fn:fold-right(1 to 5, 0, function($a, $b) {
+$a + $b })</code> returns <code>15</code>. <em>(This returns the
 sum of the items in the sequence).</em>
                 </p>
-                <p>The expression <code>fn:fold-right(fn:concat(?, ".", ?), "", 1
-to 5)</code> returns <code>"1.2.3.4.5."</code>.</p>
-                <p>The expression <code>fn:fold-right(concat("$f(", ?, ", ", ?,
-")"), "$zero", 1 to 5)</code> returns <code>"$f(1, $f(2, $f(3,
-$f(4, $f(5, $zero)))))"</code>.</p>
+                <p>The expression <code>fn:fold-right(1 to 5, "", fn:concat(?, ".",
+?))</code> returns <code>"1.2.3.4.5."</code>.</p>
+                <p>The expression <code>fn:fold-right(1 to 5, "$zero",
+concat("$f(", ?, ", ", ?, ")"))</code> returns <code>"$f(1, $f(2,
+$f(3, $f(4, $f(5, $zero)))))"</code>.</p>
               </dd>
             </dl>
           </div>
           <div class="div3">
             <h4>
-              <a name="func-map-pairs" id="func-map-pairs"/>16.2.5
-fn:map-pairs</h4>
+              <a name="func-for-each-pair" id="func-for-each-pair"/>16.2.5
+fn:for-each-pair</h4>
             <dl>
               <dt class="label">Summary</dt>
               <dd>
@@ -28527,15 +29235,7 @@
                     <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
                       <tr>
                         <td valign="baseline" rowspan="3">
-                          <code class="function">fn:map-pairs</code>(</td>
-                        <td valign="baseline">
-                          <code class="arg">$f</code>
-                        </td>
-                        <td valign="baseline">
-                          <code class="as"> as </code>
-                          <code class="type">function(item(), item()) as item()*</code>,</td>
-                      </tr>
-                      <tr>
+                          <code class="function">fn:for-each-pair</code>(</td>
                         <td valign="baseline">
                           <code class="arg">$seq1</code>
                         </td>
@@ -28549,7 +29249,15 @@
                         </td>
                         <td valign="baseline">
                           <code class="as"> as </code>
-                          <code class="type">item()*</code>)<code class="as"> as </code>
+                          <code class="type">item()*</code>,</td>
+                      </tr>
+                      <tr>
+                        <td valign="baseline">
+                          <code class="arg">$f</code>
+                        </td>
+                        <td valign="baseline">
+                          <code class="as"> as </code>
+                          <code class="type">function(item(), item()) as item()*</code>)<code class="as"> as </code>
                           <code class="return-type">item()*</code>
                         </td>
                       </tr>
@@ -28574,12 +29282,12 @@
 implementation in XQuery:</p>
                 <div class="exampleInner">
                   <pre>
-declare function fn:map-pairs($f, $seq1, $seq2)
+declare function fn:for-each-pair($seq1, $seq2, $f)
 {
    if(fn:exists($seq1) and fn:exists($seq2)) 
    then (
      $f(fn:head($seq1), fn:head($seq2)),
-     fn:map-pairs($f, fn:tail($seq1), fn:tail($seq2))
+     fn:for-each-pair(fn:tail($seq1), fn:tail($seq2), $f)
    )
    else ()
 };
@@ -28588,13 +29296,13 @@
                 <p>or its equivalent in XSLT:</p>
                 <div class="exampleInner">
                   <pre>
-&lt;xsl:function name="fn:map-pairs"&gt;
-  &lt;xsl:param name="f"/&gt;
+&lt;xsl:function name="fn:for-each-pair"&gt;
   &lt;xsl:param name="seq1/&gt;
   &lt;xsl:param name="seq2/&gt;
-  &lt;xsl:if test="fn:exists($seq1) and fn:exists($seq2"&gt;
+  &lt;xsl:param name="f"/&gt;
+  &lt;xsl:if test="fn:exists($seq1) and fn:exists($seq2)"&gt;
     &lt;xsl:sequence select="$f(fn:head($seq1), fn:head($seq2))"/&gt;
-    &lt;xsl:sequence select="fn:map-pairs($f, fn:tail($seq1), fn:tail($seq2))"/&gt;
+    &lt;xsl:sequence select="fn:for-each-pair(fn:tail($seq1), fn:tail($seq2), $f)"/&gt;
   &lt;/xsl:if&gt;
 &lt;/xsl:function&gt;
          
@@ -28603,11 +29311,11 @@
               </dd>
               <dt class="label">Examples</dt>
               <dd>
-                <p>The expression <code>fn:map-pairs(concat#2, ("a", "b", "c"),
-("x", "y", "z"))</code> returns <code>("ax", "by",
+                <p>The expression <code>fn:for-each-pair(("a", "b", "c"), ("x",
+"y", "z"), concat#2)</code> returns <code>("ax", "by",
 "cz")</code>.</p>
-                <p>The expression <code>fn:map-pairs(function($a, $b){10*$a + $b},
-1 to 5, 1 to 5)</code> returns <code>(11, 22, 33, 44,
+                <p>The expression <code>fn:for-each-pair(1 to 5, 1 to 5,
+function($a, $b){10*$a + $b}</code> returns <code>(11, 22, 33, 44,
 55)</code>.</p>
               </dd>
             </dl>
@@ -28620,10 +29328,10 @@
         <div class="div2">
           <h3>
             <a name="constructor-functions-for-xsd-types" id="constructor-functions-for-xsd-types"/>17.1 Constructor
-functions for XML Schema built-in types</h3>
+functions for XML Schema built-in atomic types</h3>
           <p>Every built-in atomic type that is defined in <a href="#xmlschema-2">[XML Schema Part 2: Datatypes Second Edition]</a>,
 except <code>xs:anyAtomicType</code> and <code>xs:NOTATION</code>,
-has an associated constructor function.
+has an associated constructor function. The type
 <code>xs:untypedAtomic</code>, defined in <a href="http://www.w3.org/TR/xpath-datamodel-30/#types";>Section 2.7 Schema
 Information</a>
             <sup>
@@ -28636,9 +29344,8 @@
               <small>DM30</small>
             </sup> also have associated
 constructor functions. <span>Implementations <strong>may</strong>
-additionally provide constructor functions for new data types
-introduced in <a href="#xmlschema11-2">[XML Schema 1.1 Part 2:
-Datatypes]</a>.</span>
+additionally provide a constructor functions for the new data type
+<code>xs:dateTimeStamp</code> introduced in <a href="#xmlschema11-2">[XML Schema 1.1 Part 2: Datatypes]</a>.</span>
           </p>
           <p>A constructor function is not defined for
 <code>xs:anyAtomicType</code> as there are no atomic values with
@@ -28653,11 +29360,12 @@
             </sup>) contains a type
 derived from <code>xs:NOTATION</code> then a constructor function
 is defined for it. See <a href="#constructor-functions-for-user-defined-types">
-              <b>17.3 Constructor
+              <b>17.5 Constructor
 functions for user-defined types</b>
             </a>.</p>
-          <p>The form of the constructor function for a type
-<em>prefix:TYPE</em> is:</p>
+          <p>The form of the constructor function for <span>an atomic
+type</span>
+            <em>prefix:TYPE</em> is:</p>
           <div class="exampleInner">
             <div class="proto">
               <code class="function">fn:prefix:TYPE</code>(<code class="arg">$arg</code>
@@ -28695,7 +29403,8 @@
 that value. If the value passed to a constructor is not in the
 lexical space of the datatype to be constructed, and cannot be
 converted to a value in the value space of the datatype under the
-rules in this specification, then an error is raised [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>].</p>
+rules in this specification, then an <span>dynamic</span> error is
+raised [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>].</p>
           <p>The semantics of the constructor function "
 <code>xs:TYPE(arg)</code> " are identical to the semantics of "
 <code>arg</code> cast as <code>xs:TYPE?</code> ". See <a href="#casting">
@@ -28711,8 +29420,8 @@
               <b>17.2 Constructor functions for
 xs:QName and xs:NOTATION</b>
             </a>.</p>
-          <p>The following constructor functions for the built-in types are
-supported:</p>
+          <p>The following constructor functions for the built-in
+<span>atomic</span> types are supported:</p>
           <ul>
             <li>
               <div class="proto">
@@ -28866,7 +29575,7 @@
               <div class="proto">
                 <code class="function">fn:QName</code>(<code class="arg">$arg</code>
                 <code class="as"> as </code>
-                <code class="type">xs:anyAtomicType</code>)<code class="as"> as </code>
+                <code class="type">xs:anyAtomicType?</code>)<code class="as"> as </code>
                 <code class="return-type">xs:QName?</code>
               </div>
               <p>See <a href="#constructor-qname-notation">
@@ -29122,8 +29831,9 @@
             <li>
               <p>There is no constructor function for <code>xs:NOTATION</code>.
 Constructors are defined, however, for <code>xs:QName</code>, for
-types derived from <code>xs:QName</code>, and for types derived
-from <code>xs:NOTATION</code>.</p>
+types derived <span>or constructed</span> from
+<code>xs:QName</code>, and for types derived <span>or
+constructed</span> from <code>xs:NOTATION</code>.</p>
             </li>
             <li>
               <p>When converting from an <code>xs:string</code>, the prefix
@@ -29137,8 +29847,8 @@
 2.1.1 Static Context</a>
                 <sup>
                   <small>XP30</small>
-                </sup>. A static
-error is raised [<a href="#ERRFONS0004" title="err:FONS0004">err:FONS0004</a>] if the prefix is not bound in the
+                </sup>. A
+<span>dynamic</span> error is raised [<a href="#ERRFONS0004" title="err:FONS0004">err:FONS0004</a>] if the prefix is not bound in the
 static context. As described in <a href="http://www.w3.org/TR/xpath-datamodel-30/#terminology";>Section 2.1
 Terminology</a>
                 <sup>
@@ -29147,10 +29857,138 @@
 is retained as part of the expanded-QName value.</p>
             </li>
           </ol>
-        </div>
-        <div class="div2">
-          <h3>
-            <a name="constructor-functions-for-user-defined-types" id="constructor-functions-for-user-defined-types"/>17.3 Constructor
+          <p>When a constructor function for a namespace-sensitive type is
+used as a literal function item or in a partial function
+application (for example, <a href="#func-QName">
+              <code>fn:QName#1</code>
+            </a> or <a href="#func-QName">
+              <code>fn:QName(?)</code>
+            </a>) the namespace bindings
+that are relevant are those from the static context of the literal
+function item or partial function application. When a constructor
+function for a namespace-sensitive type is obtained by means of the
+<a href="#func-function-lookup">
+              <code>fn:function-lookup</code>
+            </a>
+function, the relevant namespace bindings are those from the static
+context of the call on <a href="#func-function-lookup">
+              <code>fn:function-lookup</code>
+            </a>.</p>
+          <div class="note">
+            <p class="prefix">
+              <b>Note:</b>
+            </p>
+            <p>When the supplied argument to the <code>xs:QName</code>
+constructor function is a node, the node is atomized in the usual
+way, and if the result is <code>xs:untypedAtomic</code> it is then
+converted as if a string had been supplied. The effect might not be
+what is desired. For example, given the attribute
+<code>xsi:type="my:type"</code>, the expression
+<code>xs:QName(@xsi:type)</code> might fail on the grounds that the
+prefix <code>my</code> is undeclared. This is because the namespace
+bindings are taken from the static context (that is, from the query
+or stylesheet), and not from the source document containing the
+<code>@xsi:type</code> attribute. The solution to this problem is
+to use the function call <code>resolve-QName(@xsi:type, .)</code>
+instead.</p>
+          </div>
+        </div>
+        <div class="div2">
+          <h3>
+            <a name="constructor-functions-for-xsd-list-types" id="constructor-functions-for-xsd-list-types"/>17.3 Constructor
+functions for XML Schema built-in list types</h3>
+          <p>Each of the three built-in list types defined in <a href="#xmlschema-2">[XML Schema Part 2: Datatypes Second Edition]</a>,
+namely <code>xs:NMTOKENS</code>, <code>xs:ENTITIES</code>, and
+<code>xs:IDREFS</code>, has an associated constructor function.</p>
+          <p>The function signatures are as follows:</p>
+          <ul>
+            <li>
+              <div class="proto">
+                <code class="function">fn:NMTOKENS</code>(<code class="arg">$arg</code>
+                <code class="as"> as </code>
+                <code class="type">xs:anyAtomicType?</code>)<code class="as"> as </code>
+                <code class="return-type">xs:NMTOKEN*</code>
+              </div>
+            </li>
+            <li>
+              <div class="proto">
+                <code class="function">fn:ENTITIES</code>(<code class="arg">$arg</code>
+                <code class="as"> as </code>
+                <code class="type">xs:anyAtomicType?</code>)<code class="as"> as </code>
+                <code class="return-type">xs:ENTITY*</code>
+              </div>
+            </li>
+            <li>
+              <div class="proto">
+                <code class="function">fn:IDREFS</code>(<code class="arg">$arg</code>
+                <code class="as"> as </code>
+                <code class="type">xs:anyAtomicType?</code>)<code class="as"> as </code>
+                <code class="return-type">xs:IDREF*</code>
+              </div>
+            </li>
+          </ul>
+          <p>The semantics are equivalent to casting to the corresponding
+types from <code>xs:string</code>.</p>
+          <p>All three of these types have the facet <code>minLength =
+1</code> meaning that there must always be at least one item in the
+list. The return type, however, allows for the fact that when the
+argument to the function is an empty sequence, the result is an
+empty sequence.</p>
+          <div class="note">
+            <p class="prefix">
+              <b>Note:</b>
+            </p>
+            <p>In the case of atomic types, it is possible to use an expression
+such as <code>xs:date(@date-of-birth)</code> to convert an
+attribute value to an instance of <code>xs:date</code>, knowing
+that this will work both in the case where the attribute is already
+annotated as <code>xs:date</code>, and also in the case where it is
+<code>xs:untypedAtomic</code>. This approach does not work with
+list types, because it is not permitted to use a value of type
+<code>xs:NMTOKEN*</code> as input to the constructor function
+<code>xs:NMTOKENS</code>. Instead, it is necessary to use
+conditional logic that performs the conversion only in the case
+where the input is untyped: <code>if (@x instance of attribute(*,
+xs:untypedAtomic)) then xs:NMTOKENS(@x) else data(@x)</code>
+            </p>
+          </div>
+        </div>
+        <div class="div2">
+          <h3>
+            <a name="constructor-functions-for-xsd-union-types" id="constructor-functions-for-xsd-union-types"/>17.4 Constructor
+functions for XML Schema built-in union types</h3>
+          <p>In the case of an implementation that supports XSD 1.1, there is
+a constructor function associated with the built-in union type
+<code>xs:error</code>.</p>
+          <p>The function signature is as follows:</p>
+          <ul>
+            <li>
+              <div class="proto">
+                <code class="function">fn:error</code>(<code class="arg">$arg</code>
+                <code class="as"> as </code>
+                <code class="type">xs:anyAtomicType?</code>)<code class="as"> as </code>
+                <code class="return-type">xs:error?</code>
+              </div>
+            </li>
+          </ul>
+          <p>The semantics are equivalent to casting to the corresponding
+union type (see <a href="#casting-to-union">
+              <b>18.3.5 Casting to
+union types</b>
+            </a>).</p>
+          <div class="note">
+            <p class="prefix">
+              <b>Note:</b>
+            </p>
+            <p>Because <code>xs:error</code> has no member types, and therefore
+has an empty value space, casting will always fail with a dynamic
+error except in the case where the supplied argument is an empty
+sequence, in which case the result is also an empty sequence.</p>
+          </div>
+        </div>
+        <div class="div2">
+          <h3>
+            <a name="constructor-functions-for-user-defined-types" id="constructor-functions-for-user-defined-types"/>17.5 Constructor
 functions for user-defined types</h3>
           <p>
             <span>For every user-defined simple type in the static context
@@ -29165,7 +30003,7 @@
 are defined in the same way as the rules for constructing built-in
 derived types defined in <a href="#constructor-functions-for-xsd-types">
               <b>17.1 Constructor
-functions for XML Schema built-in types</b>
+functions for XML Schema built-in atomic types</b>
             </a>.</p>
           <p>Special rules apply to constructor functions for
 namespace-sensitive types, that is, atomic types derived from
@@ -29175,18 +30013,33 @@
               <b>17.2 Constructor functions for
 xs:QName and xs:NOTATION</b>
             </a>.</p>
-          <p>Consider a situation where the static context contains a type
-called <code>hatSize</code> defined in a schema whose target
-namespace is bound to the prefix <code>my</code>. In such a case
-the following constructor function is available to users:</p>
+          <p>Consider a situation where the static context contains an
+<span>atomic</span> type called <code>hatSize</code> defined in a
+schema whose target namespace is bound to the prefix
+<code>eg</code>. In such a case the following constructor function
+is available to users:</p>
           <div class="exampleInner">
             <div class="proto">
-              <code class="function">fn:my:hatSize</code>(<code class="arg">$arg</code>
+              <code class="function">eg:hatSize</code>(<code class="arg">$arg</code>
               <code class="as"> as </code>
               <code class="type">xs:anyAtomicType?</code>)<code class="as"> as </code>
               <code class="return-type">my:hatSize?</code>
             </div>
           </div>
+          <p>In the case of an atomic type <var>A</var>, the return type of
+the function is <code>A?</code>, reflecting the fact that the
+result will be an empty sequence if the input is an empty sequence.
+For a union or list type, the return type of the function is
+specified only as <code>xs:anyAtomicType*</code>. Implementations
+performing static type checking will often be able to compute a
+more specific result type. For example, if the target type is a
+list type whose item type is the atomic type <var>A</var>, the
+result will always be an instance of <var>A*</var>; if the target
+type is a pure union type <var>U</var> then the result will always
+be an instance of <var>U?</var>. In general, however, applications
+needing interoperable behavior on implementations that do strict
+static type checking will need to use a <code>treat as</code>
+expression to assert the specific type of the result.</p>
           <p>To construct an instance of <span>a user-defined</span> type
 that is not in a namespace, it is necessary to use a cast
 expression or undeclare the default function namespace. For
@@ -29225,10 +30078,10 @@
           </sup> of <a href="#xpath-datamodel-30">[XQuery and XPath Data Model (XDM) 3.0]</a>
 (see <a href="#constructor-functions-for-xsd-types">
             <b>17.1
-Constructor functions for XML Schema built-in types</b>
-          </a>) or the
-user-derived datatype (see <a href="#constructor-functions-for-user-defined-types">
-            <b>17.3 Constructor
+Constructor functions for XML Schema built-in atomic types</b>
+          </a>)
+or the user-derived datatype (see <a href="#constructor-functions-for-user-defined-types">
+            <b>17.5 Constructor
 functions for user-defined types</b>
           </a>) that is the target for
 the conversion, and the semantics are exactly the same as for a
@@ -29243,8 +30096,8 @@
 sequence and the expression to be cast is the empty sequence, the
 empty sequence is returned. If the type name does not allow the
 empty sequence and the expression to be cast is the empty sequence,
-a type error is raised [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-            <small>XP</small>
+a type error is raised [<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+            <small>XP30</small>
           </sup>.</p>
         <p>Where the argument to a cast is a literal, the result of the
 function <strong>may</strong> be evaluated statically; if an error
@@ -29311,9 +30164,9 @@
             <a href="#xmlschema-2">[XML Schema Part 2: Datatypes Second
 Edition]</a> defines <code>xs:NOTATION</code> as an abstract type.
 Thus, casting to <code>xs:NOTATION</code> from any other type
-including <code>xs:NOTATION</code> is not permitted and raises
-[<a href="http://www.w3.org/TR/xpath20/#ERRXPST0080"; title="err:XPST0080">err:XPST0080</a>]<sup>
-              <small>XP</small>
+including <code>xs:NOTATION</code> is not permitted and raises a
+<span>static error</span> [<a href="http://www.w3.org/TR/xpath-30/#ERRXPST0080"; title="err:XPST0080">err:XPST0080</a>]<sup>
+              <small>XP30</small>
             </sup>.
 However, casting from one subtype of <code>xs:NOTATION</code> to
 another subtype of <code>xs:NOTATION</code> is permitted.</p>
@@ -29323,21 +30176,24 @@
 validated or has been validated as <code>xs:anySimpleType</code>,
 the typed value of the node is an atomic value of type
 <code>xs:untypedAtomic</code>. There are no atomic values with the
-type annotation <code>xs:anySimpleType</code> at runtime. Casting
-to a type that is not atomic raises [<a href="http://www.w3.org/TR/xpath20/#ERRXPST0051"; title="err:XPST0051">err:XPST0051</a>]<sup>
-              <small>XP</small>
-            </sup>.</p>
+type annotation <code>xs:anySimpleType</code> at runtime.
+<span>Casting to <code>xs:anySimpleType</code> is not permitted and
+raises <span>a static error</span>: [<a href="http://www.w3.org/TR/xpath-30/#ERRXPST0080"; title="err:XPST0080">err:XPST0080</a>]<sup>
+                <small>XP30</small>
+              </sup>
+            </span>.</p>
           <p>Similarly, casting is not supported to or from
-<code>xs:anyAtomicType</code> and will raise error [<a href="http://www.w3.org/TR/xpath20/#ERRXPST0080"; title="err:XPST0080">err:XPST0080</a>]<sup>
-              <small>XP</small>
-            </sup>. There
-are no atomic values with the type annotation
+<code>xs:anyAtomicType</code> and will raise <span>a static
+error</span>: [<a href="http://www.w3.org/TR/xpath-30/#ERRXPST0080"; title="err:XPST0080">err:XPST0080</a>]<sup>
+              <small>XP30</small>
+            </sup>.
+There are no atomic values with the type annotation
 <code>xs:anyAtomicType</code> at runtime, although this can be a
 statically inferred type.</p>
           <p>If casting is attempted from an <em>ST</em> to a <em>TT</em> for
 which casting is not supported, as defined in the table below, a
-type error is raised [<a href="http://www.w3.org/TR/xpath20/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
-              <small>XP</small>
+type error is raised [<a href="http://www.w3.org/TR/xpath-30/#ERRXPTY0004"; title="err:XPTY0004">err:XPTY0004</a>]<sup>
+              <small>XP30</small>
             </sup>.</p>
           <p>In the following table, the columns and rows are identified by
 short codes that identify simple types as follows:</p>
@@ -31599,11 +32455,11 @@
 <code>xs:decimal</code>, (see <a href="#xmlschema-2">[XML Schema
 Part 2: Datatypes Second Edition]</a> for <a title="implementation-defined" class="termref" href="#implementation-defined">
                       <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-                    </a> limits on numeric values) an error is raised
-[<a href="#ERRFOCA0001" title="err:FOCA0001">err:FOCA0001</a>]. If
-<em>SV</em> is one of the special <code>xs:float</code> or
-<code>xs:double</code> values <code>NaN</code>, <code>INF</code>,
-or <code>-INF</code>, an error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>].</p>
+                    </a> limits on numeric values) a
+<span>dynamic</span> error is raised [<a href="#ERRFOCA0001" title="err:FOCA0001">err:FOCA0001</a>]. If <em>SV</em> is one of the
+special <code>xs:float</code> or <code>xs:double</code> values
+<code>NaN</code>, <code>INF</code>, or <code>-INF</code>, a
+<span>dynamic</span> error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>].</p>
                 </li>
                 <li>
                   <p>If <em>ST</em> is <code>xs:boolean</code>, <em>SV</em> is
@@ -31646,11 +32502,11 @@
 <a href="#xmlschema-2">[XML Schema Part 2: Datatypes Second
 Edition]</a> for <a title="implementation-defined" class="termref" href="#implementation-defined">
                       <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-                    </a> limits on numeric values) an error is raised
-[<a href="#ERRFOCA0003" title="err:FOCA0003">err:FOCA0003</a>]. If
-<em>SV</em> is one of the special <code>xs:float</code> or
-<code>xs:double</code> values <code>NaN</code>, <code>INF</code>,
-or <code>-INF</code>, an error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>].</p>
+                    </a> limits on numeric values) a
+<span>dynamic</span> error is raised [<a href="#ERRFOCA0003" title="err:FOCA0003">err:FOCA0003</a>]. If <em>SV</em> is one of the
+special <code>xs:float</code> or <code>xs:double</code> values
+<code>NaN</code>, <code>INF</code>, or <code>-INF</code>, a
+<span>dynamic</span> error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>].</p>
                 </li>
                 <li>
                   <p>If <em>ST</em> is <code>xs:boolean</code>, <em>SV</em> is
@@ -32285,6 +33141,17 @@
 <code>xs:QName</code> or <code>xs:NOTATION</code> has the same
 prefix, local name, and namespace URI parts as the supplied
 value.</p>
+            <div class="note">
+              <p class="prefix">
+                <b>Note:</b>
+              </p>
+              <p>See <a href="#constructor-qname-notation">
+                  <b>17.2 Constructor
+functions for xs:QName and xs:NOTATION</b>
+                </a> for a discussion of
+how the combination of atomization and casting might not produce
+the desired effect.</p>
+            </div>
           </div>
           <div class="div3">
             <h4>
@@ -32337,18 +33204,20 @@
               <b>18.3.1 Casting to derived
 types</b>
             </a>). If the lexical form does not conform to the
-pattern, error [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] is raised.</p>
+pattern, a <span>dynamic</span> error [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] is raised.</p>
           <p>For example, consider a user-defined type
 <code>my:boolean</code> which is derived by restriction from
 <code>xs:boolean</code> and specifies the pattern facet
 <code>value="0|1"</code>. The expression <code>"true" cast as
-my:boolean</code> would fail with [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>].</p>
+my:boolean</code> would fail with a <span>dynamic</span> error
+[<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>].</p>
           <p>Facets other than <code>pattern</code> are checked
 <em>after</em> the conversion. For example if there is a
 user-defined datatype called <code>my:height</code> defined as a
 restriction of <code>xs:integer</code> with the facet
 <code>&lt;maxInclusive value="84"/&gt;</code>, then the expression
-<code>"100" cast as my:height</code> would fail with [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>].</p>
+<code>"100" cast as my:height</code> would fail with a
+<span>dynamic</span> error [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>].</p>
           <p>Casting to the types <code>xs:NOTATION</code>,
 <code>xs:anySimpleType</code>, or <code>xs:anyAtomicType</code> is
 not permitted because these types are abstract (they have no
@@ -32402,22 +33271,25 @@
 of decimal digits available to the implementation, the
 implementation may round to the nearest representable value or may
 raise a dynamic error [<a href="#ERRFOCA0006" title="err:FOCA0006">err:FOCA0006</a>]. The choice of rounding algorithm
-and the choice between rounding and error behavior and is
-implementation-defined.</p>
+and the choice between rounding and error behavior and is <a title="implementation-defined" class="termref" href="#implementation-defined">
+              <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+            </a>.</p>
           <p>In casting to <code>xs:date</code>, <code>xs:dateTime</code>,
 <code>xs:gYear</code>, or <code>xs:gYearMonth</code> (or types
 derived from these), if the value is too large or too small to be
-represented by the implementation, error [<a href="#ERRFODT0001" title="err:FODT0001">err:FODT0001</a>] is raised.</p>
+represented by the implementation, a <span>dynamic</span> error
+[<a href="#ERRFODT0001" title="err:FODT0001">err:FODT0001</a>] is
+raised.</p>
           <p>In casting to a duration value, if the value is too large or too
-small to be represented by the implementation, error [<a href="#ERRFODT0002" title="err:FODT0002">err:FODT0002</a>] is
-raised.</p>
+small to be represented by the implementation, a
+<span>dynamic</span> error [<a href="#ERRFODT0002" title="err:FODT0002">err:FODT0002</a>] is raised.</p>
           <p>For <code>xs:anyURI</code>, the extent to which an
 implementation validates the lexical form of <code>xs:anyURI</code>
 is <a title="implementation dependent" class="termref" href="#implementation-dependent">
               <span class="arrow">·</span>implementation dependent<span class="arrow">·</span>
             </a>.</p>
-          <p>If the cast fails for any other reason, error [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] is
-raised.</p>
+          <p>If the cast fails for any other reason, a <span>dynamic</span>
+error [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] is raised.</p>
         </div>
         <div class="div2">
           <h3>
@@ -32525,14 +33397,13 @@
 <code>xs:byte</code> can be cast as <code>xs:unsignedShort</code>,
 provided the value is not negative.</p>
             <p>If the value does not conform to the facets defined for the
-target type, then an error is raised [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>]. See <a href="#xmlschema-2">[XML
-Schema Part 2: Datatypes Second Edition]</a>. In the case of the
-pattern facet (which applies to the lexical space rather than the
-value space), the pattern is tested against the canonical lexical
-representation of the value, as defined for the source type (or the
-result of casting the value to an <code>xs:string</code>, in the
-case of types that have no canonical lexical representation defined
-for them).</p>
+target type, then a <span>dynamic</span> error is raised [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>]. See <a href="#xmlschema-2">[XML Schema Part 2: Datatypes Second Edition]</a>.
+In the case of the pattern facet (which applies to the lexical
+space rather than the value space), the pattern is tested against
+the canonical lexical representation of the value, as defined for
+the source type (or the result of casting the value to an
+<code>xs:string</code>, in the case of types that have no canonical
+lexical representation defined for them).</p>
             <p>Note that this will cause casts to fail if the pattern excludes
 the canonical lexical representation of the source type. For
 example, if the type <code>my:distance</code> is defined as a
@@ -32572,7 +33443,9 @@
                   <li>
                     <p>If <em>SV</em> is an instance of <code>xs:string</code> or
 <code>xs:untypedAtomic</code>, check its value against the pattern
-facet of <em>TT</em>, and raise an error [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] if the check fails.</p>
+facet of <em>TT</em>, and raise a <span>dynamic</span> error
+[<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] if
+the check fails.</p>
                   </li>
                 </ol>
               </li>
@@ -32659,6 +33532,8 @@
             <p>If more than one of these conditions applies, then the casting
 is done according to the rules for the first condition that
 applies.</p>
+            <p>If none of these conditions applies, the cast fails with a
+dynamic error [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>].</p>
             <p>Example: consider a type <var>U</var> whose member types are
 <code>xs:integer</code> and <code>xs:date</code>.</p>
             <ul>
@@ -32691,10 +33566,10 @@
 <code>xs:short</code> value <code>93</code>.</p>
               </li>
               <li>
-                <p>The expression <code>"93.7" cast as V</code> raises an error
-[<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] on
-the grounds that the string <code>"93.7"</code> is not in the
-lexical space of the union type.</p>
+                <p>The expression <code>"93.7" cast as V</code> raises a
+<span>dynamic</span> error [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] on the grounds that the string
+<code>"93.7"</code> is not in the lexical space of the union
+type.</p>
               </li>
             </ul>
             <p>Example: consider a type <var>W</var> that is derived from the
@@ -32706,10 +33581,9 @@
 <code>xs:short</code> value <code>12</code>.</p>
               </li>
               <li>
-                <p>The expression <code>"123" cast as V</code> raises an error
-[<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] on
-the grounds that the string <code>"123"</code> does not match the
-pattern facet.</p>
+                <p>The expression <code>"123" cast as V</code> raises an
+<span>dynamic</span> error [<a href="#ERRFORG0001" title="err:FORG0001">err:FORG0001</a>] on the grounds that the string
+<code>"123"</code> does not match the pattern facet.</p>
               </li>
             </ul>
           </div>
@@ -32916,7 +33790,7 @@
             </dd>
             <dt class="label">
               <span>
-                <a name="Unicode-Normalization" id="Unicode-Normalization"/>Unicode Normaliation Forms</span>
+                <a name="Unicode-Normalization" id="Unicode-Normalization"/>Unicode Normalization Forms</span>
             </dt>
             <dd>
               <div>Unicode Standard Annex #15, Unicode Normalization Forms.
@@ -32966,7 +33840,7 @@
 (XPath) Version 1.0</cite>
                 </a>, Steven DeRose and James Clark,
 Editors. World Wide Web Consortium, 16 Nov 1999. This version is
-http://www.w3.org/TR/1999/REC-xpath-19991116/. The <a href="http://www.w3.org/TR/xpath/";>latest version</a> is available at
+http://www.w3.org/TR/1999/REC-xpath-19991116. The <a href="http://www.w3.org/TR/xpath/";>latest version</a> is available at
 http://www.w3.org/TR/xpath/.</div>
             </dd>
             <dt class="label">
@@ -32996,13 +33870,30 @@
                   <cite>XML Path
 Language (XPath) 3.0</cite>
                 </a>, Jonathan Robie, Don Chamberlin,
-Michael Dyck, John Snelson, Editors. World Wide Web Consortium, 13
-December 2011. This version is
-http://www.w3.org/TR/2011/WD-xpath-30-20111213/. The <a href="http://www.w3.org/TR/xpath-30/";>latest version</a> is available at
+Michael Dyck, John Snelson, Editors. World Wide Web Consortium, 08
+January 2013. This version is
+http://www.w3.org/TR/2013/CR-xpath-30-20130108/. The <a href="http://www.w3.org/TR/xpath-30/";>latest version</a> is available at
 http://www.w3.org/TR/xpath-30/.</div>
             </dd>
             <dt class="label">
               <span>
+                <a name="xpath-functions" id="xpath-functions"/>XQuery 1.0 and XPath 2.0 Functions and
+Operators</span>
+            </dt>
+            <dd>
+              <div>
+                <a href="http://www.w3.org/TR/xpath-functions/";>
+                  <cite>XQuery
+1.0 and XPath 2.0 Functions and Operators (Second
+Edition)</cite>
+                </a>, Ashok Malhotra, Jim Melton, and Norman Walsh,
+Editors. World Wide Web Consortium, 14 December 2010. This version
+is http://www.w3.org/TR/2010/REC-xpath-functions-20101214/. The
+<a href="http://www.w3.org/TR/xpath-functions/";>latest version</a>
+is available at http://www.w3.org/TR/xpath-functions/.</div>
+            </dd>
+            <dt class="label">
+              <span>
                 <a name="xslt20" id="xslt20"/>XSL
 Transformations (XSLT) Version 2.0</span>
             </dt>
@@ -33024,10 +33915,13 @@
             </dt>
             <dd>
               <div>
-                <cite>XSL Transformations (XSLT) Version 3.0</cite>
-(expected), Michael Kay, Editor. World Wide Web Consortium, (not
-yet published but anticipated in 2012; see the <a href="http://www.w3.org/TR/#tr_XSLT";>list of XSLT
-specifications</a>)</div>
+                <a href="http://www.w3.org/TR/xslt-30/";>
+                  <cite>XSL
+Transformations (XSLT) Version 3.0</cite>
+                </a>, Michael Kay, Editor.
+World Wide Web Consortium, 10 July 2012. This version is
+http://www.w3.org/TR/2012/WD-xslt-30-20120710/. The <a href="http://www.w3.org/TR/xslt-30/";>latest version</a> is available at
+http://www.w3.org/TR/xslt-30/.</div>
             </dd>
             <dt class="label">
               <span>
@@ -33040,8 +33934,8 @@
                   <cite>XQuery and XPath
 Data Model (XDM) 3.0</cite>
                 </a>, Norman Walsh, John Snelson,
-Editors. World Wide Web Consortium, 13 December 2011. This version
-is http://www.w3.org/TR/2011/WD-xpath-datamodel-30-20111213/. The
+Editors. World Wide Web Consortium, 08 January 2013. This version
+is http://www.w3.org/TR/2013/CR-xpath-datamodel-30-20130108/. The
 <a href="http://www.w3.org/TR/xpath-datamodel-30/";>latest
 version</a> is available at
 http://www.w3.org/TR/xpath-datamodel-30/.</div>
@@ -33057,8 +33951,8 @@
                   <cite>XSLT and
 XQuery Serialization 3.0</cite>
                 </a>, Henry Zongaro, Editor. World
-Wide Web Consortium, 13 December 2011. This version is
-http://www.w3.org/TR/2011/WD-xslt-xquery-serialization-30-20111213/.
+Wide Web Consortium, 19 March 2013. This version is
+http://www.w3.org/TR/2013/CR-xslt-xquery-serialization-30-20130319/.
 The <a href="http://www.w3.org/TR/xslt-xquery-serialization-30/";>latest
 version</a> is available at
 http://www.w3.org/TR/xslt-xquery-serialization-30/.</div>
@@ -33106,9 +34000,9 @@
                   <cite>XQuery 3.0: An
 XML Query Language</cite>
                 </a>, Jonathan Robie, Don Chamberlin,
-Michael Dyck, John Snelson, Editors. World Wide Web Consortium, 13
-December 2011. This version is
-http://www.w3.org/TR/2011/WD-xquery-30-20111213/. The <a href="http://www.w3.org/TR/xquery-30/";>latest version</a> is available
+Michael Dyck, John Snelson, Editors. World Wide Web Consortium, 08
+January 2013. This version is
+http://www.w3.org/TR/2013/CR-xquery-30-20130108/. The <a href="http://www.w3.org/TR/xquery-30/";>latest version</a> is available
 at http://www.w3.org/TR/xquery-30/.</div>
             </dd>
             <dt class="label">
@@ -33121,9 +34015,9 @@
                 <a href="http://www.w3.org/TR/xinclude/";>
                   <cite>XML Inclusions
 (XInclude) Version 1.0 (Second Edition)</cite>
-                </a>, Daniel
-Veillard, David Orchard, and Jonathan Marsh, Editors. World Wide
-Web Consortium, 15 Nov 2006. This version is
+                </a>, David Orchard,
+Jonathan Marsh, and Daniel Veillard, Editors. World Wide Web
+Consortium, 15 Nov 2006. This version is
 http://www.w3.org/TR/2006/REC-xinclude-20061115/. The <a href="http://www.w3.org/TR/xinclude/";>latest version</a> is available at
 http://www.w3.org/TR/xinclude/.</div>
             </dd>
@@ -33229,12 +34123,6 @@
         <p>The error text provided with these errors is non-normative.</p>
         <dl>
           <dt>
-            <a name="ERRFOER0000" id="ERRFOER0000"/>err:FOER0000,
-Unidentified error.</dt>
-          <dd>
-            <p>Unidentified error.</p>
-          </dd>
-          <dt>
             <a name="ERRFOAR0001" id="ERRFOAR0001"/>err:FOAR0001,
 Division by zero.</dt>
           <dd>
@@ -33251,51 +34139,166 @@
           <dt>
             <a name="ERRFOCA0001" id="ERRFOCA0001"/>err:FOCA0001, Input
 value too large for decimal.</dt>
+          <dd>
+            <p>Raised when casting to <code>xs:decimal</code> if the supplied
+value exceeds the implementation-defined limits for the data
+type.</p>
+          </dd>
           <dt>
             <a name="ERRFOCA0002" id="ERRFOCA0002"/>err:FOCA0002,
 Invalid lexical value.</dt>
+          <dd>
+            <p>Raised by <a href="#func-resolve-QName">
+                <code>fn:resolve-QName</code>
+              </a> and
+<a href="#func-QName">
+                <code>fn:QName</code>
+              </a> when a supplied
+value does not have the lexical form of a QName or URI
+respectively; and when casting to decimal, if the supplied value is
+NaN or Infinity.</p>
+          </dd>
           <dt>
             <a name="ERRFOCA0003" id="ERRFOCA0003"/>err:FOCA0003, Input
 value too large for integer.</dt>
+          <dd>
+            <p>Raised when casting to <code>xs:integer</code> if the supplied
+value exceeds the implementation-defined limits for the data
+type.</p>
+          </dd>
           <dt>
             <a name="ERRFOCA0005" id="ERRFOCA0005"/>err:FOCA0005, NaN
 supplied as float/double value.</dt>
+          <dd>
+            <p>Raised when multiplying or dividing a duration by a number, if
+the number supplied is NaN.</p>
+          </dd>
           <dt>
             <a name="ERRFOCA0006" id="ERRFOCA0006"/>err:FOCA0006, String
 to be cast to decimal has too many digits of precision.</dt>
+          <dd>
+            <p>Raised when casting a string to <code>xs:decimal</code> if the
+string has more digits of precision than the implementation can
+represent (the implementation also has the option of rounding).</p>
+          </dd>
           <dt>
             <a name="ERRFOCH0001" id="ERRFOCH0001"/>err:FOCH0001,
 Codepoint not valid.</dt>
+          <dd>
+            <p>Raised by <a href="#func-codepoints-to-string">
+                <code>fn:codepoints-to-string</code>
+              </a>
+if the input contains an integer that is not the codepoint of a
+valid XML character.</p>
+          </dd>
           <dt>
             <a name="ERRFOCH0002" id="ERRFOCH0002"/>err:FOCH0002,
 Unsupported collation.</dt>
+          <dd>
+            <p>Raised by any function that uses a collation if the requested
+collation is not recognized.</p>
+          </dd>
           <dt>
             <a name="ERRFOCH0003" id="ERRFOCH0003"/>err:FOCH0003,
 Unsupported normalization form.</dt>
+          <dd>
+            <p>Raised by <a href="#func-normalize-unicode">
+                <code>fn:normalize-unicode</code>
+              </a> if
+the requested normalization form is not supported by the
+implementation.</p>
+          </dd>
           <dt>
             <a name="ERRFOCH0004" id="ERRFOCH0004"/>err:FOCH0004,
 Collation does not support collation units.</dt>
+          <dd>
+            <p>Raised by functions such as <a href="#func-contains">
+                <code>fn:contains</code>
+              </a> if the requested
+collation does not operate on a character-by-character basis.</p>
+          </dd>
           <dt>
             <a name="ERRFODC0001" id="ERRFODC0001"/>err:FODC0001, No
 context document.</dt>
+          <dd>
+            <p>Raised by <a href="#func-id">
+                <code>fn:id</code>
+              </a>, <a href="#func-idref">
+                <code>fn:idref</code>
+              </a>, and <a href="#func-element-with-id">
+                <code>fn:element-with-id</code>
+              </a> if the
+node that identifies the tree to be searched is a node in a tree
+whose root is not a document node.</p>
+          </dd>
           <dt>
             <a name="ERRFODC0002" id="ERRFODC0002"/>err:FODC0002, Error
 retrieving resource.</dt>
+          <dd>
+            <p>Raised by <a href="#func-doc">
+                <code>fn:doc</code>
+              </a>, <a href="#func-collection">
+                <code>fn:collection</code>
+              </a>, and <a href="#func-uri-collection">
+                <code>fn:uri-collection</code>
+              </a> to
+indicate that either the supplied URI cannot be dereferenced to
+obtain a resource, or the resource that is returned in not
+parseable as XML.</p>
+          </dd>
           <dt>
             <a name="ERRFODC0003" id="ERRFODC0003"/>err:FODC0003,
 Function not defined as deterministic.</dt>
+          <dd>
+            <p>Raised by <a href="#func-doc">
+                <code>fn:doc</code>
+              </a>, <a href="#func-collection">
+                <code>fn:collection</code>
+              </a> to indicate that
+it is not possible to return a result that is guaranteed
+deterministic.</p>
+          </dd>
           <dt>
             <a name="ERRFODC0004" id="ERRFODC0004"/>err:FODC0004,
 Invalid argument to fn:collection.</dt>
+          <dd>
+            <p>Raised by <a href="#func-collection">
+                <code>fn:collection</code>
+              </a> if the argument
+is not a valid <code>xs:anyURI</code>.</p>
+          </dd>
           <dt>
             <a name="ERRFODC0005" id="ERRFODC0005"/>err:FODC0005,
 Invalid argument to fn:doc or fn:doc-available.</dt>
+          <dd>
+            <p>Raised (optionally) by <a href="#func-doc">
+                <code>fn:doc</code>
+              </a> and <a href="#func-doc-available">
+                <code>fn:doc-available</code>
+              </a> if the
+argument is not a valid <code>xs:anyURI</code>.</p>
+          </dd>
           <dt>
             <a name="ERRFODC0006" id="ERRFODC0006"/>err:FODC0006, String
 passed to fn:parse-xml is not a well-formed XML document.</dt>
+          <dd>
+            <p>Raised by <a href="#func-parse-xml">
+                <code>fn:parse-xml</code>
+              </a> if the supplied
+string is not a well-formed and namespace-well-formed XML document;
+or if DTD validation is requested and the document is not valid
+against its DTD.</p>
+          </dd>
           <dt>
-            <a name="ERRFODC0007" id="ERRFODC0007"/>err:FODC0007, Base
-URI passed to fn:parse-xml is not a valid absolute URI.</dt>
+            <a name="ERRFODC0010" id="ERRFODC0010"/>err:FODC0010, The
+processor does not support serialization.</dt>
+          <dd>
+            <p>Raised when <a href="#func-serialize">
+                <code>fn:serialize</code>
+              </a> is called and the
+processor does not support serialization, in cases where the host
+language makes serialization an optional feature.</p>
+          </dd>
           <dt>
             <a name="ERRFODF1280" id="ERRFODF1280"/>err:FODF1280,
 Invalid decimal format name.</dt>
@@ -33320,12 +34323,35 @@
           <dt>
             <a name="ERRFODT0001" id="ERRFODT0001"/>err:FODT0001,
 Overflow/underflow in date/time operation.</dt>
+          <dd>
+            <p>Raised when casting to date/time data types, or performing
+arithmetic with date/time values, if arithmetic overflow or
+underflow occurs.</p>
+          </dd>
           <dt>
             <a name="ERRFODT0002" id="ERRFODT0002"/>err:FODT0002,
 Overflow/underflow in duration operation.</dt>
+          <dd>
+            <p>Raised when casting to duration data types, or performing
+arithmetic with duration values, if arithmetic overflow or
+underflow occurs.</p>
+          </dd>
           <dt>
             <a name="ERRFODT0003" id="ERRFODT0003"/>err:FODT0003,
 Invalid timezone value.</dt>
+          <dd>
+            <p>Raised by <code>adjust-date-to-timezone</code> and related
+functions if the supplied timezone is invalid.</p>
+          </dd>
+          <dt>
+            <a name="ERRFOER0000" id="ERRFOER0000"/>err:FOER0000,
+Unidentified error.</dt>
+          <dd>
+            <p>Error code used by <a href="#func-error">
+                <code>fn:error</code>
+              </a> when no other error code is
+provided.</p>
+          </dd>
           <dt>
             <a name="ERRFOFD1340" id="ERRFOFD1340"/>err:FOFD1340,
 Invalid date/time formatting picture string.</dt>
@@ -33353,103 +34379,207 @@
 component that is not present in a time.</p>
           </dd>
           <dt>
-            <a name="ERRFOFI0001" id="ERRFOFI0001"/>err:FOFI0001,
-Language argument is not castable to xs:language.</dt>
-          <dd>
-            <p>This error is raised if the language argument supplied to
-<a href="#func-format-integer">
-                <code>fn:format-integer</code>
-              </a>
-is not castable to <code>xs:language</code>.</p>
-          </dd>
-          <dt>
-            <a name="ERRFOFL0001" id="ERRFOFL0001"/>err:FOFL0001,
-Dynamic call on context-dependent function item.</dt>
-          <dd>
-            <p>This error is raised if the <a href="#func-function-lookup">
-                <code>fn:function-lookup</code>
-              </a> returns
-a context-dependent function and the context-dependent function is
-then called.</p>
-          </dd>
-          <dt>
-            <a name="ERRFOJS0001" id="ERRFOJS0001"/>err:FOJS0001, Input
-to parse-JSON does not conform to JSON syntax</dt>
-          <dt>
-            <a name="ERRFOJS0002" id="ERRFOJS0002"/>err:FOJS0002,
-Invalid escaped character in JSON input</dt>
-          <dt>
             <a name="ERRFONS0004" id="ERRFONS0004"/>err:FONS0004, No
 namespace found for prefix.</dt>
+          <dd>
+            <p>Raised by <a href="#func-resolve-QName">
+                <code>fn:resolve-QName</code>
+              </a> and
+analagous functions if a supplied QName has a prefix that has no
+binding to a namespace.</p>
+          </dd>
           <dt>
             <a name="ERRFONS0005" id="ERRFONS0005"/>err:FONS0005,
 Base-uri not defined in the static context.</dt>
+          <dd>
+            <p>Raised by <a href="#func-resolve-uri">
+                <code>fn:resolve-uri</code>
+              </a> if no base URI
+is available for resolving a relative URI.</p>
+          </dd>
           <dt>
             <a name="ERRFORG0001" id="ERRFORG0001"/>err:FORG0001,
 Invalid value for cast/constructor.</dt>
+          <dd>
+            <p>A general-purpose error raised when casting, if a cast between
+two data types is allowed in principle, but the supplied value
+cannot be converted: for example when attempting to cast the string
+"nine" to an integer.</p>
+          </dd>
           <dt>
             <a name="ERRFORG0002" id="ERRFORG0002"/>err:FORG0002,
 Invalid argument to fn:resolve-uri().</dt>
+          <dd>
+            <p>Raised when either argument to <a href="#func-resolve-uri">
+                <code>fn:resolve-uri</code>
+              </a> is not a valid
+URI/IRI.</p>
+          </dd>
           <dt>
             <a name="ERRFORG0003" id="ERRFORG0003"/>err:FORG0003,
 fn:zero-or-one called with a sequence containing more than one
 item.</dt>
+          <dd>
+            <p>Raised by <a href="#func-zero-or-one">
+                <code>fn:zero-or-one</code>
+              </a> if the supplied
+value contains more than one item.</p>
+          </dd>
           <dt>
             <a name="ERRFORG0004" id="ERRFORG0004"/>err:FORG0004,
 fn:one-or-more called with a sequence containing no items.</dt>
+          <dd>
+            <p>Raised by <a href="#func-one-or-more">
+                <code>fn:one-or-more</code>
+              </a> if the supplied
+value is an empty sequence.</p>
+          </dd>
           <dt>
             <a name="ERRFORG0005" id="ERRFORG0005"/>err:FORG0005,
 fn:exactly-one called with a sequence containing zero or more than
 one item.</dt>
+          <dd>
+            <p>Raised by <a href="#func-exactly-one">
+                <code>fn:exactly-one</code>
+              </a> if the supplied
+value is not a singleton sequence.</p>
+          </dd>
           <dt>
             <a name="ERRFORG0006" id="ERRFORG0006"/>err:FORG0006,
 Invalid argument type.</dt>
+          <dd>
+            <p>Raised by functions such as <a href="#func-max">
+                <code>fn:max</code>
+              </a>, <a href="#func-min">
+                <code>fn:min</code>
+              </a>, <a href="#func-avg">
+                <code>fn:avg</code>
+              </a>, <a href="#func-sum">
+                <code>fn:sum</code>
+              </a> if the supplied sequence
+contains values inappropriate to this function.</p>
+          </dd>
           <dt>
             <a name="ERRFORG0008" id="ERRFORG0008"/>err:FORG0008, The
 two arguments to fn:dateTime have inconsistent timezones.</dt>
+          <dd>
+            <p>Raised by <a href="#func-dateTime">
+                <code>fn:dateTime</code>
+              </a>
+if the two arguments both have timezones and the timezones are
+different.</p>
+          </dd>
           <dt>
             <a name="ERRFORG0009" id="ERRFORG0009"/>err:FORG0009, Error
 in resolving a relative URI against a base URI in
 fn:resolve-uri.</dt>
+          <dd>
+            <p>A catch-all error for <a href="#func-resolve-uri">
+                <code>fn:resolve-uri</code>
+              </a>, recognizing
+that the implementation can choose between a variety of algorithms
+and that some of these may fail for a variety of reasons.</p>
+          </dd>
           <dt>
             <a name="ERRFORX0001" id="ERRFORX0001"/>err:FORX0001,
 Invalid regular expression flags.</dt>
+          <dd>
+            <p>Raised by regular expression functions such as <a href="#func-matches">
+                <code>fn:matches</code>
+              </a> and <a href="#func-replace">
+                <code>fn:replace</code>
+              </a> if the regular
+expression flags contain a character other than
+<code>imsx</code>
+            </p>
+          </dd>
           <dt>
             <a name="ERRFORX0002" id="ERRFORX0002"/>err:FORX0002,
 Invalid regular expression.</dt>
+          <dd>
+            <p>Raised by regular expression functions such as <a href="#func-matches">
+                <code>fn:matches</code>
+              </a> and <a href="#func-replace">
+                <code>fn:replace</code>
+              </a> if the regular
+expression is syntactically invalid.</p>
+          </dd>
           <dt>
             <a name="ERRFORX0003" id="ERRFORX0003"/>err:FORX0003,
 Regular expression matches zero-length string.</dt>
+          <dd>
+            <p>For functions such as <a href="#func-replace">
+                <code>fn:replace</code>
+              </a> and <a href="#func-tokenize">
+                <code>fn:tokenize</code>
+              </a>, raises an error if
+the supplied regular expression is capable of matching a zero
+length string.</p>
+          </dd>
           <dt>
             <a name="ERRFORX0004" id="ERRFORX0004"/>err:FORX0004,
 Invalid replacement string.</dt>
+          <dd>
+            <p>Raised by <a href="#func-replace">
+                <code>fn:replace</code>
+              </a> to
+report errors in the replacement string.</p>
+          </dd>
           <dt>
             <a name="ERRFOTY0012" id="ERRFOTY0012"/>err:FOTY0012,
 Argument to fn:data() contains a node that does not have a typed
 value.</dt>
+          <dd>
+            <p>Raised by <a href="#func-data">
+                <code>fn:data</code>
+              </a>, or by
+implicit atomization, if applied to a node with no typed value, the
+main example being an element validated against a complex type that
+defines it to have element-only content.</p>
+          </dd>
           <dt>
             <a name="ERRFOTY0013" id="ERRFOTY0013"/>err:FOTY0013, The
 argument to fn:data() contains a function item.</dt>
+          <dd>
+            <p>Raised by <a href="#func-data">
+                <code>fn:data</code>
+              </a>, or by
+implicit atomization, if the sequence to be atomized contains a
+function item.</p>
+          </dd>
           <dt>
             <a name="ERRFOTY0014" id="ERRFOTY0014"/>err:FOTY0014, The
 argument to fn:string() is a function item.</dt>
+          <dd>
+            <p>Raised by <a href="#func-string">
+                <code>fn:string</code>
+              </a>, or
+by implicit string conversion, if the input sequence contains a
+function item.</p>
+          </dd>
           <dt>
             <a name="ERRFOTY0015" id="ERRFOTY0015"/>err:FOTY0015, An
 argument to fn:deep-equal() contains a function item.</dt>
+          <dd>
+            <p>Raised by <a href="#func-deep-equal">
+                <code>fn:deep-equal</code>
+              </a> if either input
+sequence contains a function item.</p>
+          </dd>
           <dt>
             <a name="ERRFOUT1170" id="ERRFOUT1170"/>err:FOUT1170,
 Invalid $href argument to fn:unparsed-text() (etc.)</dt>
           <dd>
-            <p>An error is raised if the <code>$href</code> argument contains a
-fragment identifier, or if it cannot be used to retrieve a resource
-containing text.</p>
+            <p>A <span>dynamic</span> error is raised if the <code>$href</code>
+argument contains a fragment identifier, or if it cannot be used to
+retrieve a resource containing text.</p>
           </dd>
           <dt>
             <a name="ERRFOUT1190" id="ERRFOUT1190"/>err:FOUT1190, Cannot
 decode resource retrieved by fn:unparsed-text() (etc.)</dt>
           <dd>
-            <p>An error is raised if the retrieved resource contains octets
-that cannot be decoded into Unicode <a title="character" class="termref" href="#character">
+            <p>A <span>dynamic</span> error is raised if the retrieved resource
+contains octets that cannot be decoded into Unicode <a title="character" class="termref" href="#character">
                 <span class="arrow">·</span>characters<span class="arrow">·</span>
               </a> using
 the specified encoding, or if the resulting characters are not
@@ -33461,808 +34591,15 @@
 infer encoding of resource retrieved by fn:unparsed-text()
 (etc.)</dt>
           <dd>
-            <p>An error is raised if <code>$encoding</code> is absent and the
-processor cannot infer the encoding using external information and
-the encoding is not UTF-8.</p>
+            <p>A <span>dynamic</span> error is raised if <code>$encoding</code>
+is absent and the processor cannot infer the encoding using
+external information and the encoding is not UTF-8.</p>
           </dd>
         </dl>
       </div>
       <div class="div1">
         <h2>
-          <a name="xpath1-compatibility" id="xpath1-compatibility"/>C
-Compatibility with XPath 1.0 (Non-Normative)</h2>
-        <p>This appendix summarizes the relationship between certain
-functions defined in <a href="#xpath">[XML Path Language (XPath)
-Version 1.0]</a> and the corresponding functions defined in this
-document. The first column of the table provides the signature of
-functions defined in this document. The second column provides the
-signature of the corresponding function in <a href="#xpath">[XML
-Path Language (XPath) Version 1.0]</a>. The third column describes
-the differences in the semantics of the corresponding functions.
-The functions appear in the order they appear in <a href="#xpath">[XML Path Language (XPath) Version 1.0]</a>.</p>
-        <p>The evaluation of the arguments to the functions defined in this
-document depends on whether the XPath 1.0 compatibility mode is on
-or off. See <a href="#xpath20">[XML Path Language (XPath) 2.0]</a>.
-If the mode is on, the following conversions are applied, in order,
-before the argument value is passed to the function:</p>
-        <ul>
-          <li>
-            <p>If the expected type is a single item or an optional single
-item, (examples: <code>xs:string, xs:string?, xs:untypedAtomic,
-xs:untypedAtomic?, node(), node()?, item(), item()?</code>), then
-the given value <code>V</code> is effectively replaced by <a href="#func-subsequence">
-                <code>fn:subsequence(V, 1, 1)</code>
-              </a>.</p>
-          </li>
-          <li>
-            <p>If the expected type is <code>xs:string</code> or
-<code>xs:string?</code>, then the given value <code>V</code> is
-effectively replaced by <a href="#func-string">
-                <code>fn:string(V)</code>
-              </a>.</p>
-          </li>
-          <li>
-            <p>If the expected type is numeric or optional numeric, then the
-given value <code>V</code> is effectively replaced by <a href="#func-number">
-                <code>fn:number(V)</code>
-              </a>.</p>
-          </li>
-          <li>
-            <p>Otherwise, the given value is unchanged.</p>
-          </li>
-        </ul>
-        <table summary="Issues list" border="1" width="100%">
-          <col width="33%" span="1"/>
-          <col width="33%" span="1"/>
-          <col width="33%" span="1"/>
-          <tbody>
-            <tr>
-              <th colspan="1">XQuery 1.0 and XPath 2.0</th>
-              <th colspan="1">XPath 1.0</th>
-              <th colspan="1">Notes</th>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:last</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:integer</code>
-                </div>
-              </td>
-              <td>
-                <code>last() =&gt; number</code>
-              </td>
-              <td>Precision of numeric results may be different.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:position</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:integer</code>
-                </div>
-              </td>
-              <td>
-                <code>position() =&gt; number</code>
-              </td>
-              <td>Precision of numeric results may be different.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:count</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">item*</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:integer</code>
-                </div>
-              </td>
-              <td>
-                <code>count(node-set) =&gt; number</code>
-              </td>
-              <td>Precision of numeric results may be different.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:id</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string*</code>)<code class="as"> as </code>
-                  <code class="return-type">element()*</code>
-                </div>
-              </td>
-              <td>
-                <code>id(object) =&gt; node-set</code>
-              </td>
-              <td>XPath 2.0 behavior is different for boolean and numeric
-arguments. The recognition of a node as an id value is sensitive to
-the manner in which the datamodel is constructed. In XPath 1.0 the
-whole string is treated as a unit. In XPath 2.0 each string is
-treated as a list.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:local-name</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>local-name(node-set?) =&gt;
-string</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, an error will occur
-if argument has more than one node.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:local-name</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">node()?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:namespace-uri</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>namespace-uri(node-set?) =&gt;
-string</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, an error will occur
-if argument has more than one node.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:namespace-uri</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">node?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:name</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">node()?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-              <td>
-                <code>name(node-set?) =&gt; string</code>
-              </td>
-              <td>If compatibility mode is off, an error will occur if argument
-has more than one node. The rules for determining the prefix are
-more precisely defined in <a href="#xpath20">[XML Path Language
-(XPath) 2.0]</a>. Function is not "well-defined" for parentless
-attribute nodes.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:string</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>string(object) =&gt; string</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, an error will occur
-if argument has more than one node. Representations of numeric
-values are XPath 1.0 compatible except for the special values
-positive and negative infinity, and for values outside the range
-1.0e-6 to 1.0e+6.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:string</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">item()?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                    <tr>
-                      <td valign="baseline" rowspan="3">
-                        <code class="function">fn:concat</code>(</td>
-                      <td valign="baseline">
-                        <code class="arg">$arg1</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:anyAtomicType?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$arg2</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:anyAtomicType?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <span class="varargs">...</span>
-                      </td>
-                      <td valign="baseline">)<code class="as"> as </code>
-                        <code class="return-type">xs:string</code>
-                      </td>
-                    </tr>
-                  </table>
-                </div>
-              </td>
-              <td>
-                <code>concat(string, string, string*) =&gt; string</code>
-              </td>
-              <td>If compatibility mode is off, an error will occur if an
-argument has more than one node. If compatibility mode on, the
-first node in the sequence is used.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:starts-with</code>(<code class="arg">$arg1</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>, <code class="arg">$arg2</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:boolean</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>starts-with(string, string) =&gt;
-boolean</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, an error will occur
-if either argument has more than one node or is a number or a
-boolean. If compatibility mode is on, implicit conversion is
-performed.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                    <tr>
-                      <td valign="baseline" rowspan="3">
-                        <code class="function">fn:starts-with</code>(</td>
-                      <td valign="baseline">
-                        <code class="arg">$arg1</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$arg2</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$collation</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string</code>)<code class="as"> as </code>
-                        <code class="return-type">xs:boolean</code>
-                      </td>
-                    </tr>
-                  </table>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:contains</code>(<code class="arg">$arg1</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>, <code class="arg">$arg2</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:boolean</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>contains(string, string) =&gt;
-boolean</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, an error will occur
-if either argument has more than one node or is a number or a
-boolean. If compatibility mode is on, implicit conversion is
-performed.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                    <tr>
-                      <td valign="baseline" rowspan="3">
-                        <code class="function">fn:contains</code>(</td>
-                      <td valign="baseline">
-                        <code class="arg">$arg1</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$arg2</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$collation</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string</code>)<code class="as"> as </code>
-                        <code class="return-type">xs:boolean</code>
-                      </td>
-                    </tr>
-                  </table>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:substring-before</code>(<code class="arg">$arg1</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>, <code class="arg">$arg2</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>substring-before(string, string) =&gt;
-string</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, an error will occur
-if either argument has more than one node or is a number or a
-boolean. If compatibility mode is on, implicit conversion is
-performed.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                    <tr>
-                      <td valign="baseline" rowspan="3">
-                        <code class="function">fn:substring-before</code>(</td>
-                      <td valign="baseline">
-                        <code class="arg">$arg1</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$arg2</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$collation</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string</code>)<code class="as"> as </code>
-                        <code class="return-type">xs:string</code>
-                      </td>
-                    </tr>
-                  </table>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:substring-after</code>(<code class="arg">$arg1</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>, <code class="arg">$arg2</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>substring-after(string, string) =&gt;
-string</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, an error will occur
-if either argument has more than one node or is a number or a
-boolean. If compatibility mode is on, implicit conversion is
-performed.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                    <tr>
-                      <td valign="baseline" rowspan="3">
-                        <code class="function">fn:substring-after</code>(</td>
-                      <td valign="baseline">
-                        <code class="arg">$arg1</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$arg2</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$collation</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string</code>)<code class="as"> as </code>
-                        <code class="return-type">xs:string</code>
-                      </td>
-                    </tr>
-                  </table>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                    <tr>
-                      <td valign="baseline" rowspan="2">
-                        <code class="function">fn:substring</code>(</td>
-                      <td valign="baseline">
-                        <code class="arg">$sourceString</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$startingLoc</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:double</code>)<code class="as"> as </code>
-                        <code class="return-type">xs:string</code>
-                      </td>
-                    </tr>
-                  </table>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>substring(string, number, number?) =&gt;
-string</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, an error will occur
-if <code>$sourceString</code> has more than one node or is a number
-or a boolean. If compatibility mode is on, implicit conversion is
-performed.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                    <tr>
-                      <td valign="baseline" rowspan="3">
-                        <code class="function">fn:substring</code>(</td>
-                      <td valign="baseline">
-                        <code class="arg">$sourceString</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$startingLoc</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:double</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$length</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:double</code>)<code class="as"> as </code>
-                        <code class="return-type">xs:string</code>
-                      </td>
-                    </tr>
-                  </table>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:string-length</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:integer?</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>string-length(string?) =&gt;
-number</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, numbers and booleans
-will give errors for first arg. Also, multiple nodes will give
-error.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:string-length</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:integer?</code>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:normalize-space</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>normalize-space(string?) =&gt;
-string</code>
-              </td>
-              <td rowspan="2">If compatibility mode is off, an error will occur
-if <code>$arg</code> has more than one node or is a number or a
-boolean. If compatibility mode is on, implicit conversion is
-performed.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:normalize-space</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:string</code>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                    <tr>
-                      <td valign="baseline" rowspan="3">
-                        <code class="function">fn:translate</code>(</td>
-                      <td valign="baseline">
-                        <code class="arg">$arg</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string?</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$mapString</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string</code>,</td>
-                    </tr>
-                    <tr>
-                      <td valign="baseline">
-                        <code class="arg">$transString</code>
-                      </td>
-                      <td valign="baseline">
-                        <code class="as"> as </code>
-                        <code class="type">xs:string</code>)<code class="as"> as </code>
-                        <code class="return-type">xs:string</code>
-                      </td>
-                    </tr>
-                  </table>
-                </div>
-              </td>
-              <td>
-                <code>translate(string, string, string)=&gt; string</code>
-              </td>
-              <td>.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:boolean</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">item()*</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:boolean</code>
-                </div>
-              </td>
-              <td>
-                <code>boolean(object) =&gt; boolean</code>
-              </td>
-              <td/>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:not</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">item()*</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:boolean</code>
-                </div>
-              </td>
-              <td>
-                <code>not(boolean) =&gt; boolean</code>
-              </td>
-              <td/>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:true</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:boolean</code>
-                </div>
-              </td>
-              <td>
-                <code>true() =&gt; boolean</code>
-              </td>
-              <td/>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:false</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:boolean</code>
-                </div>
-              </td>
-              <td>
-                <code>false() =&gt; boolean</code>
-              </td>
-              <td/>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:lang</code>(<code class="arg">$testlang</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:string</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:boolean</code>
-                </div>
-              </td>
-              <td>
-                <code>lang(string) =&gt; boolean</code>
-              </td>
-              <td>If compatibility mode is off, numbers and booleans will give
-errors. Also, multiple nodes will give error. If compatibility mode
-is on, implicit conversion is performed.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:number</code>()<code class="as"> as </code>
-                  <code class="return-type">xs:double</code>
-                </div>
-              </td>
-              <td rowspan="2">
-                <code>number(object?) =&gt; number</code>
-              </td>
-              <td rowspan="2">Error if argument has more than one node when not
-in compatibility node.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:number</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:anyAtomicType?</code>)<code class="as"> as </code>
-                  <code class="return-type">xs:double</code>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:sum</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">xs:anyAtomicType*</code>)<code class="as"> as </code>
-                  <code class="return-varies">xs:anyAtomicType</code>
-                </div>
-              </td>
-              <td>
-                <code>sum(node-set) =&gt; number</code>
-              </td>
-              <td>2.0 raises an error if sequence contains values that cannot be
-added together such as NMTOKENS and other subtypes of string. 1.0
-returns <code>NaN</code>.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:floor</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">numeric?</code>)<code class="as"> as </code>
-                  <code class="return-varies">numeric?</code>
-                </div>
-              </td>
-              <td>
-                <code>floor(number)=&gt; number</code>
-              </td>
-              <td>In 2.0, if argument is <code>()</code>, the result is
-<code>()</code>. In 1.0, the result is <code>NaN</code>. If
-compatibility mode is off, an error will occur with more than one
-node. If compatibility mode is on, implicit conversion is
-performed.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:ceiling</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">numeric?</code>)<code class="as"> as </code>
-                  <code class="return-varies">numeric?</code>
-                </div>
-              </td>
-              <td>
-                <code>ceiling(number)=&gt; number</code>
-              </td>
-              <td>In 2.0, if argument is <code>()</code>, the result is
-<code>()</code>. In 1.0, the result is <code>NaN</code>. If
-compatibility mode is off, an error will occur with more than one
-node. If compatibility mode is on, implicit conversion is
-performed.</td>
-            </tr>
-            <tr>
-              <td>
-                <div class="proto">
-                  <code class="function">fn:round</code>(<code class="arg">$arg</code>
-                  <code class="as"> as </code>
-                  <code class="type">numeric?</code>)<code class="as"> as </code>
-                  <code class="return-varies">numeric?</code>
-                </div>
-              </td>
-              <td>
-                <code>round(number)=&gt; number</code>
-              </td>
-              <td>In 2.0, if argument is <code>()</code>, the result is
-<code>()</code>. In 1.0, the result is <code>NaN</code>. If
-compatibility mode is off, an error will occur with more than one
-node. If compatibility mode is on, implicit conversion is
-performed.</td>
-            </tr>
-          </tbody>
-        </table>
-      </div>
-      <div class="div1">
-        <h2>
-          <a name="examples" id="examples"/>D Illustrative
+          <a name="examples" id="examples"/>C Illustrative
 user-written functions (Non-Normative)</h2>
         <p>Certain functions that were proposed for inclusion in this
 function library have been excluded on the basis that it is
@@ -34277,7 +34614,7 @@
 put them in a common namespace.</p>
         <div class="div2">
           <h3>
-            <a name="if-empty-if-absent" id="if-empty-if-absent"/>D.1
+            <a name="if-empty-if-absent" id="if-empty-if-absent"/>C.1
 eg:if-empty and eg:if-absent</h3>
           <p>In some situations, users may want to provide default values for
 missing information that may be signaled by elements that are
@@ -34290,31 +34627,15 @@
 that return more specific types.</p>
           <div class="div3">
             <h4>
-              <a name="if-empty" id="if-empty"/>D.1.1 eg:if-empty</h4>
+              <a name="if-empty" id="if-empty"/>C.1.1 eg:if-empty</h4>
             <div class="exampleInner">
               <div class="proto">
-                <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                  <tr>
-                    <td valign="baseline" rowspan="2">
-                      <code class="function">fn:eg:if-empty</code>(</td>
-                    <td valign="baseline">
-                      <code class="arg">$node</code>
-                    </td>
-                    <td valign="baseline">
-                      <code class="as"> as </code>
-                      <code class="type">node()?</code>,</td>
-                  </tr>
-                  <tr>
-                    <td valign="baseline">
-                      <code class="arg">$value</code>
-                    </td>
-                    <td valign="baseline">
-                      <code class="as"> as </code>
-                      <code class="type">xs:anyAtomicType</code>)<code class="as"> as </code>
-                      <code class="return-type">xs:anyAtomicType*</code>
-                    </td>
-                  </tr>
-                </table>
+                <code class="function">eg:if-empty</code>(<code class="arg">$node</code>
+                <code class="as"> as </code>
+                <code class="type">node()?</code>, <code class="arg">$value</code>
+                <code class="as"> as </code>
+                <code class="type">xs:anyAtomicType</code>)<code class="as"> as </code>
+                <code class="return-type">xs:anyAtomicType*</code>
               </div>
             </div>
             <p>If the first argument is the empty sequence or an element
@@ -34346,31 +34667,15 @@
           </div>
           <div class="div3">
             <h4>
-              <a name="if-absent" id="if-absent"/>D.1.2 eg:if-absent</h4>
+              <a name="if-absent" id="if-absent"/>C.1.2 eg:if-absent</h4>
             <div class="exampleInner">
               <div class="proto">
-                <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
-                  <tr>
-                    <td valign="baseline" rowspan="2">
-                      <code class="function">fn:eg:if-absent</code>(</td>
-                    <td valign="baseline">
-                      <code class="arg">$node</code>
-                    </td>
-                    <td valign="baseline">
-                      <code class="as"> as </code>
-                      <code class="type">node()?</code>,</td>
-                  </tr>
-                  <tr>
-                    <td valign="baseline">
-                      <code class="arg">$value</code>
-                    </td>
-                    <td valign="baseline">
-                      <code class="as"> as </code>
-                      <code class="type">xs:anyAtomicType</code>)<code class="as"> as </code>
-                      <code class="return-type">xs:anyAtomicType*</code>
-                    </td>
-                  </tr>
-                </table>
+                <code class="function">eg:if-absent</code>(<code class="arg">$node</code>
+                <code class="as"> as </code>
+                <code class="type">node()?</code>, <code class="arg">$value</code>
+                <code class="as"> as </code>
+                <code class="type">xs:anyAtomicType</code>)<code class="as"> as </code>
+                <code class="return-type">xs:anyAtomicType*</code>
               </div>
             </div>
             <p>If the first argument is the empty sequence,
@@ -34402,18 +34707,18 @@
         </div>
         <div class="div2">
           <h3>
-            <a name="union-intersect-except-on-values" id="union-intersect-except-on-values"/>D.2 Union, intersection and
+            <a name="union-intersect-except-on-values" id="union-intersect-except-on-values"/>C.2 Union, intersection and
 difference on sequences of values</h3>
           <div class="div3">
             <h4>
-              <a name="value-union" id="value-union"/>D.2.1
+              <a name="value-union" id="value-union"/>C.2.1
 eg:value-union</h4>
             <div class="exampleInner">
               <div class="proto">
                 <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
                   <tr>
                     <td valign="baseline" rowspan="2">
-                      <code class="function">fn:eg:value-union</code>(</td>
+                      <code class="function">eg:value-union</code>(</td>
                     <td valign="baseline">
                       <code class="arg">$arg1</code>
                     </td>
@@ -34439,7 +34744,7 @@
             <p>XSLT implementation</p>
             <div class="exampleInner">
               <pre>
-xsl:function name="eg:value-union" as="xs:anyAtomicType*"&gt;
+&lt;xsl:function name="eg:value-union" as="xs:anyAtomicType*"&gt;
   &lt;xsl:param name="arg1" as="xs:anyAtomicType*"/&gt;
   &lt;xsl:param name="arg2" as="xs:anyAtomicType*"/&gt;
   &lt;xsl:sequence
@@ -34462,14 +34767,14 @@
           </div>
           <div class="div3">
             <h4>
-              <a name="value-intersect" id="value-intersect"/>D.2.2
+              <a name="value-intersect" id="value-intersect"/>C.2.2
 eg:value-intersect</h4>
             <div class="exampleInner">
               <div class="proto">
                 <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
                   <tr>
                     <td valign="baseline" rowspan="2">
-                      <code class="function">fn:eg:value-intersect</code>(</td>
+                      <code class="function">eg:value-intersect</code>(</td>
                     <td valign="baseline">
                       <code class="arg">$arg1</code>
                     </td>
@@ -34519,14 +34824,14 @@
           </div>
           <div class="div3">
             <h4>
-              <a name="value-except" id="value-except"/>D.2.3
+              <a name="value-except" id="value-except"/>C.2.3
 eg:value-except</h4>
             <div class="exampleInner">
               <div class="proto">
                 <table border="0" cellpadding="0" cellspacing="0" summary="Function/operator prototype">
                   <tr>
                     <td valign="baseline" rowspan="2">
-                      <code class="function">fn:eg:value-except</code>(</td>
+                      <code class="function">eg:value-except</code>(</td>
                     <td valign="baseline">
                       <code class="arg">$arg1</code>
                     </td>
@@ -34576,11 +34881,11 @@
         </div>
         <div class="div2">
           <h3>
-            <a name="index-of-node" id="index-of-node"/>D.3
+            <a name="index-of-node" id="index-of-node"/>C.3
 eg:index-of-node</h3>
           <div class="exampleInner">
             <div class="proto">
-              <code class="function">fn:eg:index-of-node</code>(<code class="arg">$seq</code>
+              <code class="function">eg:index-of-node</code>(<code class="arg">$seq</code>
               <code class="as"> as </code>
               <code class="type">node()*</code>, <code class="arg">$search</code>
               <code class="as"> as </code>
@@ -34634,7 +34939,7 @@
             <pre>
 declare function eg:index-of-node($seq as node()*, $search as node()) as xs:integer* 
 {
-  fn:map-pairs(function($node, $index) {
+  fn:for-each-pair(function($node, $index) {
      if($node is $search) then $index else () 
   }, $seq, 1 to fn:count($seq))
 }
@@ -34643,10 +34948,10 @@
         </div>
         <div class="div2">
           <h3>
-            <a name="string-pad" id="string-pad"/>D.4 eg:string-pad</h3>
+            <a name="string-pad" id="string-pad"/>C.4 eg:string-pad</h3>
           <div class="exampleInner">
             <div class="proto">
-              <code class="function">fn:eg:string-pad</code>(<code class="arg">$padString</code>
+              <code class="function">eg:string-pad</code>(<code class="arg">$padString</code>
               <code class="as"> as </code>
               <code class="type">xs:string?</code>, <code class="arg">$padCount</code>
               <code class="as"> as </code>
@@ -34688,10 +34993,10 @@
         </div>
         <div class="div2">
           <h3>
-            <a name="func-distinct-nodes-stable" id="func-distinct-nodes-stable"/>D.5 eg:distinct-nodes-stable</h3>
+            <a name="func-distinct-nodes-stable" id="func-distinct-nodes-stable"/>C.5 eg:distinct-nodes-stable</h3>
           <div class="exampleInner">
             <div class="proto">
-              <code class="function">fn:eg:distinct-nodes-stable</code>(<code class="arg">$arg</code>
+              <code class="function">eg:distinct-nodes-stable</code>(<code class="arg">$arg</code>
               <code class="as"> as </code>
               <code class="type">node()*</code>)<code class="as"> as </code>
               <code class="return-type">node()*</code>
@@ -34741,7 +35046,7 @@
         </div>
         <div class="div2">
           <h3>
-            <a name="highest-lowest" id="highest-lowest"/>D.6 Finding
+            <a name="highest-lowest" id="highest-lowest"/>C.6 Finding
 minima and maxima</h3>
           <p>The <a href="#func-min">
               <code>fn:min</code>
@@ -34763,7 +35068,7 @@
 joint highest (or lowest) then they are all returned.</p>
           <div class="div3">
             <h4>
-              <a name="highest" id="highest"/>D.6.1 eg:highest</h4>
+              <a name="highest" id="highest"/>C.6.1 eg:highest</h4>
             <p>The function <code>eg:highest</code> returns the items having
 the highest value for the supplied function.</p>
             <p>XSLT implementation</p>
@@ -34818,7 +35123,7 @@
           </div>
           <div class="div3">
             <h4>
-              <a name="lowest" id="lowest"/>D.6.2 eg:lowest</h4>
+              <a name="lowest" id="lowest"/>C.6.2 eg:lowest</h4>
             <p>The function <code>eg:lowest</code> returns the items having the
 lowest value for the supplied function.</p>
             <p>XSLT implementation</p>
@@ -34874,7 +35179,7 @@
         </div>
         <div class="div2">
           <h3>
-            <a name="sorting" id="sorting"/>D.7 Sorting</h3>
+            <a name="sorting" id="sorting"/>C.7 Sorting</h3>
           <p>Both XSLT and XQuery include constructs for sorting sequences.
 However, it can often be convenient to invoke sorting via a simple
 function call. The example function in this section takes two
@@ -34915,328 +35220,608 @@
       </div>
       <div class="div1">
         <h2>
-          <a name="impl-def" id="impl-def"/>E Checklist of
+          <a name="impl-def" id="impl-def"/>D Checklist of
 implementation-defined features (Non-Normative)</h2>
-        <p>This appendix provides a summary of features defined in this
-specification whose effect is explicitly <a title="implementation-defined" class="termref" href="#implementation-defined">
-            <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-          </a>. The conformance rules require vendors to
-provide documentation that explains how these choices have been
-exercised.</p>
-        <ol class="enumar">
+        <ol>
           <li>
             <p>It is <a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
               </a> which version of Unicode is supported, but it
-is recommended that the most recent version of Unicode be used.</p>
+is recommended that the most recent version of Unicode be used.
+(See <a href="#conformance">Conformance</a>.)</p>
           </li>
           <li>
             <p>It is <a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
               </a> whether the type system is based on XML Schema
-1.0 or XML Schema 1.1.</p>
+1.0 or XML Schema 1.1. (See <a href="#conformance">Conformance</a>.)</p>
           </li>
           <li>
             <p>It is <a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> whether the guarantee of node identity in
-relation to URI identity also holds for document nodes obtained by
-means other than the <a href="#func-doc">
+              </a> which version of <a href="#Unicode">[The
+Unicode Standard]</a> is supported, but it is recommended that the
+most recent version of Unicode be used. (See <a href="#character-terminology">Strings, characters, and
+codepoints</a>.)</p>
+          </li>
+          <li>
+            <p>Some functions (such as <a href="#func-distinct-values">
+                <code>fn:distinct-values</code>
+              </a> and
+<a href="#func-unordered">
+                <code>fn:unordered</code>
+              </a>) produce
+results in an <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> or <a title="implementation dependent" class="termref" href="#implementation-dependent">
+                <span class="arrow">·</span>implementation-dependent<span class="arrow">·</span>
+              </a> order. In such cases there is no guarantee
+that the order of results from different calls will be the same.
+These functions are said to be <b>non-deterministic with respect to
+ordering</b>. (See <a href="#properties-of-functions">Properties of
+functions</a>.)</p>
+          </li>
+          <li>
+            <p>Where the results of a function are described as being (to a
+greater or lesser extent) <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> or <a title="implementation dependent" class="termref" href="#implementation-dependent">
+                <span class="arrow">·</span>implementation-dependent<span class="arrow">·</span>
+              </a>, this does not by itself remove the
+requirement that the results should be deterministic: that is, that
+repeated calls with the same explicit and implicit arguments
+<strong>must</strong> return identical results. (See <a href="#properties-of-functions">Properties of functions</a>.)</p>
+          </li>
+          <li>
+            <p>In the case of a document node <code>$D</code> returned by the
+<a href="#func-doc">
                 <code>fn:doc</code>
-              </a>
-function, for example a document node passed as the initial context
-node of a query or transformation.</p>
-          </li>
-          <li>
-            <p>The destination of the output of <a href="#func-trace">
-                <code>fn:trace</code>
-              </a> is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>
-            </p>
-          </li>
-          <li>
-            <p>For integer operations that overflow, implementations <a title="may" class="termref" href="#may">
+              </a> function, or a document
+node at the root of a tree containing a node returned by the
+<a href="#func-collection">
+                <code>fn:collection</code>
+              </a> function,
+it will always be true that either <code>fn:document-uri($D)</code>
+returns the empty sequence, or that the following expression is
+true: <a href="#func-doc">
+                <code>fn:doc(fn:document-uri($D))</code>
+              </a> is
+<code>$D</code>. It is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> whether this guarantee also holds for document
+nodes obtained by other means, for example a document node passed
+as the initial context node of a query or transformation. (See
+<a href="#func-document-uri">fn:document-uri</a>.)</p>
+          </li>
+          <li>
+            <p>In addition, the values of <code>$value</code>, converted to an
+<code>xs:string</code>, and <code>$label</code>
+              <strong>may</strong> be directed to a trace data set. The
+destination of the trace output is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. The format of the trace output is <a title="implementation dependent" class="termref" href="#implementation-dependent">
+                <span class="arrow">·</span>implementation dependent<span class="arrow">·</span>
+              </a>. The ordering of output from calls of the
+<code>fn:trace</code> function is <a title="implementation dependent" class="termref" href="#implementation-dependent">
+                <span class="arrow">·</span>implementation dependent<span class="arrow">·</span>
+              </a>. (See <a href="#func-trace">fn:trace</a>.)</p>
+          </li>
+          <li>
+            <p>They <a title="may" class="termref" href="#may">
                 <span class="arrow">·</span>may<span class="arrow">·</span>
               </a> provide an
 <a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
               </a> mechanism that allows users to choose between
 raising an error and returning a result that is modulo the largest
-representable integer value.</p>
-          </li>
-          <li>
-            <p>For <code>xs:decimal</code> values the number of digits of
-precision returned by the numeric operators is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>. If the number of digits in the result exceeds
-the number of digits that the implementation supports, the result
-is truncated or rounded in an <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> manner.</p>
-          </li>
-          <li>
-            <p>IEEE-defined floating point exceptions <strong>may</strong> be
-notified to the application or to the user by some <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> warning condition.</p>
-          </li>
-          <li>
-            <p>It is <a title="implementation-defined" class="termref" href="#implementation-defined">
+representable integer value. See <a href="#ISO10967">[ISO
+10967]</a>. (See <a href="#op.numeric">Arithmetic operators on
+numeric values</a>.)</p>
+          </li>
+          <li>
+            <p>For <code>xs:decimal</code> values the number of digits of
+precision returned by the numeric operators is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. If the number of digits in the result exceeds
+the number of digits that the implementation supports, the result
+is truncated or rounded in an <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> manner. (See <a href="#op.numeric">Arithmetic
+operators on numeric values</a>.)</p>
+          </li>
+          <li>
+            <p>For <code>xs:decimal</code> values the number of digits of
+precision returned by the numeric operators is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. If the number of digits in the result exceeds
+the number of digits that the implementation supports, the result
+is truncated or rounded in an <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> manner. (See <a href="#op.numeric">Arithmetic
+operators on numeric values</a>.)</p>
+          </li>
+          <li>
+            <p>The <a href="#ieee754-2008">[IEEE 754-2008]</a> specification
+also describes handling of two exception conditions called
+<code>divideByZero</code> and <code>invalidOperation</code>. The
+IEEE <code>divideByZero</code> exception is raised not only by a
+direct attempt to divide by zero, but also by operations such as
+<code>log(0)</code>. The IEEE <code>invalidOperation</code>
+exception is raised by attempts to call a function with an argument
+that is outside the function's domain (for example,
+<code>sqrt(-1)</code> or <code>log(-1)</code>. These IEEE
+exceptions do not cause a dynamic error at the application level;
+rather they result in the relevant function or operator returning
+<code>NaN</code>. The underlying IEEE exception
+<strong>may</strong> be notified to the application or to the user
+by some <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> warning condition, but the observable effect
+on an application using the functions and operators defined in this
+specification is simply to return <code>NaN</code> with no error.
+(See <a href="#op.numeric">Arithmetic operators on numeric
+values</a>.)</p>
+          </li>
+          <li>
+            <p>The <a href="#ieee754-2008">[IEEE 754-2008]</a> specification
+distinguishes two NaN values, a quiet NaN and a signaling NaN.
+These two values are not distinguishable in the XDM model: the
+value spaces of <code>xs:float</code> and <code>xs:double</code>
+each include only a single <code>NaN</code> value. This does not
+prevent the implementation distinguishing them internally, and
+triggering different <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> warning conditions, but such distinctions do
+not affect the observable behavior of an application using the
+functions and operators defined in this specification. (See
+<a href="#op.numeric">Arithmetic operators on numeric
+values</a>.)</p>
+          </li>
+          <li>
+            <p>The implementation may adopt a different algorithm provided that
+it is equivalent to this formulation in all cases where <a title="implementation dependent" class="termref" href="#implementation-dependent">
+                <span class="arrow">·</span>implementation-dependent<span class="arrow">·</span>
+              </a> or <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> behavior does not affect the outcome, for
+example, the implementation-defined precision of the result of
+<code>xs:decimal</code> division. (See <a href="#func-numeric-integer-divide">op:numeric-integer-divide</a>.)</p>
+          </li>
+          <li>
+            <p>XSD 1.1 allows the string <code>+INF</code> as a representation
+of positive infinity; XSD 1.0 does not. It is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> whether XSD 1.1 is supported. (See <a href="#func-number">fn:number</a>.)</p>
+          </li>
+          <li>
+            <p>Any other format token, which indicates a numbering sequence in
+which that token represents the number 1 (one) (but see the note
+below). It is <a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
               </a> which numbering sequences, additional to those
-listed in the specification, are supported (in <a href="#func-format-integer">
-                <code>fn:format-integer</code>
-              </a>).</p>
+listed above, are supported. If an implementation does not support
+a numbering sequence represented by the given token, it
+<strong>must</strong> use a format token of <code>1</code>. (See
+<a href="#func-format-integer">fn:format-integer</a>.)</p>
           </li>
           <li>
-            <p>there <strong>may</strong> be <a title="implementation-defined" class="termref" href="#implementation-defined">
+            <p>For all format tokens other than the first kind above (one that
+consists of decimal digits), there <strong>may</strong> be
+<a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
               </a> lower and upper bounds on the range of numbers
-that can be formatted using some numbering sequences (in <a href="#func-format-integer">
-                <code>fn:format-integer</code>
-              </a>).</p>
-          </li>
-          <li>
-            <p>The set of languages for which numbering is supported (in
-<a href="#func-format-integer">
-                <code>fn:format-integer</code>
-              </a>)
-is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
-          </li>
-          <li>
-            <p>The default choice between alphabetical and traditional
-numbering (in <a href="#func-format-integer">
-                <code>fn:format-integer</code>
-              </a>) is
-<a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
+that can be formatted using this format token; indeed, for some
+numbering sequences there may be intrinsic limits. For example, the
+format token <code>&amp;#x2460;</code> (circled digit one, ①) has a
+range <span>imposed by the Unicode character repertoire — 1 to 20
+in Unicode versions prior to 4.0, increased in subsequent
+versions</span>. For the numbering sequences described above any
+upper bound imposed by the implementation <strong>must not</strong>
+be less than 1000 (one thousand) and any lower bound must not be
+greater than 1. Numbers that fall outside this range
+<strong>must</strong> be formatted using the format token
+<code>1</code>. (See <a href="#func-format-integer">fn:format-integer</a>.)</p>
+          </li>
+          <li>
+            <p>The set of languages for which numbering is supported is
+<a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. If the <code>$lang</code> argument is absent,
+or is set to an empty sequence, or is invalid, or is not a language
+supported by the implementation, then the number is formatted using
+<span>the default language from the dynamic context</span>. (See
+<a href="#func-format-integer">fn:format-integer</a>.)</p>
+          </li>
+          <li>
+            <p>...either <code>a</code> or <code>t</code>, to indicate
+alphabetic or traditional numbering respectively, the default being
+<a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#func-format-integer">fn:format-integer</a>.)</p>
           </li>
           <li>
             <p>It is <a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
               </a> what combinations of values of the format
 token, the language, and the cardinal/ordinal modifier are
-supported (in <a href="#func-format-integer">
-                <code>fn:format-integer</code>
-              </a>).</p>
-          </li>
-          <li>
-            <p>There is always a default decimal format available (for use by
-<a href="#func-format-integer">
-                <code>fn:format-integer</code>
-              </a>)
-but its contents are <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
-          </li>
-          <li>
-            <p>IEEE states that the preferred quantum (for trigonometric
-functions) is language-defined. In this specification, it is
-<a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
-          </li>
-          <li>
-            <p>The set of collations that are supported is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
-          </li>
-          <li>
-            <p>Implementations <strong>may</strong> support additional
-normalization forms with <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> semantics.</p>
-          </li>
-          <li>
-            <p>The ability to decompose strings into collation units is an
-<a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> property of a collation.</p>
-          </li>
-          <li>
-            <p>The <a href="#func-resolve-uri">
-                <code>fn:resolve-uri</code>
-              </a>
-function must accept input conforming to the rules of RFC3987,
-extended with an <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> subset of the extensions permitted in
-LEIRI.</p>
-          </li>
-          <li>
-            <p>Processors <a title="may" class="termref" href="#may">
-                <span class="arrow">·</span>may<span class="arrow">·</span>
-              </a> set larger <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> limits on the maximum number of digits they
-support, beyond the minimum of 4 digits for a year and 3 digits for
-fractional seconds.</p>
-          </li>
-          <li>
-            <p>The results of operations on dates that cross the year 0000 are
-<a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
-          </li>
-          <li>
-            <p>If the processor cannot output these components (months, days of
-the week, timezones, and eras) by name for the chosen calendar and
-language then it must use an <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> fallback representation.</p>
-          </li>
-          <li>
-            <p>When formatting fractional seconds, <code>[f1]</code> will
+supported. If ordinal numbering is not supported for the
+combination of the format token, the language, and the string
+appearing in parentheses, the request is ignored and cardinal
+numbers are generated instead. (See <a href="#func-format-integer">fn:format-integer</a>.)</p>
+          </li>
+          <li>
+            <p>The <span>use of the <code>a</code> or <code>t</code>
+modifier</span> disambiguates between numbering sequences that use
+letters. In many languages there are two commonly used numbering
+sequences that use letters. One numbering sequence assigns numeric
+values to letters in alphabetic sequence, and the other assigns
+numeric values to each letter in some other manner traditional in
+that language. In English, these would correspond to the numbering
+sequences specified by the format tokens <code>a</code> and
+<code>i</code>. In some languages, the first member of each
+sequence is the same, and so the format token alone would be
+ambiguous. <span>In the absence of the <code>a</code> or
+<code>t</code> modifier, the default is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                  <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+                </a>
+              </span>. (See <a href="#func-format-integer">fn:format-integer</a>.)</p>
+          </li>
+          <li>
+            <p>The static context provides a set of decimal formats. One of the
+decimal formats is unnamed, the others (if any) are identified by a
+QName. There is always an unnamed decimal format available, but its
+contents are <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#defining-decimal-format">Defining a decimal format</a>.)</p>
+          </li>
+          <li>
+            <p>IEEE states that the preferred quantum is language-defined. In
+this specification, it is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#trigonometry">Trigonometric
+and exponential functions</a>.)</p>
+          </li>
+          <li>
+            <p>IEEE defines various rounding algorithms for inexact results,
+and states that the choice of rounding direction, and the
+mechanisms for influencing this choice, are language-defined. In
+this specification, the rounding direction and any mechanisms for
+influencing it are <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#trigonometry">Trigonometric
+and exponential functions</a>.)</p>
+          </li>
+          <li>
+            <p>Because the set of collations that are supported is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>, an implementation has the option to support
+all collation URIs, in which case it will never raise this error.
+(See <a href="#choosing-a-collation">Choosing a collation</a>.)</p>
+          </li>
+          <li>
+            <p>Conforming implementations <strong>must</strong> support
+normalization form "NFC" and <strong>may</strong> support
+normalization forms "NFD", "NFKC", "NFKD", and "FULLY-NORMALIZED".
+They <strong>may</strong> also support other normalization forms
+with <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> semantics. (See <a href="#func-normalize-unicode">fn:normalize-unicode</a>.)</p>
+          </li>
+          <li>
+            <p>It is possible to define collations that do not have the ability
+to decompose a string into units suitable for substring matching.
+An argument to a function defined in this section may be a URI that
+identifies a collation that is able to compare two strings, but
+that does not have the capability to split the string into
+collation units. Such a collation may cause the function to fail,
+or to give unexpected results or it may be rejected as an
+unsuitable argument. The ability to decompose strings into
+collation units is an <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> property of the collation. (See <a href="#substring.functions">Functions based on substring
+matching</a>.)</p>
+          </li>
+          <li>
+            <p>All <em>minimally conforming</em> processors <a title="must" class="termref" href="#must">
+                <span class="arrow">·</span>must<span class="arrow">·</span>
+              </a> support
+positive year values with a minimum of 4 digits (i.e., YYYY) and a
+minimum fractional second precision of 1 millisecond or three
+digits (i.e., s.sss). However, <em>conforming</em> processors
+<a title="may" class="termref" href="#may">
+                <span class="arrow">·</span>may<span class="arrow">·</span>
+              </a> set larger
+<a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> limits on the maximum number of digits they
+support in these two situations. Processors <a title="may" class="termref" href="#may">
+                <span class="arrow">·</span>may<span class="arrow">·</span>
+              </a> also choose to support the year 0000 and years
+with negative values. The results of operations on dates that cross
+the year 0000 are <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#date-time-duration-conformance">Limits and precision</a>.)</p>
+          </li>
+          <li>
+            <p>All <em>minimally conforming</em> processors <a title="must" class="termref" href="#must">
+                <span class="arrow">·</span>must<span class="arrow">·</span>
+              </a> support
+positive year values with a minimum of 4 digits (i.e., YYYY) and a
+minimum fractional second precision of 1 millisecond or three
+digits (i.e., s.sss). However, <em>conforming</em> processors
+<a title="may" class="termref" href="#may">
+                <span class="arrow">·</span>may<span class="arrow">·</span>
+              </a> set larger
+<a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> limits on the maximum number of digits they
+support in these two situations. Processors <a title="may" class="termref" href="#may">
+                <span class="arrow">·</span>may<span class="arrow">·</span>
+              </a> also choose to support the year 0000 and years
+with negative values. The results of operations on dates that cross
+the year 0000 are <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#date-time-duration-conformance">Limits and precision</a>.)</p>
+          </li>
+          <li>
+            <p>...the format token <code>n</code>, <code>N</code>, or
+<code>Nn</code>, indicating that the value of the component is to
+be output by name, in lower-case, upper-case, or title-case
+respectively. Components that can be output by name include (but
+are not limited to) months, days of the week, timezones, and eras.
+If the processor cannot output these components by name for the
+chosen calendar and language then it must use an <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> fallback representation. (See <a href="#date-picture-string">The picture string</a>.)</p>
+          </li>
+          <li>
+            <p>...indicates alphabetic or traditional numbering respectively,
+the default being <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. This has the same meaning as in the second
+argument of <a href="#func-format-integer">
+                <code>fn:format-integer</code>
+              </a>. (See
+<a href="#date-picture-string">The picture string</a>.)</p>
+          </li>
+          <li>
+            <p>A format token consisting of a single digit, such as
+<code>1</code>, does not constrain the number of digits in the
+output. In the case of fractional seconds in particular,
+<code>[f001]</code> requests three decimal digits,
+<code>[f01]</code> requests two digits, but <code>[f1]</code> will
 produce an <a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> number of digits</p>
-          </li>
-          <li>
-            <p>The set of languages, calendars, and <span>places</span> that
-are supported in the <a title="date formatting function" class="termref" href="#dt-date-formatting-function">
-                <span class="arrow">·</span>date formatting functions<span class="arrow">·</span>
-              </a> is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>. When any of these arguments is omitted or is
-an empty sequence, an <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> default value is used.</p>
-          </li>
-          <li>
-            <p>The choice of the names and abbreviations used in any given
-language (for example, the names of days and months) is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
-          </li>
-          <li>
-            <p>implementations may provide a user option to evaluate functions
-such as <a href="#func-doc">
-                <code>fn:doc</code>
-              </a> and <a href="#func-collection">
-                <code>fn:collection</code>
-              </a> without a
-guarantee of determinism. The manner in which any such option is
-provided is implementation-defined.</p>
-          </li>
-          <li>
-            <p>Various aspects of the processing performed by the <a href="#func-doc">
-                <code>fn:doc</code>
-              </a> function are <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
-          </li>
-          <li>
-            <p>The processor <strong>may</strong> use <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> heuristics to determine the likely encoding of
-a file read using the <a href="#func-unparsed-text">
-                <code>fn:unparsed-text</code>
-              </a>
-function</p>
-          </li>
-          <li>
-            <p>The collation used for matching names of environment variables
-is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>
-            </p>
-          </li>
-          <li>
-            <p>The precise process used by <a href="#func-parse-xml">
-                <code>fn:parse-xml</code>
-              </a>to construct the XDM
-instance is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
-          </li>
-          <li>
-            <p>If there is no matching function in the static context, then the
-results pf the <a href="#func-function-lookup">
-                <code>fn:function-lookup</code>
-              </a>
-function depend on what is present in the dynamic context, which is
+              </a> number of digits. If exactly one digit is
+required, this can be achieved using the component specifier
+<code>[f1,1-1]</code>. (See <a href="#date-picture-string">The
+picture string</a>.)</p>
+          </li>
+          <li>
+            <p>The set of languages, calendars, and <span>places</span> that
+are supported in the <a title="date formatting function" class="termref" href="#dt-date-formatting-function">
+                <span class="arrow">·</span>date formatting functions<span class="arrow">·</span>
+              </a> is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. When any of these arguments is omitted or is
+an empty sequence, an <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> default value is used. (See <a href="#lang-cal-place">The language, calendar, and place
+arguments</a>.)</p>
+          </li>
+          <li>
+            <p>The set of languages, calendars, and <span>places</span> that
+are supported in the <a title="date formatting function" class="termref" href="#dt-date-formatting-function">
+                <span class="arrow">·</span>date formatting functions<span class="arrow">·</span>
+              </a> is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. When any of these arguments is omitted or is
+an empty sequence, an <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> default value is used. (See <a href="#lang-cal-place">The language, calendar, and place
+arguments</a>.)</p>
+          </li>
+          <li>
+            <p>The choice of the names and abbreviations used in any given
+language is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. For example, one implementation might
+abbreviate July as <code>Jul</code> while another uses
+<code>Jly</code>. In German, one implementation might represent
+Saturday as <code>Samstag</code> while another uses
+<code>Sonnabend</code>. Implementations <strong>may</strong>
+provide mechanisms allowing users to control such choices. (See
+<a href="#lang-cal-place">The language, calendar, and place
+arguments</a>.)</p>
+          </li>
+          <li>
+            <p>The choice of the names and abbreviations used in any given
+language for calendar units such as days of the week and months of
+the year is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#lang-cal-place">The language,
+calendar, and place arguments</a>.)</p>
+          </li>
+          <li>
+            <p>The calendar value if present <strong>must</strong> be a valid
+<span>
+                <code>EQName</code> (<span>dynamic</span> error: [<a href="#ERRFOFD1340" title="err:FOFD1340">err:FOFD1340</a>])</span>. If
+it is a lexical <code>QName</code> then it is expanded into an
+expanded QName using the <span>statically known namespaces</span>;
+if it has no prefix then it represents an expanded-QName in no
+namespace. If the expanded QName is in no namespace, then it
+<strong>must</strong> identify a calendar with a designator
+specified below (<span>dynamic error: [<a href="#ERRFOFD1340" title="err:FOFD1340">err:FOFD1340</a>])</span>. If the expanded
+QName is in a namespace then it identifies the calendar in an
 <a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>.</p>
-          </li>
-          <li>
-            <p>When casting to <code>xs:decimal</code>, the choice of rounding
-algorithm and the choice between rounding and error behavior and is
-implementation-defined.</p>
+              </a> way. (See <a href="#lang-cal-place">The
+language, calendar, and place arguments</a>.)</p>
+          </li>
+          <li>
+            <p>At least one of the above calendars <strong>must</strong> be
+supported. It is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> which calendars are supported. (See <a href="#lang-cal-place">The language, calendar, and place
+arguments</a>.)</p>
+          </li>
+          <li>
+            <p>Various aspects of this processing are <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. Implementations may provide external
+configuration options that allow any aspect of the processing to be
+controlled by the user. In particular:... (See <a href="#func-doc">fn:doc</a>.)</p>
           </li>
           <li>
             <p>It is <a title="implementation-defined" class="termref" href="#implementation-defined">
                 <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> which version of the Olson timezone database
-is used.</p>
-          </li>
-          <li>
-            <p>For <code>xs:integer</code> operations, implementations that
-support limited-precision integer operations <a title="must" class="termref" href="#must">
-                <span class="arrow">·</span>must<span class="arrow">·</span>
-              </a> either raise an error [<a href="#ERRFOAR0002" title="err:FOAR0002">err:FOAR0002</a>] or provide an <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> mechanism that allows users to choose between
-raising an error and returning a result that is modulo the largest
-representable integer value. See <a href="#op.numeric">
-                <b>4.2
-Arithmetic operators on numeric values</b>
-              </a>.</p>
-          </li>
-          <li>
-            <p>For <code>xs:decimal</code> values the number of digits of
-precision returned by the numeric operators is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>. See <a href="#op.numeric">
-                <b>4.2 Arithmetic
-operators on numeric values</b>
-              </a>. See also <a href="#casting-to-decimal">
-                <b>18.1.2.3 Casting to xs:decimal</b>
-              </a> and
-<a href="#casting-to-integer">
-                <b>18.1.2.4 Casting to
-xs:integer</b>
-              </a>
-            </p>
-          </li>
-          <li>
-            <p>If the number of digits in the result of a numeric operation
-exceeds the number of digits that the implementation supports, the
-result is truncated or rounded in an <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a> manner. See <a href="#op.numeric">
-                <b>4.2
-Arithmetic operators on numeric values</b>
-              </a>. See also <a href="#casting-to-decimal">
-                <b>18.1.2.3 Casting to xs:decimal</b>
-              </a> and
-<a href="#casting-to-integer">
-                <b>18.1.2.4 Casting to
-xs:integer</b>
-              </a>
-            </p>
-          </li>
-          <li>
-            <p>The destination of the trace output is <a title="implementation-defined" class="termref" href="#implementation-defined">
-                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
-              </a>. See <a href="#func-trace">
-                <b>3.2.1
-fn:trace</b>
-              </a>.</p>
+              </a> whether DTD validation and/or schema
+validation is applied to the source document. (See <a href="#func-doc">fn:doc</a>.)</p>
+          </li>
+          <li>
+            <p>By default, this function is <a title="" class="termref" href="#">
+                <span class="arrow">·</span>deterministic<span class="arrow">·</span>
+              </a>. This means that repeated calls on the
+function with the same argument will return the same result.
+However, for performance reasons, implementations may provide a
+user option to evaluate the function without a guarantee of
+determinism. The manner in which any such option is provided is
+<a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. If the user has not selected such an option,
+a call to this function must either return a deterministic result
+or must raise a <span>dynamic</span> error [<a href="#ERRFODC0003" title="err:FODC0003">err:FODC0003</a>]. (See <a href="#func-collection">fn:collection</a>.)</p>
+          </li>
+          <li>
+            <p>...the processor <strong>may</strong> use <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> heuristics to determine the likely encoding,
+otherwise... (See <a href="#func-unparsed-text">fn:unparsed-text</a>.)</p>
+          </li>
+          <li>
+            <p>The fact that the resolution of URIs is defined by a mapping in
+the dynamic context means that in effect, various aspects of the
+behavior of this function are <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. Implementations may provide external
+configuration options that allow any aspect of the processing to be
+controlled by the user. In particular:... (See <a href="#func-unparsed-text">fn:unparsed-text</a>.)</p>
+          </li>
+          <li>
+            <p>The collation used for matching names is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>, but must be the same as the collation used to
+ensure that the names of all environment variables are unique. (See
+<a href="#func-environment-variable">fn:environment-variable</a>.)</p>
+          </li>
+          <li>
+            <p>The precise process used to construct the XDM instance is
+<a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. In particular, it is implementation-defined
+whether DTD and/or schema validation is invoked, and it is
+implementation-defined whether an XML 1.0 or XML 1.1 parser is
+used. (See <a href="#func-parse-xml">fn:parse-xml</a>.)</p>
+          </li>
+          <li>
+            <p>The precise process used to construct the XDM instance is
+<a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. In particular, it is implementation-defined
+whether an XML 1.0 or XML 1.1 parser is used. (See <a href="#func-parse-xml-fragment">fn:parse-xml-fragment</a>.)</p>
+          </li>
+          <li>
+            <p>If the arguments to <code>fn:function-lookup</code> identify a
+function that is present in the static context of the function
+call, the function will always return the same function that a
+static reference to this function would bind to. If there is no
+such function in the static context, then the results depend on
+what is present in the dynamic context, which is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#func-function-lookup">fn:function-lookup</a>.)</p>
+          </li>
+          <li>
+            <p>If <em>ST</em> is <code>xs:float</code> or
+<code>xs:double</code>, then <em>TV</em> is the
+<code>xs:decimal</code> value, within the set of
+<code>xs:decimal</code> values that the implementation is capable
+of representing, that is numerically closest to <em>SV</em>. If two
+values are equally close, then the one that is closest to zero is
+chosen. If <em>SV</em> is too large to be accommodated as an
+<code>xs:decimal</code>, (see <a href="#xmlschema-2">[XML Schema
+Part 2: Datatypes Second Edition]</a> for <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> limits on numeric values) a
+<span>dynamic</span> error is raised [<a href="#ERRFOCA0001" title="err:FOCA0001">err:FOCA0001</a>]. If <em>SV</em> is one of the
+special <code>xs:float</code> or <code>xs:double</code> values
+<code>NaN</code>, <code>INF</code>, or <code>-INF</code>, a
+<span>dynamic</span> error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>]. (See <a href="#casting-to-decimal">Casting to xs:decimal</a>.)</p>
+          </li>
+          <li>
+            <p>If <em>ST</em> is <code>xs:decimal</code>, <code>xs:float</code>
+or <code>xs:double</code>, then <em>TV</em> is <em>SV</em> with the
+fractional part discarded and the value converted to
+<code>xs:integer</code>. Thus, casting <code>3.1456</code> returns
+<code>3</code> and <code>-17.89</code> returns <code>-17</code>.
+Casting <code>3.124E1</code> returns <code>31</code>. If
+<em>SV</em> is too large to be accommodated as an integer, (see
+<a href="#xmlschema-2">[XML Schema Part 2: Datatypes Second
+Edition]</a> for <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> limits on numeric values) a
+<span>dynamic</span> error is raised [<a href="#ERRFOCA0003" title="err:FOCA0003">err:FOCA0003</a>]. If <em>SV</em> is one of the
+special <code>xs:float</code> or <code>xs:double</code> values
+<code>NaN</code>, <code>INF</code>, or <code>-INF</code>, a
+<span>dynamic</span> error is raised [<a href="#ERRFOCA0002" title="err:FOCA0002">err:FOCA0002</a>]. (See <a href="#casting-to-integer">Casting to xs:integer</a>.)</p>
+          </li>
+          <li>
+            <p>In casting to <code>xs:decimal</code> or to a type derived from
+<code>xs:decimal</code>, if the value is not too large or too small
+but nevertheless cannot be represented accurately with the number
+of decimal digits available to the implementation, the
+implementation may round to the nearest representable value or may
+raise a dynamic error [<a href="#ERRFOCA0006" title="err:FOCA0006">err:FOCA0006</a>]. The choice of rounding algorithm
+and the choice between rounding and error behavior and is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#casting-from-strings">Casting
+from xs:string and xs:untypedAtomic</a>.)</p>
+          </li>
+          <li>
+            <p>The <em>tz</em> timezone database, available at <a href="http://www.twinsun.com/tz/tz-link.htm";>http://www.twinsun.com/tz/tz-link.htm</a>.
+It is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a> which version of the database is used. (See
+<a href="#olson">Olson Timezone Database</a>.)</p>
+          </li>
+          <li>
+            <p>The Unicode Consortium, Reading, MA, Addison-Wesley, 2003.
+<em>The Unicode Standard</em> as updated from time to time by the
+publication of new versions. See <a href="http://www.unicode.org/standard/versions/";>http://www.unicode.org/standard/versions/</a>
+for the latest version and additional information on versions of
+the standard and of the Unicode Character Database. The version of
+Unicode to be used is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>, but implementations are recommended to use
+the latest Unicode version; currently, Version 6.0.0. (See <a href="#Unicode">The Unicode Standard</a>.)</p>
+          </li>
+          <li>
+            <p>Unicode Standard Annex #15, Unicode Normalization Forms.
+Available at: <a href="http://www.unicode.org/reports/tr15/";>http://www.unicode.org/reports/tr15/</a>.
+As with <a href="#Unicode">[The Unicode Standard]</a>, the version
+to be used is <a title="implementation-defined" class="termref" href="#implementation-defined">
+                <span class="arrow">·</span>implementation-defined<span class="arrow">·</span>
+              </a>. (See <a href="#Unicode-Normalization">Unicode
+Normalization Forms</a>.)</p>
           </li>
         </ol>
       </div>
       <div class="div1">
         <h2>
-          <a name="changelog" id="changelog"/>F Changes since previous
+          <a name="changelog" id="changelog"/>E Changes since previous
 Recommendation (Non-Normative)</h2>
         <div class="div2">
           <h3>
-            <a name="substantive-changes-2009-12-15" id="substantive-changes-2009-12-15"/>F.1 Substantive changes (15
+            <a name="substantive-changes-2009-12-15" id="substantive-changes-2009-12-15"/>E.1 Substantive changes (15
 December 2009)</h3>
           <p>In the Working Draft of 15 December 2009, the following changes
 were made relative to the first edition of the Functions and
@@ -35320,11 +35905,22 @@
             <li>
               <p>Supporting the new language feature of higher-order functions, a
 number of functions were defined that operate on function items as
-their arguments. (The function <code>fn:partial-apply</code>,
-however, which was introduced in the previous version of this
-Working Draft, has now been dropped in favor of custom syntax for
-partial application using "?" as a place-holder for missing
-arguments.)</p>
+their arguments: <code>fn:map</code> (subsequently renamed <a href="#func-for-each">
+                  <code>fn:for-each</code>
+                </a>), <a href="#func-filter">
+                  <code>fn:filter</code>
+                </a>,
+<code>fn:map-pairs</code> (subsequently renamed <a href="#func-for-each-pair">
+                  <code>fn:for-each-pair</code>
+                </a>, <a href="#func-fold-left">
+                  <code>fn:fold-left</code>
+                </a>, <a href="#func-fold-right">
+                  <code>fn:fold-right</code>
+                </a>. The function
+<code>fn:partial-apply</code>, however, which was introduced in the
+previous version of this Working Draft, has now been dropped in
+favor of custom syntax for partial application using "?" as a
+place-holder for missing arguments.</p>
             </li>
             <li>
               <p>The description of the <a href="#func-error">
@@ -35342,31 +35938,17 @@
         </div>
         <div class="div2">
           <h3>
-            <a name="substantive-changes-current-draft" id="substantive-changes-current-draft"/>F.2 Substantive changes
-(current draft)</h3>
-          <p>In this Working Draft, the following substantive changes are
-made relative to the draft of 15 December 2009:</p>
+            <a name="substantive-changes-2012-06-18" id="substantive-changes-2012-06-18"/>E.2 Substantive changes (18
+June 2012)</h3>
+          <p>In the Last Call Working Draft of 18 June 2012, the following
+substantive changes are made relative to the draft of 15 December
+2009:</p>
           <ol class="enumar">
             <li>
               <p>The version number of the specification is changed from 1.1 to
 3.0.</p>
             </li>
             <li>
-              <p>New functions <a href="#func-filter">
-                  <code>fn:filter</code>
-                </a>,
-<a href="#func-map">
-                  <code>fn:map</code>
-                </a>, <a href="#func-map-pairs">
-                  <code>fn:map-pairs</code>
-                </a>, <a href="#func-fold-left">
-                  <code>fn:fold-left</code>
-                </a>, and <a href="#func-fold-right">
-                  <code>fn:fold-right</code>
-                </a> are
-introduced.</p>
-            </li>
-            <li>
               <p>New functions <a href="#func-math-exp">
                   <code>math:exp</code>
                 </a>, <a href="#func-math-exp10">
@@ -35423,7 +36005,26 @@
               <p>The function <code>fn:partial-apply</code> has been removed, as
 this functionality is now provided by custom syntax (partial
 function application, using "?" as a placeholder for missing
-arguments)</p>
+arguments).</p>
+            </li>
+            <li>
+              <p>New functions <a href="#func-function-name">
+                  <code>fn:function-name</code>
+                </a>, <a href="#func-function-arity">
+                  <code>fn:function-arity</code>
+                </a>, and
+<a href="#func-function-lookup">
+                  <code>fn:function-lookup</code>
+                </a>
+are available.</p>
+            </li>
+            <li>
+              <p>A new function <a href="#func-parse-xml-fragment">
+                  <code>fn:parse-xml-fragment</code>
+                </a>
+was introduced. (This change went unremarked in the change log up
+to and including the Candidate Recommendation of 8 January
+2013.)</p>
             </li>
             <li>
               <p>Casting from a dynamic string to an <code>xs:QName</code> or a
@@ -35439,8 +36040,15 @@
                   <code>fn:document-uri</code>
                 </a>, and <a href="#func-node-name">
                   <code>fn:node-name</code>
-                </a>, with the argument
-defaulting to the context item in each case. (Bug 9571)</p>
+                </a>, <a href="#func-base-uri">
+                  <code>fn:base-uri</code>
+                </a>, <a href="#func-nilled">
+                  <code>fn:nilled</code>
+                </a>, and <a href="#func-has-children">
+                  <code>fn:has-children</code>
+                </a>, with the
+argument defaulting to the context item in each case. (Bug
+9571)</p>
             </li>
             <li>
               <p>The new function <code>fn:parse</code> is renamed <a href="#func-parse-xml">
@@ -35498,24 +36106,8 @@
 have been defined.</p>
             </li>
             <li>
-              <p>A new function <a href="#func-uri-collection">
-                  <code>fn:uri-collection</code>
-                </a> is
-added.</p>
-            </li>
-            <li>
-              <p>Zero-argument versions of the <a href="#func-base-uri">
-                  <code>fn:base-uri</code>
-                </a>, <a href="#func-data">
-                  <code>fn:data</code>
-                </a>, and <a href="#func-document-uri">
-                  <code>fn:document-uri</code>
-                </a> functions are
-added.</p>
-            </li>
-            <li>
               <p>Casting from a string or <code>xs:untypedAtomic</code> value to
-a union type is now allowed.</p>
+a union or list type is now allowed.</p>
             </li>
             <li>
               <p>References to the Formal Semantics have been removed.</p>
@@ -35557,43 +36149,197 @@
                 </a> have been
 clarified, possibly involving incompatible changes.</p>
             </li>
+            <li>
+              <p>In regular expressions (without the "m" option) the
+meta-character "." now matches everything except x0A and x0D.
+Previously it was defined to match everything except x0A, which was
+an unnecessary and unintended incompatibility with regular
+expressions in XSD.</p>
+            </li>
           </ol>
         </div>
         <div class="div2">
           <h3>
-            <a name="incompatibilities" id="incompatibilities"/>F.3
-Incompatibilities</h3>
-          <p>The following is a list of known incompatibilities between this
-draft and the first edition of the Functions and Operators
-specification for XPath 2.0 and XQuery 1.0 published on 23 January
-2007 (that is, differences in observable behaviour that may mean
-existing applications using these functions need to be changed to
-continue functioning correctly)</p>
+            <a name="substantive-changes-2013-01-08" id="substantive-changes-2013-01-08"/>E.3 Substantive changes
+(Candidate Recommendation)</h3>
+          <p>In this Candidate Recommendation, the following substantive
+changes are made relative to the Last Call Working Draft draft of
+18 June 2012:</p>
           <ol class="enumar">
             <li>
-              <p>The handling of timezones by <a href="#func-format-dateTime">
-                  <code>fn:format-dateTime</code>
+              <p>Functions with dependencies on the static or dynamic context can
+now be bound to function items (for example, by the use of <a href="#func-function-lookup">
+                  <code>fn:function-lookup</code>
+                </a>), and
+the rules for doing so have been clarified.</p>
+            </li>
+            <li>
+              <p>The specification of <a href="#func-format-integer">
+                  <code>fn:format-integer</code>
+                </a> makes a
+more precise distinction between situations where the processor
+must report an error in the supplied picture, and situations where
+it must adopt a fallback representation.</p>
+            </li>
+            <li>
+              <p>The conditions under which the static base URI used during
+static analysis can differ from the base URI used during evaluation
+are now more clearly and consistently described. The concept of
+dynamic base URI is dropped.</p>
+            </li>
+            <li>
+              <p>The syntax for regular expressions is now described by reference
+to the XSD 1.1 specification as well as the XSD 1.0 specification.
+(XSD 1.1 gives a much clearer exposition of the syntax and
+semantics of regular expressions without introducing any intended
+changes to the functionality.)</p>
+            </li>
+            <li>
+              <p>Some edge cases for capturing subgroups in regular expressions
+are described.</p>
+            </li>
+            <li>
+              <p>The role of the schema for the data returned by <a href="#func-analyze-string">
+                  <code>fn:analyze-string</code>
                 </a> is more
-prescriptive than in the previous specification (in this case, the
-XSLT 2.0 specification). The output of the function may be
-different, depending on the interpretation adopted by
-implementations of the previous specification.</p>
-            </li>
-            <li>
-              <p>For functions such as <a href="#func-format-dateTime">
-                  <code>fn:format-dateTime</code>
-                </a> and
-<a href="#func-unparsed-text">
+clearly defined.</p>
+            </li>
+            <li>
+              <p>In the result of <a href="#func-path">
+                  <code>fn:path</code>
+                </a>,
+dependencies on the default namespace for functions have been
+removed, by ensuring that any function calls in the return path use
+fully-qualified names.</p>
+            </li>
+            <li>
+              <p>In the specification of <a href="#func-deep-equal">
+                  <code>fn:deep-equal</code>
+                </a>, the consequences
+of the existing rules for comparing validated against unvalidated
+trees are more carefully explained.</p>
+            </li>
+            <li>
+              <p>The rules for the <a href="#func-unparsed-text">
                   <code>fn:unparsed-text</code>
-                </a>
-transferred from the XSLT 2.0 specification, error codes have been
-changed to start with "FO" rather than "XT".</p>
-            </li>
-          </ol>
-        </div>
-        <div class="div2">
-          <h3>
-            <a name="editorial-changes" id="editorial-changes"/>F.4
+                </a> function
+have been expressed at a higher level of abstraction, using the
+context in the same way as the <a href="#func-doc">
+                  <code>fn:doc</code>
+                </a> function, and making use of
+concepts such as the distinction in web architecture between a
+resource and its representation.</p>
+            </li>
+            <li>
+              <p>A number of rules have been added, which were previously
+omitted, concerning casts and constructors where the target type is
+a union or list type.</p>
+            </li>
+          </ol>
+        </div>
+        <div class="div2">
+          <h3>
+            <a name="substantive-changes-current-draft" id="substantive-changes-current-draft"/>E.4 Substantive changes
+(post Candidate Recommendation)</h3>
+          <p>The following changes are made subsequent to the Candidate
+Recommendation of 8 January 2013:</p>
+          <ol class="enumar">
+            <li>
+              <p>The functions <code>fn:map</code> and <code>fn:map-pairs</code>
+are renamed <a href="#func-for-each">
+                  <code>fn:for-each</code>
+                </a>
+and <a href="#func-for-each-pair">
+                  <code>fn:for-each-pair</code>
+                </a>
+respectively. This change is made to remove the risk of potential
+confusion and syntactic conflicts if and when a map data type is
+added to the language, as proposed in the current XSLT 3.0 Working
+Draft. (Bug 21128).</p>
+            </li>
+            <li>
+              <p>The arguments of the functions <a href="#func-for-each">
+                  <code>fn:for-each</code>
+                </a> and <a href="#func-for-each-pair">
+                  <code>fn:for-each-pair</code>
+                </a>, <a href="#func-filter">
+                  <code>fn:filter</code>
+                </a>, <a href="#func-fold-left">
+                  <code>fn:fold-left</code>
+                </a>, and <a href="#func-fold-right">
+                  <code>fn:fold-right</code>
+                </a> are re-ordered.
+This change has been made in the interests of usability and
+consistency with other functions. (Bug 21797).</p>
+            </li>
+            <li>
+              <p>The regular expression matching the format modifier in the
+picture string supplied to <a href="#func-format-integer">
+                  <code>fn:format-integer</code>
+                </a> has been
+corrected to match the accompanying prose. (Bug 19004).</p>
+            </li>
+            <li>
+              <p>The function signature for the <code>xs:QName</code> constructor
+function has been corrected to show that the supplied value may be
+an empty sequence (the error arose because in XPath 2.0, this
+constructor was a special case, requiring that the supplied
+argument be an string literal). (Bug 20856)</p>
+            </li>
+            <li>
+              <p>The function signature for the <a href="#func-adjust-dateTime-to-timezone">
+                  <code>fn:adjust-dateTime-to-timezone</code>
+                </a>
+function has been corrected to show that the returned value may be
+an empty sequence, making the signature consistent with the prose
+description and with the XPath 2.0/XQuery 1.0 version of the
+specification. (Bug 20850)</p>
+            </li>
+            <li>
+              <p>The <code>$calendar</code> argument of functions in the <a href="#func-format-date">
+                  <code>fn:format-date</code>
+                </a> family may now
+be an <code>EQName</code> for consistency, and the error conditions
+for the arguments to these functions are more clearly spelled out.
+(Bug 21284).</p>
+            </li>
+            <li>
+              <p>A section has been added to describe the constructor function
+<code>xs:error</code> present in implementations that support XSD
+1.1. The existence of such a function is a consequence of general
+rules included in the published Candidate Recommendation, but the
+function was not listed along with other constructor functions for
+built-in XSD types. (Bug 20634).</p>
+            </li>
+            <li>
+              <p>A paragraph has been added explaining how to interpret the
+week-in-month (<code>w</code>) component for the <a href="#func-format-date">
+                  <code>fn:format-date</code>
+                </a> family of
+functions in the case where the chosen calendar is the ISO
+calendar. (Bug 21370).</p>
+            </li>
+            <li>
+              <p>It is now stated that it is an error in a regular expression to
+use a Unicode block name which is not defined in the version(s) of
+Unicode supported by the processor. This differs from the treatment
+of this condition in XSD 1.1. (Bug 20575).</p>
+            </li>
+            <li>
+              <p>Error conditions are now properly categorized as type errors or
+dynamic errors, and in particular where the error condition
+<code>XPDY0002</code> was previously categorized as a type error
+this has been corrected. (Bug 21315).</p>
+            </li>
+            <li>
+              <p>It is now stated that failure to cast to a union type is always
+a dynamic error, not a type error. (Bug 21766)</p>
+            </li>
+          </ol>
+        </div>
+        <div class="div2">
+          <h3>
+            <a name="editorial-changes" id="editorial-changes"/>E.5
 Editorial changes</h3>
           <p>The following editorial changes have been made since the first
 edition of the Functions and Operators specification for XPath 2.0
@@ -35609,7 +36355,10 @@
             </li>
             <li>
               <p>A quick reference section containing links to the functions has
-been added before the full table of contents.</p>
+been added before the full table of contents. The end-of-document
+indexes have been dropped in this draft (any readers disappointed
+by this decision are invited to make representations to the editor,
+since they can easily be re-instated).</p>
             </li>
             <li>
               <p>The section on constructor functions has been moved so that it
@@ -35669,9 +36418,7 @@
               <p>A seperate section for each function now lists the properties of
 the function: whether or not it is deterministic,
 context-dependent, or focus-dependent. These properties are linked
-to their definitions, which also explain the implications: for
-example, a focus-dependent function cannot be used as the basis of
-a function literal for use with higher-order functions.</p>
+to their definitions.</p>
             </li>
             <li>
               <p>Rules have been rewritten in a more consistent style: "If
@@ -35746,5426 +36493,241 @@
 revised, and new functions are supplied to illustrate use cases for
 higher-order functions.</p>
             </li>
+            <li>
+              <p>The appendix describing error codes gives more information.</p>
+            </li>
+            <li>
+              <p>The checklist of implementation-defined features is now
+automatically aligned with the text.</p>
+            </li>
           </ol>
         </div>
       </div>
       <div class="div1">
         <h2>
-          <a name="quickref" id="quickref"/>G Function and Operator
-Quick Reference (Non-Normative)</h2>
+          <a name="back-compatibility" id="back-compatibility"/>F
+Compatibility with Previous Versions (Non-Normative)</h2>
+        <p>This section summarizes the extent to which this specification
+is compatible with previous versions.</p>
+        <p>It describes first the incompatibilities between XPath 1.0 and
+XPath 2.0 (or XQuery 1.0), then the incompatibilities between XPath
+2.0 (or XQuery 1.0) and XPath/XQuery 3.0.</p>
         <div class="div2">
           <h3>
-            <a name="quickref-section" id="quickref-section"/>G.1
-Functions and Operators by Section</h3>
-          <dl>
-            <dt class="label">2 Accessors</dt>
-            <dd>
-              <dl>
-                <dt class="label">2.1 fn:node-name</dt>
-                <dt class="label">2.2 fn:nilled</dt>
-                <dt class="label">2.3 fn:string</dt>
-                <dt class="label">2.4 fn:data</dt>
-                <dt class="label">2.5 fn:base-uri</dt>
-                <dt class="label">2.6 fn:document-uri</dt>
-              </dl>
-            </dd>
-            <dt class="label">3 Errors and diagnostics</dt>
-            <dd>
-              <dl>
-                <dt class="label">3.1 Raising errors</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-error">
-                      <code>fn:error</code>
-                    </a>()<code> as </code>
-                    <code>none</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-error">
-                      <code>fn:error</code>
-                    </a>(<code>$code</code>
-                    <code> as </code>
-                    <code>xs:QName</code>)<code> as </code>
-                    <code>none</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-error">
-                      <code>fn:error</code>
-                    </a>(<code>$code</code>
-                    <code> as </code>
-                    <code>xs:QName?</code>,
-<code>$description</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>none</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-error">
-                      <code>fn:error</code>
-                    </a>(<code>$code</code>
-                    <code> as </code>
-                    <code>xs:QName?</code>,
-<code>$description</code>
-                    <code> as </code>
-                    <code>xs:string</code>,
-<code>$error-object</code>
-                    <code> as </code>
-                    <code>item()*</code>)<code> as </code>
-                    <code>none</code>
-                  </div>
-                </dd>
-                <dt class="label">3.2 Diagnostic tracing</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-trace">
-                      <code>fn:trace</code>
-                    </a>(<code>$value</code>
-                    <code> as </code>
-                    <code>item()*</code>,
-<code>$label</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>item()*</code>
-                  </div>
-                </dd>
-              </dl>
-            </dd>
-            <dt class="label">4 Functions and operators on numerics</dt>
-            <dd>
-              <dl>
-                <dt class="label">4.2 Arithmetic operators on numeric values</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-numeric-add">
-                      <code>op:numeric-add</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>numeric</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>numeric</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-numeric-subtract">
-                      <code>op:numeric-subtract</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>numeric</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>numeric</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-numeric-multiply">
-                      <code>op:numeric-multiply</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>numeric</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>numeric</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-numeric-divide">
-                      <code>op:numeric-divide</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>numeric</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>numeric</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-numeric-integer-divide">
-                      <code>op:numeric-integer-divide</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>numeric</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>xs:integer</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-numeric-mod">
-                      <code>op:numeric-mod</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>numeric</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>numeric</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-numeric-unary-plus">
-                      <code>op:numeric-unary-plus</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>numeric</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-numeric-unary-minus">
-                      <code>op:numeric-unary-minus</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>numeric</code>
-                  </div>
-                </dd>
-                <dt class="label">4.3 Comparison operators on numeric values</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-numeric-equal">
-                      <code>op:numeric-equal</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>numeric</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>xs:boolean</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-numeric-less-than">
-                      <code>op:numeric-less-than</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>numeric</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>xs:boolean</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-numeric-greater-than">
-                      <code>op:numeric-greater-than</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>numeric</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>xs:boolean</code>
-                  </div>
-                </dd>
-                <dt class="label">4.4 Functions on numeric values</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-abs">
-                      <code>fn:abs</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>numeric?</code>)<code> as </code>
-                    <code>numeric?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-ceiling">
-                      <code>fn:ceiling</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>numeric?</code>)<code> as </code>
-                    <code>numeric?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-floor">
-                      <code>fn:floor</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>numeric?</code>)<code> as </code>
-                    <code>numeric?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-round">
-                      <code>fn:round</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>numeric?</code>)<code> as </code>
-                    <code>numeric?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-round">
-                      <code>fn:round</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>numeric?</code>,
-<code>$precision</code>
-                    <code> as </code>
-                    <code>xs:integer</code>)<code> as </code>
-                    <code>numeric?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-round-half-to-even">
-                      <code>fn:round-half-to-even</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>numeric?</code>)<code> as </code>
-                    <code>numeric?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-round-half-to-even">
-                      <code>fn:round-half-to-even</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>numeric?</code>,
-<code>$precision</code>
-                    <code> as </code>
-                    <code>xs:integer</code>)<code> as </code>
-                    <code>numeric?</code>
-                  </div>
-                </dd>
-                <dt class="label">4.5 Parsing numbers</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-number">
-                      <code>fn:number</code>
-                    </a>()<code> as </code>
-                    <code>xs:double</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-number">
-                      <code>fn:number</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:anyAtomicType?</code>)<code> as </code>
-                    <code>xs:double</code>
-                  </div>
-                </dd>
-                <dt class="label">4.6 Formatting integers</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-format-integer">
-                      <code>fn:format-integer</code>
-                    </a>(<code>$value</code>
-                    <code> as </code>
-                    <code>xs:integer?</code>,
-<code>$picture</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-format-integer">
-                      <code>fn:format-integer</code>
-                    </a>(<code>$value</code>
-                    <code> as </code>
-                    <code>xs:integer?</code>,
-<code>$picture</code>
-                    <code> as </code>
-                    <code>xs:string</code>,
-<code>$language</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                </dd>
-                <dt class="label">4.7 Formatting numbers</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-format-number">
-                      <code>fn:format-number</code>
-                    </a>(<code>$value</code>
-                    <code> as </code>
-                    <code>numeric?</code>,
-<code>$picture</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-format-number">
-                      <code>fn:format-number</code>
-                    </a>(<code>$value</code>
-                    <code> as </code>
-                    <code>numeric?</code>,
-<code>$picture</code>
-                    <code> as </code>
-                    <code>xs:string</code>,
-<code>$decimal-format-name</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                </dd>
-                <dt class="label">4.8 Trigonometric and exponential functions</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-math-pi">
-                      <code>math:pi</code>
-                    </a>()<code> as </code>
-                    <code>xs:double</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-exp">
-                      <code>math:exp</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-exp10">
-                      <code>math:exp10</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-log">
-                      <code>math:log</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-log10">
-                      <code>math:log10</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-pow">
-                      <code>math:pow</code>
-                    </a>(<code>$x</code>
-                    <code> as </code>
-                    <code>xs:double?</code>,
-<code>$y</code>
-                    <code> as </code>
-                    <code>numeric</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-sqrt">
-                      <code>math:sqrt</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-sin">
-                      <code>math:sin</code>
-                    </a>(<code>$</code>
-                    <span style="font-family:Times; font-style:italic">θ</span>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-cos">
-                      <code>math:cos</code>
-                    </a>(<code>$</code>
-                    <span style="font-family:Times; font-style:italic">θ</span>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-tan">
-                      <code>math:tan</code>
-                    </a>(<code>$</code>
-                    <span style="font-family:Times; font-style:italic">θ</span>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-asin">
-                      <code>math:asin</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-acos">
-                      <code>math:acos</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-atan">
-                      <code>math:atan</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:double?</code>)<code> as </code>
-                    <code>xs:double?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-math-atan2">
-                      <code>math:atan2</code>
-                    </a>(<code>$y</code>
-                    <code> as </code>
-                    <code>xs:double</code>,
-<code>$x</code>
-                    <code> as </code>
-                    <code>xs:double</code>)<code> as </code>
-                    <code>xs:double</code>
-                  </div>
-                </dd>
-              </dl>
-            </dd>
-            <dt class="label">5 Functions on strings</dt>
-            <dd>
-              <dl>
-                <dt class="label">5.2 Functions to assemble and disassemble
-strings</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-codepoints-to-string">
-                      <code>fn:codepoints-to-string</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:integer*</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-string-to-codepoints">
-                      <code>fn:string-to-codepoints</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:integer*</code>
-                  </div>
-                </dd>
-                <dt class="label">5.3 Comparison of strings</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-compare">
-                      <code>fn:compare</code>
-                    </a>(<code>$comparand1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$comparand2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:integer?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-compare">
-                      <code>fn:compare</code>
-                    </a>(<code>$comparand1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$comparand2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$collation</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:integer?</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-codepoint-equal">
-                      <code>fn:codepoint-equal</code>
-                    </a>(<code>$comparand1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$comparand2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:boolean?</code>
-                  </div>
-                </dd>
-                <dt class="label">5.4 Functions on string values</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-concat">
-                      <code>op:concat</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:anyAtomicType?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:anyAtomicType?</code>,
-<span class="varargs">...</span>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-string-join">
-                      <code>fn:string-join</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string*</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-string-join">
-                      <code>fn:string-join</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string*</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-substring">
-                      <code>fn:substring</code>
-                    </a>(<code>$sourceString</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$start</code>
-                    <code> as </code>
-                    <code>xs:double</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-substring">
-                      <code>fn:substring</code>
-                    </a>(<code>$sourceString</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$start</code>
-                    <code> as </code>
-                    <code>xs:double</code>,
-<code>$length</code>
-                    <code> as </code>
-                    <code>xs:double</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-string-length">
-                      <code>fn:string-length</code>
-                    </a>()<code> as </code>
-                    <code>xs:integer</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-string-length">
-                      <code>fn:string-length</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:integer</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-normalize-space">
-                      <code>fn:normalize-space</code>
-                    </a>()<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-normalize-space">
-                      <code>fn:normalize-space</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-normalize-unicode">
-                      <code>fn:normalize-unicode</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-normalize-unicode">
-                      <code>fn:normalize-unicode</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$normalizationForm</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-upper-case">
-                      <code>fn:upper-case</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-lower-case">
-                      <code>fn:lower-case</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-translate">
-                      <code>fn:translate</code>
-                    </a>(<code>$arg</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$mapString</code>
-                    <code> as </code>
-                    <code>xs:string</code>,
-<code>$transString</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                </dd>
-                <dt class="label">5.5 Functions based on substring matching</dt>
-                <dd>
-                  <div class="protoref">
-                    <a href="#func-contains">
-                      <code>fn:contains</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:boolean</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-contains">
-                      <code>fn:contains</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$collation</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:boolean</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-starts-with">
-                      <code>fn:starts-with</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:boolean</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-starts-with">
-                      <code>fn:starts-with</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$collation</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:boolean</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-ends-with">
-                      <code>fn:ends-with</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:boolean</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-ends-with">
-                      <code>fn:ends-with</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$collation</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:boolean</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-substring-before">
-                      <code>fn:substring-before</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-substring-before">
-                      <code>fn:substring-before</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$collation</code>
-                    <code> as </code>
-                    <code>xs:string</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-substring-after">
-                      <code>fn:substring-after</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>)<code> as </code>
-                    <code>xs:string</code>
-                  </div>
-                  <div class="protoref">
-                    <a href="#func-substring-after">
-                      <code>fn:substring-after</code>
-                    </a>(<code>$arg1</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$arg2</code>
-                    <code> as </code>
-                    <code>xs:string?</code>,
-<code>$collation</code>
-             

Follow ups