[xml] Issue in DTD validation thru Libxml



Hello everybody,
                      I am new to this forum.I need a great help from this forum.
Actually i am using libxml 2.2.6  for creating dom(xmldocptr)  in unix environment.I have a DTD file already existing in file format.I need to validate the DTD with the dom.
 
The following is the code construct:
 
 doc = xmlReadFile("sample.xml", NULL, 0);
 dtd = xmlParseDTD(NULL,"sample.dtd" ); /* parse the DTD */
 valid=xmlValidateDtd(&cvp, doc, dtd);
 
the input sample.xml is
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "sample.dtd">
<note>
 <from/>
</note>
 
sample.dtd
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
 
when i validate the xml file with the dtd using the above code, it returns 1 which describes xml is valid.
 
To my understanding of xml, it should be invalid as the to,from,heading are sequence children to note element.
Could anybody help me to resolve this issue using libxml?
 
Thanks,
S.Senthil
 
 
 
 


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