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

Set an element or attribute value


Attribute
xpaththe target path into the operand document
selectoptional an unambiguous xpath into the child document fragment contained by the stm:set element

The stm:set operation is used to set the value of elements or attributes. It does not create or modify document structure it cannot be used to create or rename elements. The value to be set is obtained from the select xpath location of the enclosed fragment.

Example

Example 1: Set

This example sets /a/b[1]/c, whose initial value is horse, to the value zebra from the /x/y element enclosed by the stm:set operation.

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

Try it

Example 2: Set with value from Param

In this example we introduce param substitution. Any element named <stm:param> within an stm operation element is substituted by the document fragment from the parameter document at the location given by the <stm:param> xpath attribute. As is always the case for any URA the param document is passed to the stm operation by the <param> element of the idoc instruction.

In detail, this example sets the value of /a/[b]/c to the value at /i/j[1]/k that is it sets horse to haddock!

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>vardoc.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:set select="/i/j[1]/k" xpath="/a/b[1]/c">
            <stm:param xpath="/*" />
          </stm:set>
        </stm:group>
      </operator>
      <param>varparam.xml</param>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

Try it

Example 3: Set an Attribute Value

In this example we set an attribute value.

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>doc.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:set select="/food" xpath="/a/b[1]/c/@food">
            <food>biscuits</food>
          </stm:set>
        </stm:group>
      </operator>
      <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