import javax.xml.transform.stream.StreamSource;
import net.sf.saxon.s9api.*;
import java.io.File;

public class TwentyStagesS9 {

    /**
     * Applies a 20 stage pipeline.
     * args[0] is the input file
     * args[1] is the output file
     */
    public static void main(String[] args)
      throws SaxonApiException
    {
    
      Processor proc = new Processor(false);
      XsltCompiler comp = proc.newXsltCompiler();
        XdmNode in= proc.newDocumentBuilder().build(new StreamSource(new File(args[0])));
        Serializer out= new Serializer();
        out.setOutputFile(new File(args[1]));
        XsltTransformer stage1 = comp.compile(new StreamSource(new File("stage1.xsl"))).load();
        XsltTransformer stage2 = comp.compile(new StreamSource(new File("stage2.xsl"))).load();
        XsltTransformer stage3 = comp.compile(new StreamSource(new File("stage3.xsl"))).load();
        XsltTransformer stage4 = comp.compile(new StreamSource(new File("stage4.xsl"))).load();
        XsltTransformer stage5 = comp.compile(new StreamSource(new File("stage5.xsl"))).load();
        XsltTransformer stage6 = comp.compile(new StreamSource(new File("stage6.xsl"))).load();
        XsltTransformer stage7 = comp.compile(new StreamSource(new File("stage7.xsl"))).load();
        XsltTransformer stage8 = comp.compile(new StreamSource(new File("stage8.xsl"))).load();
        XsltTransformer stage9 = comp.compile(new StreamSource(new File("stage9.xsl"))).load();
        XsltTransformer stage10 = comp.compile(new StreamSource(new File("stage10.xsl"))).load();
        XsltTransformer stage11 = comp.compile(new StreamSource(new File("stage11.xsl"))).load();
        XsltTransformer stage12 = comp.compile(new StreamSource(new File("stage12.xsl"))).load();
        XsltTransformer stage13 = comp.compile(new StreamSource(new File("stage13.xsl"))).load();
        XsltTransformer stage14 = comp.compile(new StreamSource(new File("stage14.xsl"))).load();
        XsltTransformer stage15 = comp.compile(new StreamSource(new File("stage15.xsl"))).load();
        XsltTransformer stage16 = comp.compile(new StreamSource(new File("stage16.xsl"))).load();
        XsltTransformer stage17 = comp.compile(new StreamSource(new File("stage17.xsl"))).load();
        XsltTransformer stage18 = comp.compile(new StreamSource(new File("stage18.xsl"))).load();
        XsltTransformer stage19 = comp.compile(new StreamSource(new File("stage19.xsl"))).load();
        XsltTransformer stage20 = comp.compile(new StreamSource(new File("stage20.xsl"))).load();
        stage1.setDestination(stage2);
        stage2.setDestination(stage3);
        stage3.setDestination(stage4);
        stage4.setDestination(stage5);
        stage5.setDestination(stage6);
        stage6.setDestination(stage7);
        stage7.setDestination(stage8);
        stage8.setDestination(stage9);
        stage9.setDestination(stage10);
        stage10.setDestination(stage11);
        stage11.setDestination(stage12);
        stage12.setDestination(stage13);
        stage13.setDestination(stage14);
        stage14.setDestination(stage15);
        stage15.setDestination(stage16);
        stage16.setDestination(stage17);
        stage17.setDestination(stage18);
        stage18.setDestination(stage19);
        stage19.setDestination(stage20);
        stage20.setDestination(out);
//         stage5.setDestination(out);
        stage1.setInitialContextNode(in);
        stage1.transform();
        
    }
}
