我正在从ibm队列中读取一些xml文件,并且更新到版本9时,我尝试使用下面的代码在 (transformer.transform(source, outputTarget);
行中将xml转换为csv时开始出现异常。
File stylesheet = new File("src/howto.xsl");
File xmlSource = new File("src/howto.xml");
DocumentBuilderFactory factory1 = DocumentBuilderFactory.newInstance();
DocumentBuilder builder1 = factory1.newDocumentBuilder();
Document document1 = builder1.parse(xmlSource);
StreamSource stylesource = new StreamSource(stylesheet);
Transformer transformer = TransformerFactory.newInstance().newTransformer(stylesource);
Source source = new DOMSource(document);
Result outputTarget = new StreamResult(new File("/temp/howto.csv"));
transformer.transform(source, outputTarget);
System.out.println("Done.");
在客户机上的队列服务器中使用了相同的jdk和ibm库
File stylesheet = new File("src/howto.xsl");
File xmlSource = new File("src/howto.xml");
DocumentBuilderFactory factory1 = DocumentBuilderFactory.newInstance();
DocumentBuilder builder1 = factory1.newDocumentBuilder();
Document document1 = builder1.parse(xmlSource);
StreamSource stylesource = new StreamSource(stylesheet);
Transformer transformer = TransformerFactory.newInstance().newTransformer(stylesource);
Source source = new DOMSource(document);
Result outputTarget = new StreamResult(new File("/temp/howto.csv"));
transformer.transform(source, outputTarget);
System.out.println("Done.");
我能够读取xml文件并将其保存在本地,但是出现以下异常:
无法初始化类 com.sun.org.apache.xml.internal.serializer.Encodings2019年7月10日 11:24:00 AM MST,错误](ItemMasterMQRawMat.java:read():388)-read()- XPathExpressionException-> java.lang.NoClassDefFoundError:无法 初始化com.sun.org.apache.xml.internal.serializer.Encodings类