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

Rename an element


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

The stm:rename operation renames an element located by an xpath. The children of the renamed element are unaffected and remain children of the renamed element. The new name is the value at the select xpath location of the enclosed document.

stm:rename is namespace aware and will retain the namespace prefix and namespace URI of the orginal element.

Due to limitations of the W3C DOM model renaming can be a relatively expensive operation.

Example

Example 1: Rename an element

This example renames all the <b> elements to <equine>.

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

Try it

Example 2: Namespace aware Rename

This example demonstrates renaming an element that has a namespace. First we use stm:apply-ns to apply the animals namespace to all elements of our example document. Secondly we rename the element <animals:b> to equine. The namespace prefix and URI are preserved.

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>doc.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:apply-ns prefix="animals" uri="http://1060.org/test" xpath="/a" />
          <stm:rename select="." xpath="/animals:a/animals:b"> equine </stm:rename>
        </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