Devsphere.com


com.devsphere.xml.taglib.process.builder
Class Controller

java.lang.Object
  |
  +--com.devsphere.xml.taglib.process.builder.Controller
All Implemented Interfaces:
SDXController

public class Controller
extends java.lang.Object
implements SDXController

This class implements com.devsphere.xml.saxdomix.SDXController to generate JSP code for handling the DOM sub-trees.

An instance of this class is created by a Main object, which is referred further as SAXDOMIX builder because it inherits com.devsphere.xml.saxdomix.SDXBuilder through com.devsphere.xml.taglib.support.builder.BuilderSupport.


Constructor Summary
Controller(Parameters params, Outputter out)
          Initializes the controller.
 
Method Summary
 void handleDOM(org.w3c.dom.Element element)
          Generates code for handling a DOM sub-tree.
 boolean wantDOM(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes attributes)
          Generates code for handling a DOM sub-tree.
protected  void xpathExpressions(java.lang.String xpath, org.w3c.dom.Element context)
          Generates a list of valid XPath expressions that can be evaluated in the given context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Controller

public Controller(Parameters params,
                  Outputter out)
Initializes the controller.

Parameters:
params - the command line parameters
out - the object used to output the generated code
Method Detail

wantDOM

public boolean wantDOM(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qualifiedName,
                       org.xml.sax.Attributes attributes)
                throws org.xml.sax.SAXException
Generates code for handling a DOM sub-tree. Returns true when the application wants to receive a DOM sub-tree for handling. This happens when the qualified name of the current element was specified in the rootElements list.

During the SAX parsing of the XML sample, a builder object invokes the controller's wantDOM() method for each startElement() parsing event. If wantDOM() returns false the SAX parsing mode continues. When wantDOM() returns true the builder enters in DOM parsing mode and starts creating a DOM sub-tree from all SAX events between the current startElement() and the corresponding endElement().

Specified by:
wantDOM in interface SDXController
Parameters:
namespaceURI - The element's namespace URI
localName - The element's local name
qualifiedName - The element's qualified name
attributes - The element's attributes
Returns:
A boolean value indicating whether the builder must enter in DOM parsing mode or must remain in SAX parsing mode
Throws:
org.xml.sax.SAXException - If an error must be signaled

handleDOM

public void handleDOM(org.w3c.dom.Element element)
               throws org.xml.sax.SAXException
Generates code for handling a DOM sub-tree. This method will call xpathExpressions() to generate a list of valid XPath expressions that can be evaluated in the context of the sample DOM sub-tree.

After wantDOM() returns true, the builder constructs a DOM sub-tree from SAX events and passes it to the controller's handleDOM() method. After handling, the builder returns to the SAX parsing mode.

Specified by:
handleDOM in interface SDXController
Parameters:
element - The root of the DOM sub-tree
Throws:
org.xml.sax.SAXException - If an error must be signaled

xpathExpressions

protected void xpathExpressions(java.lang.String xpath,
                                org.w3c.dom.Element context)
Generates a list of valid XPath expressions that can be evaluated in the given context.

Parameters:
xpath - The expression used to refer the DOM sub-tree.
context - The root of the DOM sub-tree whose XPaths must be generated.

 Devsphere.com