.. _insert-before: ============= insert-before ============= Inserts a new item into a sequence 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. .. list-table:: :widths: 40 60 :header-rows: 1 * - **Parameters** - **Description** * - target:item() - the sequence to insert into * - position:integer() - the position to insert at * - inserts:item() - the items to insert Examples ~~~~~~~~ .. list-table:: :widths: 50 50 :header-rows: 1 * - **XPath** - **Results** * - 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')