I would like to call an XPL from java, but I can't get back the output of the XPL. The executePipeline method runs without error. I try to get the output through the response.outputStream, but it is empty. I want to make this test.xpl run: <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors"> <p:param type="input" name="selectparam"/> <p:param type="output" name="data"/> <p:processor name="oxf:identity"> <p:input name="data" href="#selectparam#xpointer(/input/selectParamsSection)"/> <p:output name="data" ref="data"/> </p:processor> </p:config> private static String callTest(Element selectparam) { try { // Only log warnings and higher Properties log4jProperties = new Properties(); log4jProperties.put("log4j.rootLogger", "WARN"); PropertyConfigurator.configure(log4jProperties); // Initialize the Resource Manager Map props = new HashMap(); props.put("oxf.resources.factory", "org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory"); ResourceManagerWrapper.init(props); // Initialize properties OXFProperties.init("oxf:/properties.xml"); // Create an initial pipeline context PipelineContext pipelineContext = new PipelineContext(); // Register inital processors with the default XML Processor Registry Processor processorsDefinition = PipelineUtils.createURLGenerator("oxf:/processors.xml"); Processor registry = new XMLProcessorRegistry(); PipelineUtils.connect(processorsDefinition, "data", registry, "config"); pipelineContext.setAttribute(PipelineContext.JNDI_CONTEXT, new InitialContext()); registry.reset(pipelineContext); registry.start(pipelineContext); ProcessorDefinition processorDefinition = new ProcessorDefinition(); processorDefinition.setUri("oxf/processor/pipeline"); processorDefinition.addInput("config", "file:///d:/eclipse/workspace/....../test.xpl"); processorDefinition.addInput("selectparam", selectparam); ExternalContext externalContext = new SimpleExternalContext(); PipelineEngineFactory.instance().executePipeline(processorDefinition, externalContext, pipelineContext); ExternalContext.Response response = externalContext.getResponse(); ByteArrayOutputStream os = (ByteArrayOutputStream)response.getOutputStream(); String result = os.toString(); System.out.println("SectionCollection-initOXF-xquery [" + result + "]"); return result; } catch (Exception ex) { ex.printStackTrace(); } return null; } Please, help me! jel -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
Jel,
This is probably not the best way (if a good way at all) to get a result from a pipeline. I suggest instead you get a DOM result, following this thread: http://mail-archive.objectweb.org/ops-users/2005-11/msg00396.html -Erik [hidden email] wrote: > > I would like to call an XPL from java, but I can't get back the output > of the XPL. > The executePipeline method runs without error. I try to get the output > through the response.outputStream, but it is empty. > > I want to make this test.xpl run: > <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" > xmlns:oxf="http://www.orbeon.com/oxf/processors"> > > <p:param type="input" name="selectparam"/> > <p:param type="output" name="data"/> > > <p:processor name="oxf:identity"> > <p:input name="data" > href="#selectparam#xpointer(/input/selectParamsSection)"/> > <p:output name="data" ref="data"/> > </p:processor> > </p:config> > > > private static String callTest(Element selectparam) { > try { > // Only log warnings and higher > Properties log4jProperties = new Properties(); > log4jProperties.put("log4j.rootLogger", "WARN"); > PropertyConfigurator.configure(log4jProperties); > > // Initialize the Resource Manager > Map props = new HashMap(); > props.put("oxf.resources.factory", > "org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory"); > ResourceManagerWrapper.init(props); > > // Initialize properties > OXFProperties.init("oxf:/properties.xml"); > > // Create an initial pipeline context > PipelineContext pipelineContext = new PipelineContext(); > > // Register inital processors with the default XML Processor > Registry > Processor processorsDefinition = > PipelineUtils.createURLGenerator("oxf:/processors.xml"); > > Processor registry = new XMLProcessorRegistry(); > PipelineUtils.connect(processorsDefinition, "data", > registry, "config"); > pipelineContext.setAttribute(PipelineContext.JNDI_CONTEXT, > new InitialContext()); > registry.reset(pipelineContext); > registry.start(pipelineContext); > > ProcessorDefinition processorDefinition = new > ProcessorDefinition(); > processorDefinition.setUri("oxf/processor/pipeline"); > processorDefinition.addInput("config", > "file:///d:/eclipse/workspace/....../test.xpl"); > processorDefinition.addInput("selectparam", selectparam); > > ExternalContext externalContext = new SimpleExternalContext(); > > > PipelineEngineFactory.instance().executePipeline(processorDefinition, > externalContext, pipelineContext); > ExternalContext.Response response = > externalContext.getResponse(); > > ByteArrayOutputStream os = > (ByteArrayOutputStream)response.getOutputStream(); > > String result = os.toString(); > System.out.println("SectionCollection-initOXF-xquery [" + > result + "]"); > > return result; > > } catch (Exception ex) { > ex.printStackTrace(); > } > > return null; > } > > > Please, help me! > > jel > > > ------------------------------------------------------------------------ > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |