Re: [xml] DTD validation not restrictive enough?



Jarek Dukat writes:
...
I use xmlValidateDtd() function and it returns status that file is ok 
even when <bar>...</bar> is missing in the document. Can I change some 
validation options to fix this behavior or it is a bug in the library?

Well, the basic rule is, if a problem doesn't show up, with xmllint,
it's most probably due to an inapropriate usage of the library.

cat ~/x.xml
<?xml version="1.0"?>
<!DOCTYPE foo [
<!ELEMENT foo (bar)>
<!ELEMENT bar (#PCDATA)>
]>
<foo>foo</foo>

./xmllint --valid ~/x.xml
/home/morus/x.xml:6: element foo: validity error : Element foo content does not follow the DTD, expecting 
(bar), got (CDATA)
<foo>foo</foo>
              ^
./xmllint --version
lt-xmllint: using libxml version 20602
   compiled with: DTDValid FTP HTTP HTML C14N Catalog XPath XPointer XInclude Iconv Unicode Regexps Automata 
Schemas 

I'm not familiar enough with the C API to guess what might be wrong in your
code, but you might have a look at xmllints sources, to see how validation 
is done.

HTH
Morus



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