org.ejen
Class EjenFilterNode

java.lang.Object
  |
  +--org.ejen.EjenChildNode
        |
        +--org.ejen.EjenStylesheetNode
              |
              +--org.ejen.EjenFilterNode
All Implemented Interfaces:
EjenConstants

public class EjenFilterNode
extends EjenStylesheetNode

Filter node class.

A filter node tranforms the current in memory DOM tree.

Usage (ant build file)

  <?xml version="1.0" encoding="UTF-8"?>

  <project name="generate" default="build">

    <taskdef name="ejen" classname="org.ejen.EjenTask"/>

    <target name="build">
      <ejen ...>
        ...
        <filter file="filter.xml"
               [foreach="/ejen/entity-bean"]>
          ...
          [<include .../>]
          [<import .../>]
          [<param .../>]
          ...
        </filter>
        ...
      </ejen>
    </target>

  </project>
 

Parent nodes:

Version:
1.0
Author:
F. Wolff

Field Summary
protected  String _foreach
           
 
Fields inherited from class org.ejen.EjenStylesheetNode
_childNodes, _file
 
Fields inherited from class org.ejen.EjenChildNode
_messageIndent
 
Fields inherited from interface org.ejen.EjenConstants
CTX_DOM_SOURCE, CTX_STYLESHEET_HANDLER, CTX_STYLESHEET_ROOT, CTX_TRANSFORMER_FACTORY_IMPL, CTX_TRANSFORMER_IMPL, DEFAULT_XML_DATA, DEFAULT_XML_DATA_ENCODING, DEFAULT_XSL_DATA, LOG_INDENT_STR1, LOG_INDENT_STR2, MSG_DEBUG, MSG_ERR, MSG_INFO, MSG_VERBOSE, MSG_WARN, STATE_AFTER_PROCESS, STATE_BEFORE_PROCESS, STATE_CHECK, STATE_IDLE, STATE_PROCESS, STATES
 
Constructor Summary
EjenFilterNode()
           
 
Method Summary
 Properties getAttributes()
          Returns all non null attributes of this EjenFilterNode.
 String nodeName()
          Returns the name of this EjenFilterNode (always "filter").
 void process()
          Executes this EjenFilterNode.
 void setForeach(String foreach)
          [optional/AVT] - sets the foreach attribute.
 
Methods inherited from class org.ejen.EjenStylesheetNode
afterProcess, beforeProcess, check, createImport, createInclude, createParam, getChildren, setFile
 
Methods inherited from class org.ejen.EjenChildNode
cloneContext, evaluateAVT, evaluateAVT, getFromContext, getFromContext, getFromGlobalContext, getListener, getState, idle, popContext, pushContext, putInContext, putInGlobalContext, sendMessageEvent, sendMessageEvent, sendStateEvent, sendXSLMessageEvent, sendXSLMessageEvent, setListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_foreach

protected String _foreach
Constructor Detail

EjenFilterNode

public EjenFilterNode()
Method Detail

nodeName

public String nodeName()
Returns the name of this EjenFilterNode (always "filter").

Specified by:
nodeName in class EjenChildNode
Returns:
the name of this EjenFilterNode.

getAttributes

public Properties getAttributes()
Returns all non null attributes of this EjenFilterNode.

Overrides:
getAttributes in class EjenStylesheetNode
Returns:
non null attributes of this EjenFilterNode.

setForeach

public void setForeach(String foreach)
[optional/AVT] - sets the foreach attribute. This attribute allows iterative applications of this filter stylesheet to a sub-nodes set of the current in memory DOM tree.

Suppose you have the following DOM tree in memory:

  <?xml version="1.0" encoding="iso-8859-1"?>
  <ejen>
    <name>Name1</name>
    <name>Name2</name>
    <name>Name3</name>
    ...
  </ejen>
 
You want to transform it into this DOM tree:

  <?xml version="1.0" encoding="iso-8859-1"?>
  <ejen>
    <name>Dear Name1</name>
    <name>Dear Name2</name>
    <name>Dear Name3</name>
    ...
  </ejen>
 
You can use this filter stylesheet (with the foreach attribute set to "/ejen/name"):

  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="1.0">
    <xsl:output method="xml" encoding="iso-8859-1"/>
    <xsl:template match="name">
      <name>Dear <xsl:value-of select="."/></name>
    </xsl:template>
  </xsl:stylesheet>
 

If this attribute is used, a parameter whose name is "root" and value is the root node of the current DOM tree is always and automaticaly passed to the filter stylesheet (you may have the line "<xsl:param name"root"/>" in the stylesheet).

Parameters:
foreach - foreach String (default is null, meaning "apply this filter stylesheet to the entire current DOM tree").

process

public void process()
Executes this EjenFilterNode.

Overrides:
process in class EjenStylesheetNode
Throws:
EjenException - if something goes wrong...