You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Matthias Hopfer <Ma...@eureka.de> on 2008/05/20 14:36:58 UTC

Validating extern DTD on distant server/machine

Hi there,

I'm using xerces-c 2.8.0 without any problems under winxp and vc6.0.

Recently i tried to validate external DTDs which really works fine
unless the path to the DTD-file is stored on a distant server or on a
different machine. The options needed for external validation are set
properly ( ...setValidationScheme ( XercesDOMParser::Val_Always ) and
...setLoadExternalDTD ( true ) ).

For example: 
<!-- -->
<!DOCTYPE message SYSTEM "http://webserver/sample.dtd">
<!-- -->

Will catch an unknown exception during parsing, while
<!-- -->
<!DOCTYPE message SYSTEM "sample.dtd">
<!-- -->

Works fine (assuming that for 1st case the server is running and
accessible and 2nd case the sample.dtd is found in the app's directory).

Is there anything i do wrong or missing? 



Thanks in advance,

Matthias

Re: Validating extern DTD on distant server/machine

Posted by Alberto Massari <am...@datadirect.com>.
Matthias Höpfer wrote:
> Hi Alberto,
>
> Thanks für the hint and sorry for answering this late (indulged myself in some days off =).
>
>     catch ( const NetAccessorException& toCatch ) 
>     {
>         char* message = XMLString::transcode ( toCatch.getMessage() );
> 	  TRACE ( _T("catched NetAccessorException: %s\n"), message );
>         XMLString::release(&message);
> 	  success = -1;
> 	  return success;
>     }
>
> Simply adding a catch block for NetAccessorExceptions seems to work fine. Is this really possible? Are the URL-handlers installed by adding the block? 
>   

No, adding a cacth() block will not change the way Xerces is built or 
initialized; most likely, the server had transient errors (or used to 
redirect your request while now it doesn't).

Alberto

> Matthias
>
>
> -----Original Message-----
> From: Alberto Massari [mailto:amassari@datadirect.com] 
> Sent: Tuesday, May 20, 2008 2:53 PM
> To: c-users@xerces.apache.org
> Subject: Re: Validating extern DTD on distant server/machine
>
> Hi Matthias,
> try adding a try/catch for NetAccessorException to have more informations about the failure. I guess the error could be caused by the HTTP redirecting the client to a different location; in this case you should use the final address, or install an entity resolver to have the possibility to fetch the DTD from file system or by the web server using WinInet functions.
>
> Alberto
>
> Matthias Hopfer wrote:
>   
>> Hi there,
>>
>> I'm using xerces-c 2.8.0 without any problems under winxp and vc6.0.
>>
>> Recently i tried to validate external DTDs which really works fine 
>> unless the path to the DTD-file is stored on a distant server or on a 
>> different machine. The options needed for external validation are set 
>> properly ( ...setValidationScheme ( XercesDOMParser::Val_Always ) and 
>> ...setLoadExternalDTD ( true ) ).
>>
>> For example: 
>> <!-- -->
>> <!DOCTYPE message SYSTEM "http://webserver/sample.dtd">
>> <!-- -->
>>
>> Will catch an unknown exception during parsing, while
>> <!-- -->
>> <!DOCTYPE message SYSTEM "sample.dtd">
>> <!-- -->
>>
>> Works fine (assuming that for 1st case the server is running and 
>> accessible and 2nd case the sample.dtd is found in the app's directory).
>>
>> Is there anything i do wrong or missing? 
>>
>>
>>
>> Thanks in advance,
>>
>> Matthias
>>
>>
>>   
>>     
>
>
>
>   


RE: Validating extern DTD on distant server/machine

Posted by Matthias Höpfer <Ma...@eureka.de>.
Hi Alberto,

Thanks für the hint and sorry for answering this late (indulged myself in some days off =).

    catch ( const NetAccessorException& toCatch ) 
    {
        char* message = XMLString::transcode ( toCatch.getMessage() );
	  TRACE ( _T("catched NetAccessorException: %s\n"), message );
        XMLString::release(&message);
	  success = -1;
	  return success;
    }

Simply adding a catch block for NetAccessorExceptions seems to work fine. Is this really possible? Are the URL-handlers installed by adding the block? 

Matthias


-----Original Message-----
From: Alberto Massari [mailto:amassari@datadirect.com] 
Sent: Tuesday, May 20, 2008 2:53 PM
To: c-users@xerces.apache.org
Subject: Re: Validating extern DTD on distant server/machine

Hi Matthias,
try adding a try/catch for NetAccessorException to have more informations about the failure. I guess the error could be caused by the HTTP redirecting the client to a different location; in this case you should use the final address, or install an entity resolver to have the possibility to fetch the DTD from file system or by the web server using WinInet functions.

Alberto

Matthias Hopfer wrote:
> Hi there,
>
> I'm using xerces-c 2.8.0 without any problems under winxp and vc6.0.
>
> Recently i tried to validate external DTDs which really works fine 
> unless the path to the DTD-file is stored on a distant server or on a 
> different machine. The options needed for external validation are set 
> properly ( ...setValidationScheme ( XercesDOMParser::Val_Always ) and 
> ...setLoadExternalDTD ( true ) ).
>
> For example: 
> <!-- -->
> <!DOCTYPE message SYSTEM "http://webserver/sample.dtd">
> <!-- -->
>
> Will catch an unknown exception during parsing, while
> <!-- -->
> <!DOCTYPE message SYSTEM "sample.dtd">
> <!-- -->
>
> Works fine (assuming that for 1st case the server is running and 
> accessible and 2nd case the sample.dtd is found in the app's directory).
>
> Is there anything i do wrong or missing? 
>
>
>
> Thanks in advance,
>
> Matthias
>
>
>   



Re: Validating extern DTD on distant server/machine

Posted by Alberto Massari <am...@datadirect.com>.
Hi Matthias,
try adding a try/catch for NetAccessorException to have more 
informations about the failure. I guess the error could be caused by the 
HTTP redirecting the client to a different location; in this case you 
should use the final address, or install an entity resolver to have the 
possibility to fetch the DTD from file system or by the web server using 
WinInet functions.

Alberto

Matthias Hopfer wrote:
> Hi there,
>
> I'm using xerces-c 2.8.0 without any problems under winxp and vc6.0.
>
> Recently i tried to validate external DTDs which really works fine
> unless the path to the DTD-file is stored on a distant server or on a
> different machine. The options needed for external validation are set
> properly ( ...setValidationScheme ( XercesDOMParser::Val_Always ) and
> ...setLoadExternalDTD ( true ) ).
>
> For example: 
> <!-- -->
> <!DOCTYPE message SYSTEM "http://webserver/sample.dtd">
> <!-- -->
>
> Will catch an unknown exception during parsing, while
> <!-- -->
> <!DOCTYPE message SYSTEM "sample.dtd">
> <!-- -->
>
> Works fine (assuming that for 1st case the server is running and
> accessible and 2nd case the sample.dtd is found in the app's directory).
>
> Is there anything i do wrong or missing? 
>
>
>
> Thanks in advance,
>
> Matthias
>
>
>