【发布时间】:2010-10-26 07:40:54
【问题描述】:
我是 XSLT 世界的新手,我基本上是在尝试从 HERE 运行 JSON 转换
但是,如果我使用这种方法:
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource("src\\json\\xml-to-json.xsl"));
transformer.transform(new StreamSource("src\\json\\xmltest.xml"), new StreamResult(new FileOutputStream("birds.out")));
System.out.println(result);
我收到以下错误:
SystemId Unknown; Line #59; Column #127; Could not find function: if
SystemId Unknown; Line #59; Column #127; Extra illegal tokens: 'then', 'http://json.org/', ':', 'create-node', '(', '$', 'input', ',', 'false', '(', ')', ')', 'else', 'http://json.org/', ':', 'create-simple-node', '(', '$', 'input', ')'
SystemId Unknown; Line #59; Column #127; function token not found.
如果我使用 Saxon,由于许可,我宁愿使用 inbuit,但只需调用 main 即可:
String[] args = new String[2];
args[0]="d:\\xmltest.xml";
args[1]="d:\\xml-to-json.xsl";
net.sf.saxon.Transform.main(args);
但我不确定如何在 Java 中实际正确编码(不调用 main),以便我可以存储结果。
干杯
【问题讨论】: