stm:remove-ns
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:remove-ns

Remove a Namespace


Attribute
xpathrequired the target xpath into the operand document
prefixrequired prefix identifier to use for namespace uri

The stm:remove-ns operation removes a namespace and associated prefix from a document fragment located by an xpath. The children of the target element are all moved out of the namespace.

Due to the historical difficulty of handling namespaces they have generally been infrequently used by XML applications. STM attempts to make removal of namespaces straightforward. We anticipate that namespace assigment can be a valuable tool in XML processing. For example portions of an in-process document may be moved into a temporary namespace to hide it from intermediate processing steps before moving it back to the original namespace on completion.

Limitations: The current implementation only handles namespace removal from elements, though this should cover 90% of use cases.

Due to the limitations of the DOM model removing namespaces is a relatively expensive operation.

Example

Example 1: Remove a namespace

This example first applies a namespace country to the first <b> element and it's children. This namespace on /a/country:b is then removed. The result is the original document but including the namespace declaration. See remove-ns-decl.

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>doc.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:apply-ns prefix="country" uri="http://1060.org/stm/apply-ns/eg1" xpath="/a/b[1]" />
          <stm:remove-ns prefix="country" xpath="/a/country:b" />
        </stm:group>
      </operator>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

Try it

Example 2: Remove Namespace Completely

This example is essentially the same as Example 1. However we now entirely remove the namespace by using the remove-ns-decl operation on /a/b

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>doc.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:apply-ns prefix="country" uri="http://1060.org/stm/apply-ns/eg1" xpath="/a/b[1]" />
          <stm:remove-ns prefix="country" xpath="/a/country:b" />
          <stm:remove-ns-decl prefix="country" uri="http://1060.org/stm/apply-ns/eg1" xpath="/a/b" />
        </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