我正在使用Saxon9-HE使用XSLT将XML转换为JSON。我遵循了Saxon website中的指示:
Processor processor = new Processor(false);
XsltCompiler compiler = processor.newXsltCompiler();
XsltExecutable stylesheet = compiler.compile(new StreamSource(new File("styles/books.xsl")));
Serializer out = processor.newSerializer(new File("data/books.json"));
out.setOutputProperty(Serializer.Property.METHOD, "text");
out.setOutputProperty(Serializer.Property.INDENT, "yes");
Xslt30Transformer transformer = stylesheet.load30();
transformer.transform(new StreamSource(new File("data/books.xml")), out);
输出文件的第一行是这样的:
books3245.02019-05-20 11:23:33{
我真的很想在输出中使用此文件名和时间戳。