[xml] Probs with xmlCtxtReadFile() !!



Hello

I work with the libxml2 version 2.6.11 on an embedded linux plattform.

The configuration is:

./configure --with-minimum --with-output --with-xpath --with-xinclude --with-tree --with-xptr --with-push --with-sax1 --with-writer --with-reader --with-pattern --disable-static --with-valid --with-html --with-docbook --with-legacy

I want to use xmlCtxtReadFile to validate a xml against his dtd, but it doesn't work and I don't know why.

For tests I used the same code like on "www.xmlsoft.org/examples/parse2.c"

(so I took the right xmlParserOption).

Please take a look to the following example and possibly you could tell me

what´s wrong.

DTD - "ACK.R01.dtd":

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

<!ELEMENT HDR (HDR.message?, HDR.control, HDR.version,

                HDR.creation, HDR.encoding?)>

        

<!ELEMENT ACK (ACK.type, ACK.ack_control, ACK.note?,

                ACK.error_detail?)>

XML_1 - "ACK.R01.xml":

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

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

<ACK.R01>

        <HDR>

                <HDR.control/>

                <HDR.version/>

                <HDR.creation/>

        </HDR>

        <ACK>

        </ACK>

</ACK.R01>

XML_2 - "ACK.R01.xml":

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

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

<ACK.R01>

        <HDR>

        </HDR>

        <ACK>

                <ACK.type/>

                <ACK.ack_control/>

        </ACK>

</ACK.R01>

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

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

Why?? They using the same dtd and in both xml-versions required elements are

missing! So with both xml versions i had to get  'ctxt->valid = 0'. (Or not?)

I also tried

xmllint --valid --noout ACK.R01.xml

from the command line.

With XML_1 I get: no error

With XML_2 I get: ACK.R01.xml:1: element HDR: validity error : Element HDR

content does not follow the DTD, expecting (HDR.message? ,

HDR.control , HDR.version , HDR.creation ,

HDR.encoding?), got ()

</HDR>

^

I tested it with several xml files. Whatever xml-file i take, i get an error only when something is wrong within the first element (in my case HRD).

Does anyone have an idea what is wrong?

I have searched

"http://www.xmlsoft.org/FAQ.html", "http://xmlsoft.org/bugs.html",

"http://www.xmlsoft.org/news.html", "http://www.xmlsoft.org/xmldtd.html",

"http://bugzilla.gnome.org/buglist.cgi?product=libxml2"

for changes in xmlCtxtReadFile since version 2.6.11 too, but i couldn't find

any hints or infos.

thanks and best regards,

Ronny Seemann

--

Mit freundlichen Grüssen

Ronny Seemann

http://www.konplan.com

mailto: rseemann konplan com



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