I am using below code for transforming the XML based on XSLT using Saxon 10.6. I could get the transformed XML in file. But I need the transformed XML assigned to a string. Kindly help to achieve this.
Source xslt = new StreamSource(new StringReader(inputXSLT));
Source xml = new StreamSource(new StringReader(inputXML));
Processor processor = new Processor(false);
XsltCompiler compiler = processor.newXsltCompiler();
XsltExecutable stylesheet = compiler.compile(xslt);
Serializer out = processor.newSerializer(new File("C:/Users/Abc/books.xml"));
out.setOutputProperty(Serializer.Property.METHOD, "xml");
out.setOutputProperty(Serializer.Property.INDENT, "yes");
Xslt30Transformer transformer = stylesheet.load30();
transformer.transform(xml,out);
CodePudding user response:
use processor.newSerializer(java.io.Writer writer) using a java.io.StringWriter.
