org.writersforge.catalan.transform.xform
Class TagProcessor

java.lang.Object
  extended byorg.writersforge.catalan.transform.BaseNodeProcessor
      extended byorg.writersforge.catalan.transform.xform.XFormProcessor
          extended byorg.writersforge.catalan.transform.xform.TagProcessor
All Implemented Interfaces:
org.writersforge.bellows.traverse.NodeProcessor

public class TagProcessor
extends XFormProcessor

A Datum-only NodeProcessor for recursively adding attribute tags to sets of sibling elements. Typically used for dynamically adding chapter and section numbers to XML documents.

Author:
jsheets

Constructor Summary
TagProcessor(org.writersforge.bellows.Datum xml)
          Creates a new instance of TagProcessor from the XML spec.
TagProcessor(java.lang.String query, java.lang.String[] paths, java.lang.String attribute, java.lang.String separator, int startIndex)
          Creates a new instance of TagProcessor.
 
Method Summary
protected  org.writersforge.bellows.Datum transformNode(org.writersforge.bellows.Datum node, org.writersforge.bellows.Datum root)
          Performs an in-place transformation on the supplied Datum tree.
 
Methods inherited from class org.writersforge.catalan.transform.xform.XFormProcessor
getQuery, getQueryNodes, processNode
 
Methods inherited from class org.writersforge.catalan.transform.BaseNodeProcessor
addLeftover, end, getLeftovers, getNodes, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagProcessor

public TagProcessor(org.writersforge.bellows.Datum xml)
Creates a new instance of TagProcessor from the XML spec.

Parameters:
xml - XML initializing spec

TagProcessor

public TagProcessor(java.lang.String query,
                    java.lang.String[] paths,
                    java.lang.String attribute,
                    java.lang.String separator,
                    int startIndex)
Creates a new instance of TagProcessor.

Parameters:
query - Bellows query path to select the source node(s)
paths - a series of nested paths for each level of tagging
attribute - optional attribute name to store tags in; defaults to "number"
separator - optional text to place between successive tags in nested levels; defaults to "."
startIndex - the numbering index to start counting at
Method Detail

transformNode

protected org.writersforge.bellows.Datum transformNode(org.writersforge.bellows.Datum node,
                                                       org.writersforge.bellows.Datum root)
Performs an in-place transformation on the supplied Datum tree.

Specified by:
transformNode in class XFormProcessor
Parameters:
node - the current node to operate upon
root - the root of the entire XML tree
Returns:
the new root Datum object (usually the same one)