protected boolean stream(ElementHandler handler) { // create an xpath context from the root element // TODO: cache the context, should work just the same // JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class, // ElementHandlerPropertyHandler.class); JXPathIntrospector.registerDynamicClass(NodeImpl.class, NodePropertyHandler.class); // ElementHandler rootHandler = // ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler(); Node root = ((DocumentHandler) handlers.firstElement()).getParseNode(); JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null, root); jxpContext.setLenient(true); Iterator itr = jxpContext.iterate(xpath); while (itr.hasNext()) { Object obj = itr.next(); if (handler.getParseNode().equals(obj)) { return true; } } return false; } }
protected boolean stream(ElementHandler handler) { //create an xpath context from the root element // TODO: cache the context, should work just the same // JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class, // ElementHandlerPropertyHandler.class); JXPathIntrospector.registerDynamicClass( NodeImpl.class, NodePropertyHandler.class ); // ElementHandler rootHandler = // ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler(); Node root = ((DocumentHandler)handlers.firstElement()).getParseNode(); JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null,root); jxpContext.setLenient(true); Iterator itr = jxpContext.iterate(xpath); for (; itr.hasNext();) { Object obj = itr.next(); if (handler.getParseNode().equals(obj)) { return true; } } return false; }
protected boolean stream(ElementHandler handler) { //create an xpath context from the root element // TODO: cache the context, should work just the same // JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class, // ElementHandlerPropertyHandler.class); JXPathIntrospector.registerDynamicClass(NodeImpl.class, NodePropertyHandler.class); // ElementHandler rootHandler = // ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler(); Node root = ((DocumentHandler) handlers.firstElement()).getParseNode(); JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null, root); jxpContext.setLenient(true); Iterator itr = jxpContext.iterate(xpath); for (; itr.hasNext();) { Object obj = itr.next(); if (handler.getParseNode().equals(obj)) { return true; } } return false; } }
protected boolean stream(ElementHandler handler) { //create an xpath context from the root element // TODO: cache the context, should work just the same // JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class, // ElementHandlerPropertyHandler.class); JXPathIntrospector.registerDynamicClass(NodeImpl.class, NodePropertyHandler.class); // ElementHandler rootHandler = // ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler(); Node root = ((DocumentHandler) handlers.firstElement()).getParseNode(); JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null, root); jxpContext.setLenient(true); Iterator itr = jxpContext.iterate(xpath); for (; itr.hasNext();) { Object obj = itr.next(); if (handler.getParseNode().equals(obj)) { return true; } } return false; } }
public void initialize() throws Exception { if (enableDebugger) { if (getLogger().isDebugEnabled()) { getLogger().debug("Flow debugger enabled, creating"); } getDebugger().doBreak(); } Context context = Context.enter(); context.setOptimizationLevel(OPTIMIZATION_LEVEL); context.setCompileFunctionsWithDynamicScope(true); context.setGeneratingDebug(true); // add support for Rhino objects to JXPath JXPathIntrospector.registerDynamicClass(Scriptable.class, ScriptablePropertyHandler.class); JXPathContextReferenceImpl.addNodePointerFactory(new ScriptablePointerFactory()); try { scope = new Global(context); // Access to Cocoon internal objects FOM_Cocoon.init(scope); } catch (Exception e) { Context.exit(); throw e; } }