home contribute faq download

FunctX XQuery Functions

functx:last-node

The XML node in a sequence that is last in document order

Google
Webxqueryfunctions.com

Description

The functx:last-node function returns the node in the sequence that appears last in document order (regardless of their order in the sequence). If nodes in the sequence are from multiple documents, the choice of which document is last is implementation-dependent.

Arguments and Return Type

NameTypeDescription
$nodes node()* the sequence of nodes
return value node()?

XQuery Function Declaration

See XSLT definition.
XQuery Syntax for July 2004 - January 2007 (1.0):
declare namespace functx = "http://www.functx.com"; 
declare function functx:last-node 
  ( $nodes as node()* )  as node()? {
       
   ($nodes/.)[last()]
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function last-node 
  ( $nodes as node()* )  as node()? {
       
   ($nodes/.)[fn:last()]
 }

Examples

let $in-xml :=
<authors>
   <author>
      <fName>Kate</fName>
      <lName>Jones</lName>
   </author>
   <author>
      <fName>John</fName>
      <lName>Doe</lName>
   </author>
</authors>
return
XQuery ExampleResults
functx:last-node($in-xml//fName)
<fName>John</fName>
functx:last-node(
     ($in-xml//lName,
      $in-xml//fName) )
<lName>Doe</lName>

See Also

functx:follows-not-descendantWhether an XML node follows another without being its descendant
functx:first-nodeThe XML node in a sequence that appears first in document order
fn:lastThe size of the current context

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley