tags:

views:

24

answers:

1

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 entity CDATA #REQUIRED>
]>

I want the string "dtd-file.dtd"

+1  A: 

You want to get the document type's system ID? Use DocumentType#getSystemId() for this.

Document document = documentBuilder.parse(someXmlInputStream);
String systemId = document.getDoctype().getSystemId();
BalusC
thank you Balus!
Gabriele
You're welcome.
BalusC