开发者

Get DTD from an XML file

开发者 https://www.devze.com 2023-01-01 14:14 出处:网络
How can I get in Java the DTD file name specified in an xml file? So, if I have: <!DOCTYPE TEI SYSTEM \"dtd-file.dtd\"[

How can I get in Java the DTD file name specified in an xml file?

So, if I have:

<!DOCTYPE TEI SYSTEM "dtd-file.dtd"  [
[
<!ENTITY c24r SYSTEM "c2r.jpg" NDATA JPEG>
<!NOTATION JPEG SYSTEM "image/jpeg">
<!ELEMENT figure EMPTY>
<!ATTLIST figure开发者_JAVA百科 entity CDATA #REQUIRED>
]>

I want the string "dtd-file.dtd"


To get the document type's system ID use DocumentType#getSystemId():

Document document = documentBuilder.parse(someXmlInputStream);
String systemId = document.getDoctype().getSystemId();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号