error with libxml parser



Hi
I have a little problem with the LibXML2, can you please help me? (windows XP, Visual C, Libxml2)
The situation is the following: I have xml-document and external dtd-table for it. The Code1 reads DTD and returns error while Code2 reads and does not return error, but gives error "No declaration for element" on validation. And the Code3 validates successfuly.
but I need to use code1 or code2, where should I use an external file test.dtd.
The question is:
Why parser returns dtd error in Code1 and Code2 while dtd is correct?
i've check dtd file whith Altova XMLSpy
if i take more dufficult xml and dtd documents - the parser returns error in dtd file
Can you help me to correct this situation?
PS - XML and DTD are attached
 
code1
doc_dtd=xmlParseDTD(NULL,(const unsigned char *)"test.dtd");
if (doc_dtd == NULL) {
fprintf(stderr,"empty document\n");
return 0;}
 
code2
dtd = xmlGetIntSubset(doc);
if (!dtd) {
fprintf(stderr,"document\n");
return 0;
}
...
xmlValidCtxt cvp;
cvp.userData = (void *) stderr;
cvp.error = (xmlValidityErrorFunc) fprintf;
cvp.warning = (xmlValidityWarningFunc) fprintf;
int RetVal = xmlValidateDtd(&cvp, doc, dtd);
 
code3
const char *mem = "<!ELEMENT ECHO-DOCUMENT EMPTY>";
buf = xmlParserInputBufferCreateStatic (mem, strlen(mem),XML_CHAR_ENCODING_ASCII);
dtd = xmlIOParseDTD (NULL, buf, XML_CHAR_ENCODING_ASCII);
ctx = xmlNewValidCtxt();
if( xmlValidateDtd(ctx, doc, dtd) )
{
xmlFreeValidCtxt(ctx);
xmlFreeDtd(dtd);
return 1;
}
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<!DOCTYPE ECHO-DOCUMENT SYSTEM 'test.dtd'>
<ECHO-DOCUMENT>
		<Patient FirstName='Ð?еÑ?Ñ?ов' LastName='ZXCV'/>
	<ToneAudiograms>
		<ToneAudiogram Name='ToneAudiogram01' Binaural='False' Fixed='False' Type='HTL' USH='HeadPhone' FreqRange='Low' StimType='Tone' StimMode='Cont'>
			<ToneCurve Later='Right' ColorIndex='1'>
				<TonePoint Freq='1000' Intens='45' StimType='Tone' StimMode='Cont' Response='Yes'/>
				<TonePoint Freq='2000' Intens='55' StimType='Tone' StimMode='Cont' Response='Yes'/>
				<TonePoint Freq='4000' Intens='65' StimType='Tone' StimMode='Cont' Response='Yes'/>
				<TonePoint Freq='6000' Intens='70' StimType='Tone' StimMode='Cont' Response='Yes'/>
			</ToneCurve>
		</ToneAudiogram>
	</ToneAudiograms>

</ECHO-DOCUMENT>

Attachment: test.dtd
Description: application/xml-dtd



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]