import oracle.xml.xsql.*; import oracle.xml.xsql.actions.XSQLIncludeXSQLHandler; import org.w3c.dom.*; import java.sql.SQLException; public class CustomInclude extends XSQLActionHandlerImpl { XSQLActionHandler nestedHandler = null; public void handleAction(Node root) throws SQLException { // Create an instance of an XSQLIncludeXSQLHandler // and init() the handler by passing the current request/action nestedHandler = new XSQLIncludeXSQLHandler(); nestedHandler.init(getPageRequest(),getActionElement()); // Rather than passing the default XML result "root" that we're given, // instead we create an empty DocumentFragment and feed *that* to // the XSQLIncludeXSQLHandler as it's root to work with DocumentFragment tmpRoot = root.getOwnerDocument().createDocumentFragment(); nestedHandler.handleAction(tmpRoot); // Custom Java code here can work on the returned document fragment // in tmpRoot before appending the final, modified document to the // XML result "root" node we're given by the XSQL Page Processor // // For example, add an attribute to the first child Element e = (Element)tmpRoot.getFirstChild(); if (e != null) { e.setAttribute("ExtraAttribute","SomeValue"); } // Finally, append the modified tmpRoot fragment as the XML result root.appendChild(tmpRoot); } } |