Search in sources :

Example 1 with Step

use of org.apache.sling.scripting.xproc.xpl.api.Step in project sling by apache.

the class XplBuilderTest method testBuild.

public void testBuild() throws Exception {
    String xplPath = "/xpl/html.xpl";
    XplBuilder builder = new XplBuilder();
    Step pipeline = builder.build(getReaderFromPath(xplPath));
    String strControl = toString(getClass().getResourceAsStream(xplPath));
    XMLAssert.assertXMLEqual(strControl, pipeline.toString());
}
Also used : Step(org.apache.sling.scripting.xproc.xpl.api.Step)

Example 2 with Step

use of org.apache.sling.scripting.xproc.xpl.api.Step in project sling by apache.

the class AbstractCompoundStepImpl method addChild.

@Override
public void addChild(XplElement child) {
    super.addChild(child);
    if (child instanceof Step) {
        Step stepChild = (Step) child;
        stepChild.setEnv(this.getEnv());
        subpipeline.add(stepChild);
    }
}
Also used : CompoundStep(org.apache.sling.scripting.xproc.xpl.api.CompoundStep) Step(org.apache.sling.scripting.xproc.xpl.api.Step)

Example 3 with Step

use of org.apache.sling.scripting.xproc.xpl.api.Step in project sling by apache.

the class PipelineImpl method eval.

@Override
public void eval() throws Exception {
    try {
        this.getEnv().setCcPipeline(new NonCachingPipeline());
        // generator
        AbstractGenerator generator = new SlingGenerator(this.getEnv().getSling());
        this.getEnv().getCcPipeline().addComponent(generator);
        // subpipeline evaluated
        for (Step step : this.getSubpipeline()) {
            step.eval();
        }
        this.getEnv().getCcPipeline().addComponent(new XMLSerializer());
        // Don't retrieve OutputStream from response until actually writing
        // to response, so that error handlers can retrieve it without getting
        // an error
        final OutputStream out = new OutputStreamWrapper() {

            @Override
            protected OutputStream getWrappedStream() throws IOException {
                return getEnv().getSling().getResponse().getOutputStream();
            }
        };
        this.getEnv().getCcPipeline().setup(out);
        this.getEnv().getCcPipeline().execute();
    } catch (Exception e) {
        String absPath = this.getEnv().getSling().getRequest().getResource().getPath();
        throw new Exception("Error in pipeline for resource: " + absPath, e);
    }
}
Also used : NonCachingPipeline(org.apache.cocoon.pipeline.NonCachingPipeline) XMLSerializer(org.apache.cocoon.pipeline.component.sax.XMLSerializer) SlingGenerator(org.apache.sling.scripting.xproc.cocoon.generator.SlingGenerator) AbstractGenerator(org.apache.cocoon.pipeline.component.sax.AbstractGenerator) OutputStream(java.io.OutputStream) Step(org.apache.sling.scripting.xproc.xpl.api.Step) IOException(java.io.IOException)

Aggregations

Step (org.apache.sling.scripting.xproc.xpl.api.Step)3 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 NonCachingPipeline (org.apache.cocoon.pipeline.NonCachingPipeline)1 AbstractGenerator (org.apache.cocoon.pipeline.component.sax.AbstractGenerator)1 XMLSerializer (org.apache.cocoon.pipeline.component.sax.XMLSerializer)1 SlingGenerator (org.apache.sling.scripting.xproc.cocoon.generator.SlingGenerator)1 CompoundStep (org.apache.sling.scripting.xproc.xpl.api.CompoundStep)1