stm:replace
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:replace

Replace an element


Attribute
xpathrequired the target xpath into the operand document

The stm:replace operation replaces an element located by an xpath with the document fragment enclosed by the <stm:replace>. Any children of the target element are destroyed.

Example

Example 1: Replace an element

This example replaces the first <b> element with the fragment /x/y.

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

Try it

Example 2: Replace multiple elements

This example replaces all the <b> elements with the /i/j[1] fragment from the parameter substitution.

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>doc.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:replace xpath="/a/b">
            <stm:param xpath="/i/j[1]" />
          </stm:replace>
        </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