[xml] What does xmlCtxtReadFile() validate?



Hello

I work with the libxml2 version 2.6.11 and my plattform is embedded linux.

I want to validate a xml with his dtd. The example parse2.c use the function

xmlCtxtReadFile() to validate the xml. Does this function really validates the File?

I would say no (or not allways). For me xmlCtxtReadFile() validates the xml on and off.

An example: I used the code from parse2.c.

DTD:

<!ELEMENT ACK.R01 (HDR, ACK)>

<!ELEMENT HDR (HDR.message_type?, HDR.control_id, HDR.version_id,

HDR.creation_dttm, HDR.encoding_chars?)>

<!ELEMENT ACK (ACK.type_cd, ACK.ack_control_id, ACK.note_txt?,

ACK.error_detail_cd?)>

XML_1:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ACK.R01 SYSTEM "ACK.R01.dtd">

<ACK.R01>

<HDR>

<HDR.control_id/>

<HDR.version_id/>

<HDR.creation_dttm"/>

</HDR>

<ACK>

</ACK>

</ACK.R01>

XML_2:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ACK.R01 SYSTEM "ACK.R01.dtd">

<ACK.R01>

<HDR>

</HDR>

<ACK>

<ACK.type_cd/>

<ACK.ack_control_id/>

</ACK>

</ACK.R01>

When validating XML_1, i get 'ctxt->valid = 1'.

When validating XML_2, i get 'ctxt->valid = 0'.

Why?? In both versions required elements are missing!

On xmlsoft.org i have searched for some hints (Releases, Validation & DTD), but i found no detailed information about xmlCtxtReadFile().

Are there changes ( for xmlCtxtReadFile() )between the version 2.6.11 and the latest one?

Can i actual use xmlCtxtReadFile() for dtd-validation or should i better use another function (e.g. xmlValidateDtd () of the modul valid)?

I'am thankful for every help.

best regards,

Ronny Seemann

--

Mit freundlichen Grüssen

Ronny Seemann

mailto: rseemann konplan com



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