0
I이 루트 요소 전에 처리 명령 삽입 다음 코드 :직렬화 XML 처리 명령
Document doc = builder.parse(file);
doc.insertBefore(
doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"annotation.xsl\""),
doc.getDocumentElement());
doc.insertBefore(doc.createProcessingInstruction("oxygen", "NVDLSchema=\"annotation.nvdl\""),
doc.getDocumentElement());
을 내가 직렬화하려면이 옵션을 사용
FileOutputStream fos = new FileOutputStream(new File(file.getAbsolutePath() + ".out"));
DOMImplementationLS ls = (DOMImplementationLS) builder.getDOMImplementation();
LSOutput lso = ls.createLSOutput();
lso.setByteStream(fos);
ls.createLSSerializer().write(doc, lso);
fos.close();
출력 I로 얻으십시오 :
<?xml version="1.0" encoding="UTF-8"?>
<fulltext-document>...</fulltext-document><?xml-stylesheet type="text/xsl" href="annotation.xsl"?><?oxygen NVDLSchema="annotation.nvdl"?>
그러나 처리 지침을 가지고 있습니다. 전에 루트 요소. 아마도 DOM 3이 올바르지 않다고 확인했지만 (아래 참조) 모든 것이 정상적으로 보입니다. 제가 놓친 것이 있습니까? 모든 해결책을 환영합니다.
P. Java 1.6.0_27 DOM을 사용합니다. 위의 내용이 버그처럼 보이면 버그 리포트에 대한 링크를 환영합니다. 이 (하지만, 버그 리포트를 찾을 수 없습니다) 고정 버그 그래서
우아한 솔루션을 이용해 주셔서 감사합니다. –