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());
}
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);
}
}
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);
}
}
Aggregations