Re: [xml] Issue in DTD validation thru Libxml
- From: Daniel Veillard <veillard redhat com>
- To: Senthil S <senthilsambandam hotmail com>
- Cc: xml gnome org
- Subject: Re: [xml] Issue in DTD validation thru Libxml
- Date: Thu, 22 Jan 2004 10:39:19 -0500
On Thu, Jan 22, 2004 at 08:22:50PM +0530, Senthil S wrote:
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);
[...]
when i validate the xml file with the dtd using the above code, it returns 1 which describes xml is valid.
unclear...
paphio:~/XML -> cat tst.xml
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "sample.dtd">
<note>
<from/>
</note>
paphio:~/XML -> cat sample.dtd
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
paphio:~/XML ->
paphio:~/XML -> xmllint --valid --noout tst.xml
tst.xml:5: element note: validity error : Element note content does not follow the DTD, expecting (to , from
, heading , body), got (from )
</note>
^
paphio:~/XML ->
that use the normal DTD validation process, while parsing and raises
the error.
paphio:~/XML -> xmllint --postvalid --noout tst.xml
tst.xml:3: element note: validity error : Element note content does not follow the DTD, expecting (to , from
, heading , body), got (from )
Document tst.xml does not validate
paphio:~/XML ->
That use xmlValidateDtd() post-validation (which is not DTD validation
as defined by the spec).
In both case xmllint, using libxml2 indicates the document is not valid.
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]