org.writersforge.catalan.transform.xform
Class ToElementProcessor

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

public class ToElementProcessor
extends XFormProcessor

A Datum-only NodeProcessor for converting attributes into element content. Expands all attributes with the given name in the selected nodes into elements nested inside the same node. The attribute name is used for the new child element name, and the attribute value becomes PCDATA inside the new element.

Author:
jsheets

Constructor Summary
ToElementProcessor(org.writersforge.bellows.Datum xml)
          Creates a new instance of ToElementProcessor from the XML spec.
ToElementProcessor(java.lang.String query, java.lang.String propertyName, int position, java.lang.String newName)
          Creates a new instance of ToElementProcessor.
 
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

ToElementProcessor

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

Parameters:
xml - XML initializing spec

ToElementProcessor

public ToElementProcessor(java.lang.String query,
                          java.lang.String propertyName,
                          int position,
                          java.lang.String newName)
Creates a new instance of ToElementProcessor.

Parameters:
query - Bellows query path to select the source node(s)
propertyName - the attribute to store the content in
position - the index position to insert nodes, or -1 to insert at end of list
newName - the new name for the element, or null to use attribute name
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)