[xml] Validity Checking headache :-(



Hello,

I'm writing this message because of a doubt about the way an application 
should enable and use validity checking.

I have successfully used post-parse checking of the DTD by using 
xmlValidateDocument, but, how may I use parse-time checking ?

This is my test document:

<?xml version="1.0"?>
<!DOCTYPE body [
<!ENTITY xml "Extensible Markup Language">
]>
<body>
<Record>
text1
<Title id="x">
</Title>
text2 and text4
<Title id="&xml;">
&xml;
</Title>
text3
</Record>
</body>

I thought that I had only to set xmlDoValidityCheckingDefaultValue to 1, but 
when I call xmlParseMemory xmlParseMemory returns a doc != NULL.

The following prints are done by the library:

Entity: line 8: validity error: No declaration for attribute id on element 
Title<Title id="x">
             ^
Entity: line 9: validity error: No declaration for element Title
</Title>
       ^
Entity: line 11: validity error: No declaration for attribute id on element 
Title
<Title id="&xml;">
                 ^
Entity: line 13: validity error: No declaration for element Title
</Title>
       ^
Entity: line 15: validity error: No declaration for element Record
</Record>
        ^
Entity: line 16: validity error: No declaration for element body
</body>

The validity problems are recognized by the parser, but, how may I know about 
these ? I think the parser context does not exist anymore after the parsing, 
so they are certainly not accessible anymore from that one.
Do I have to implement a modified version of xmlParseMemory which keeps track 
of the validity returned (if so) into the parser context ? 

Hope this question is clear enough.

Another doubt I have is the following: from the source of xsltproc, I have 
noticed that xmlLoadExtDtdDefaultValue is set depending upon the --novalid 
flag, but xmlDoValidityCheckingDefaultValue is never changed.
Does it mean that xmlDoValidityCheckingDefaultValue is automatically enabled 
when xmlLoadExtDtdDefaultValue is enabled too, or are they totally 
independent ? And if so, why is the DTD loaded at all if not for checking the 
validity of the document ?

TIA

--
Fabrizio Ammollo   




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