我有两个 Java 项目的副本。
运行此方法后:
private void editArtifactWSDL() {
try {
File outputfile = new File(
"C:\\WorkSpace\\CMU\\WebContent\\WEB-INF\\bpelfiles\\process\\Artifacts.wsdl");
File skeletonFile = new File(
"C:\\WorkSpace\\CMU\\WebContent\\WEB-INF\\bpelfiles\\SkeletonArtifacts.wsdl");
DocumentBuilderFactory docFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(skeletonFile);
Element definitionsElement = doc.getDocumentElement();
// xmlns attributes
editDefinitionsElementToArtifact(doc, definitionsElement);
// partnerLinkType elements
appendPartnerLinkTypeElementsToArtifact(doc, definitionsElement);
// import elements
appendImportElementsToArtifact(doc, definitionsElement);
// write the content into xml file
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(outputfile);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(
"{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(source, result);
System.out.println("Artifact.wsdl saved!");
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (TransformerException tfe) {
tfe.printStackTrace();
} catch (SAXException sxe) {
sxe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
在其中一个项目中,我得到了“干净” Artifacts.wsdl
。在另一个项目中,我 xmlns=""
添加了一些元素。
SkeletonArtifacts.wsdl 完全相同(在http://www.diffnow.com/上进行比较)
那么这种随机行为的原因是什么,我是否摆脱了 xmlns 属性?