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

Compute the basis set for an xpath expression


Attribute
xpaththe target path into the operand document

The stm:basis operation generates the basis set for the given xpath. In linear algebra the basis is the set of unique values from which all others can be composed. stm:basis computes the unique document for a given xpath.

Sounds complex but it's not so bad and is very useful. Say you want to know the set of unique values of, for example, @type attribute in a document. Use stm:basis with xpath="//@type". It's then easy to transform that result into say an XHTML form select element.

What if you wanted to know the set of unique instructions used in an idoc? Use xpath="/descendant::type/text()". Or the set of unique customers from a list of multiple orders - use something like xpath="/orders/order/customer/name/text()"

With declarative processing of XML it is very useful to be able to examine the fundamental structure of a document without the noise of the data. Using xpath="//*" returns the skeleton document without it's data.

stm:basis works with any xpath location these can be elements, text or attributes or any combination.

Example

Example1: The basis elements

This example creates the basis document from which the source document was a linear combination. Checkout data.xml to see how it is composed of this basis set.

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>data.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:basis xpath="//*" />
        </stm:group>
      </operator>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

Try it

Example 2: The unique attribute values

This example returns the set of all attributes and their unique values. They remain in the context of the document tree structure.

<idoc>
  <seq>
    <instr>
      <type>stm</type>
      <operand>doc.xml</operand>
      <operator>
        <stm:group xmlns:stm="http://1060.org/stm">
          <stm:basis xpath="//*/@*" />
        </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