我正在嘗試使用 Dom4J 2.1.1 將實體聲明添加到 Java 中的 XML 文檔,但不知道如何執行此操作,或者是否可能這樣做。有人可以幫忙嗎?<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE TEAMS_ASSET_FILE PUBLIC "-//TEAMS//DTD asset and link file//EN" "D:\Apps\data\Tasset.dtd" [<!ENTITY asset0000001 SYSTEM "Z:\somepath\1234\myfile.pdf"><!ENTITY asset0000002 SYSTEM "Z:\anotherpath\5678\another.pdf">]><content>...</content>
1 回答

RISEBY
TA貢獻1856條經驗 獲得超5個贊
請參閱 DocumentType-Interface [ https://dom4j.github.io/javadoc/2.1.1/org/dom4j/DocumentType.html]。通過使用獲取它 DocumentType docType = doc.getDocType();
,然后使用 setExternalDeclarations(java.util.List<Decl> declarations)
或 將實體添加為InternalEntityDecl/ExternalEntityDeclsetInternalDeclarations(java.util.List<Decl> declarations)
添加回答
舉報
0/150
提交
取消