home contribute faq download

FunctX XSLT Functions

fn:insert-before

Inserts a new item into a sequence

Google
Webxsltfunctions.com

Description

The fn:insert-before function returns a copy of the $target sequence with the item(s) in $inserts inserted at the position indicated by $position. Position numbers start at 1, not 0.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameTypeDescription
$target item()* the sequence to insert into
$position xs:integer the position to insert at
$inserts item()* the items to insert
return value item()*

Examples

XPath ExampleResults
insert-before(
   ('a', 'b', 'c'), 1, ('x', 'y'))
('x', 'y', 'a', 'b', 'c')
insert-before(
   ('a', 'b', 'c'), 2, ('x', 'y'))
('a', 'x', 'y', 'b', 'c')
insert-before(
   ('a', 'b', 'c'), 10, ('x', 'y'))
('a', 'b', 'c', 'x', 'y')
insert-before(
   ('a', 'b', 'c'), 0, ('x', 'y'))
('x', 'y', 'a', 'b', 'c')
insert-before(
   ('a', 'b', 'c'), 2, ())
('a', 'b', 'c')
insert-before(
   (), 3, ('a', 'b', 'c') )
('a', 'b', 'c')

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading:

XQuery