[EMAIL PROTECTED] wrote:
Hi
I have a task that takes in various types of XML messages and evaluates
XPath expressions. Im now using input messages that have been produced
with a DTD and start with the following:
<?xml version="1.0"?>
<!DOCTYPE MxML SYSTEM "test.dtd">
When I try and parse the message I get the following error:
Fatal Error.Occurred at file SourceXML , line 2 , column 34. An
exception occurred! Type:RuntimeException, Message:Could not open DTD
file 'test.dtd'
...
Ive tried housing the test.dtd in the directory where the executable is
run, but have had no joy. If I change the input msg to use the full
path to the dtd it works OK - however that is not really an option as
the message will be coming from an external source.
I could extract that component of the message before parsing, but would
prefer to preserve the msg in it's entirety. Is there anyway to switch
off the parsing of the dtd?
You can, but it's not recommended, since the DTD may contain entity
definitions that are required to parse the document. Since the parser
uses the system ID of the input document to resolve relative URLs, make
sure the system ID of the XSLTInputSource is correct.
If the document is not located on a file system, or it's in a different
location, you can implement the EntityResolver class and install an
instance into the XalanTransformer instance you're using. You should
take a look at the Xerces-C documentation for more information.
Dave