0

I am transforming some xml via a Java app. I load the xml with javax.xml.transform.Source

Source src = new StreamSource(getXml());

When the xml is parsed, it tries to load the DTD and some entities:

<!DOCTYPE dmodule SYSTEM "http://mysecureserver/System/DTD/dmodule/proced.dtd"[
 <!NOTATION SWF SYSTEM "">
 <!NOTATION PNG SYSTEM "">
 <!ENTITY % catalog PUBLIC "-//MyCompany//ENTITIES//EN "http://mysecureserver/catalog.pen">
  %catalog;
]>

I get a file IO error because I can not access the file "catalog.pen" with out credentials. Is there a way to pass the credentials to javax.xml.transform.Source?

Also, I can not change the DTD declaration as I don't "own" the xml. I can only read it.

PhillyNJ
  • 3,644
  • 4
  • 35
  • 60

1 Answers1

2

You could use a custom entity resolver to retrieve the files (either by using credentials or by using a cached version of the files). See Java, xml, XSLT: Prevent DTD-Validation for an example.

Community
  • 1
  • 1
erikxiv
  • 3,815
  • 1
  • 22
  • 22