I've found a workaround. If I define an entity resolver to use the systemid 
passed by the parser which is the path specified in the DOCTYPE declaration in 
the XML file (i.e <!DOCTYPE mpd SYSTEM "mpboe03.dtd" ), I can verify the 
accessibility of the file and pass it to the parser to use as an inputsource.

Thanks Alberto

-----Original Message-----
From: Dantzler, DeWayne C 
Sent: Wednesday, November 04, 2009 8:40 AM
To: [email protected]
Subject: RE: How do I get Xerces to find the location of a DTD specified inan 
XML file?

Sorry, I apologize. It was a typo and the name of the dtd in the XML is 
mpboe03. And I'm running Xerces2.7.0, but will be migrating to Xerces3.0.1 very 
soon. So, how does Xerces resolve paths to dtd's in an XML file? Does it 
attempt to look for the file in current directory the application is running 
under or should absolute paths be used?

Thanks 


-----Original Message-----
From: Alberto Massari [mailto:[email protected]]
Sent: Tuesday, November 03, 2009 11:25 PM
To: [email protected]
Subject: Re: How do I get Xerces to find the location of a DTD specified inan 
XML file?

Have you checked that in the same folder there is another DTD named 
mpboe03.dtd? From what you say, it looks you placed mpdjp103.dtd

Alberto


Dantzler, DeWayne C wrote:
>  
> Hello
>
> Scenario: I have a local dtd on my system and I'm running my code in the same 
> directory as the dtd. I thought Xerces would look for the dtd relative to the 
> current directory or if an absolute path is specified, use it. 
>  
> I have an xml file specified as follows:
>
> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mpd SYSTEM 
> "mpboe03.dtd" [ <!ENTITY E67895 SYSTEM "E67895.tif" NDATA ccitt4> 
> <!ENTITY W28741 SYSTEM "W28741.tif" NDATA ccitt4> <!ENTITY W28833 
> SYSTEM "W28833.tif" NDATA ccitt4> .... Rest of xml file
>
>
> I've generated code as follows:
>
>     try
>     {
>               //The parser should use the default DTD called out in the XML 
> file 
>               //by the DOCTYPE declaration to resolve external ENTITY's  
>               //------------- Example given below ------------- 
>               //<!DOCTYPE mpd SYSTEM "mpboe03.dtd" [
>               //<!ENTITY E67895 SYSTEM "E67895.tif" NDATA ccitt4>
>               //<!ENTITY W28741 SYSTEM "W28741.tif" NDATA ccitt4>
>               
>               //Turn on the necessary features to allow validation by an 
> internal DTD
>             //Val_Auto   - turn on validation only if an internal/external 
> DTD subset has been seen!!
>               _XmlDOMParser->setValidationScheme(_XmlDOMParser->Val_Auto);
>               _XmlDOMParser->setDoSchema(false);
>             _XmlDOMParser->parse(xmlDoc);
>     }
>     catch(....ALL EXCEPTIONs)
>  
> Results: I get the following Exception even though the permissions on 
> the dtd is 777 "Parser Error Message: An exception occurred! 
> Type:RuntimeException, Message:Could not open DTD file 'mpboe03.dtd'"
>
> What must I do (syntax or SAX feature) for Xerces to locate the dtd?
>   

Reply via email to