stm:insert-before
STM by Example
Release Notes
Developing with NetKernel
Module Development Guide
Introduction
Design Model
Parameter Substitution
Namespaces
Examples readme
Tree Operations
stm:set
stm:append
stm:delete
stm:create-path
stm:get-fragment
stm:rename
stm:apply-ns
stm:remove-ns
stm:insert-before
stm:insert-after
stm:regex
stm:replace
stm:append-text
stm:append-attr
stm:set-xpath-eval
stm:basis
DPML Reference Guide
XRL Reference Guide
XForms Processing Guide
XAccesor/XAHelper
XDA
Session Guide
Mod DB Guide
Compound URI Guide
License
Change History
NetKernel History
Acknowledgements

stm:insert-before

Insert a fragment before an element


Attribute
xpathrequired the target path into the operand document

The stm:insert-before operation is used to insert a document fragment before an element located by an xpath. Inserted items are located above the target element. If the xpath value returns multiple targets the fragment is inserted above each of them.

Example

Example 1: Insert a fragment before a target

This example inserts the enclosed /x/y fragment before the first <b> element.

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>doc.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:insert-before xpath="/a/b[1]">
            <x>
              <y>zebra</y>
            </x>
          </stm:insert-before>
        </stm:group>
      </operator>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

Try it

Example 2: Insert a param substituted fragment before multiple targets

This is a more complex example. It demonstrates a mutlivalued xpath target. The xpath /a/b is ambiguous and produces two <b> elements. The insert-before operation is applied to each of the elements. In addition this uses parameter substitution to obtain the /i/j/k fragment which is inserted before <b>.

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>doc.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:insert-before xpath="/a/b">
            <stm:param />
          </stm:insert-before>
        </stm:group>
      </operator>
      <param>param.xml</param>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

Try it


1060® NetKernelTM Documentation
(C) 2003-2004 1060 Research Limited

Send Feedback

© 2003,2004, 1060® Research Limited
1060 registered trademark, NetKernel trademark of 1060 Research Limited