home contribute faq download

FunctX XQuery Functions

functx:siblings-same-name

The siblings of an XML element that have the same name

Google
Webxqueryfunctions.com

Description

The functx:siblings-same-name function returns the siblings of an element that have the same qualified name. It returns only other elements, not attributes, and not the element itself.

Arguments and Return Type

NameTypeDescription
$element element()? the node
return value element()*

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:siblings-same-name 
  ( $element as element()? )  as element()* {
       
   $element/../*[node-name(.) = node-name($element)]
   except $element
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function siblings-same-name 
  ( $element as element()? )  as element()* {
       
   $element/../*[fn:node-name(.) = fn:node-name($element)]
   except $element
 }

Examples

let $in-xml :=
<authors>
   <author>
      <fName>Kate</fName>
      <fName>Jane</fName>
      <lName>Jones</lName>
   </author>
   <author>
      <fName>John</fName>
      <lName>Doe</lName>
   </author>
</authors>
return
XQuery ExampleResults
functx:siblings-same-name(
     $in-xml/author[1])
<author>
  <fName>John</fName>
  <lName>Doe</lName>
</author>
functx:siblings-same-name(
     $in-xml/author[1]/fName[2])
<fName>Kate</fName>

See Also

functx:siblingsThe siblings of an XML node

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