FileAppenderStep extends StepJava { @Override public void close() throws SaxonApiException { }  @Override Receiver getReceiver(Configuration c); @Override void close(); static final QName FILE_NAME; static final QName VALUE; static final QName LINE_SEPARATOR; static final QName ENCODING; }
@Test public void doTest() throws SaxonApiException, FileNotFoundException, IOException { Configuration config = Configuration.newConfiguration(); Processor processor = new Processor(config); XsltTransformer transformer = processor.newXsltCompiler().compile(new StreamSource("src/test/resources/identity.xsl")).load(); Serializer serializer = processor.newSerializer(new File("target/generated-test-files/output.xml")); FileAppenderStep fas = new FileAppenderStep(); fas.setParameter(FileAppenderStep.FILE_NAME, new XdmAtomicValue("target/generated-test-files/appendee.txt")); fas.setParameter(FileAppenderStep.VALUE, new XdmAtomicValue("blablabla")); fas.setParameter(FileAppenderStep.LINE_SEPARATOR, new XdmAtomicValue("LF")); fas.setDestination(serializer); transformer.setDestination(fas); transformer.setSource(new StreamSource("src/test/resources/source.xml")); File expect = new File("target/generated-test-files/appendee.txt"); if(expect.exists()) expect.delete(); transformer.transform(); assertTrue(expect.isFile()); BufferedReader br = new BufferedReader(new FileReader(expect)); char[] buff = new char[30]; int ret = br.read(buff); br.close(); assertEquals(10, ret); char[] ex = new char[] { 'b', 'l', 'a', 'b', 'l', 'a', 'b', 'l', 'a', '\n'}; assertArrayEquals(ex, Arrays.copyOf(buff, ret)); fas.setDestination(processor.newSerializer(new File("target/generated-test-files/output2.xml"))); transformer.transform(); br = new BufferedReader(new FileReader(expect)); ret = br.read(buff); br.close(); assertEquals(20, ret); }