zipfile zip エントリからの入力ストリームを解析して org.w3c.dom.Document を作成しようとしていますが、何らかの理由で DefferedDocumentImpl を取得しています。新しい org.w3c.dom.Document も作成していますが、これは DocumentImpl を返しています。次に、Xpathを使用して単一のノードを選択しますが、特定のノードを見つけようとすると、「org.apache.xerces.dom.DocumentImplはorg.jdom.Elementと互換性がありません」というエラーが発生します。私はいくつかの検索を行いましたが、例が見つからないようです。私のドキュメントがdomドキュメントとして作成されない理由を知っている人はいますか? 助けてくれてありがとう。
//create a zip file from the crate location
File downloadFile = crate.getLocation();
ZipFile zipFile = new ZipFile(downloadFile);
//put all the contents of the zip file into an enumeration
Enumeration entries = zipFile.entries();
while (entries.hasMoreElements()){
ZipEntry entry = (ZipEntry) entries.nextElement();
String currentEntry = entry.getName();
if (currentEntry.equals("ATTACH 8130-3 XML/signature.xml")){
InputStream zipStream = zipFile.getInputStream(entry);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
org.w3c.dom.Document doc = (org.w3c.dom.Document)dBuilder.parse(zipStream);
doc.getDocumentElement().normalize();
NodeList certNode = doc.getElementsByTagName("ATA_PartCertificationForm");
int testInt = certNode.getLength();
org.w3c.dom.Document doc2 = (org.w3c.dom.Document) dBuilder.newDocument();
Node parentNode = doc.getParentNode();
Element rootElement = doc2.createElement("CurrentCertificate");
doc2.appendChild(rootElement);
for(int i=0; i<certNode.getLength(); i++){
Node childNode = certNode.item(i);
Element childElement;
childElement = (Element)certNode.item(i);
rootElement.appendChild(doc2.importNode(childNode, true));
String nameString = childNode.getNodeName();
Element block13Element = (Element) XPath.selectSingleNode(doc2, "//Block13M");
System.out.println("tester test");
}
System.out.println("Test break");
}
}