Re: [xml] Differences in DOM parsing on Windows and UNIX?



The problem appears to be that xmlIsMainThread does not work on Solaris.  I
put the following diag messages into the code:

#ifdef HAVE_PTHREAD_H
   result = (mainthread == pthread_self());
   printf ("mainthread = %x, pthread_self() = %x, result = %d\n",
           mainthread, pthread_self(), result);
   return (result);
   /* return(mainthread == pthread_self()); */
   ...

The result of this printf is as follows:

mainthread = 0, pthread_self() = 1, result = 0

Regards,

Ed Day

----- Original Message -----
From: "Stéphane Bidoul" <stephane bidoul softwareag com>
To: "'Ed Day'" <eday obj-sys com>
Cc: <xml gnome org>
Sent: Saturday, October 11, 2003 6:59 AM
Subject: RE: [xml] Differences in DOM parsing on Windows and UNIX?


Well, there is not that much to it.  When the code was as follows:

         xmlInitParser();
         xmlKeepBlanksDefault(0);
         xmlLineNumbersDefault(1);  // set line numbers

         pXmlDoc = xmlParseFile (fileSpec);

         if (0 == pXmlDoc) {
            printf ("Error parsing XML file\n");
            return 1;
         }

         xmlCleanupParser();

I got the blank nodes.  When I changed it to:

         xmlInitParser();
#ifdef LIBXML_THREAD_ENABLED
         xmlThrDefKeepBlanksDefaultValue(0);
#else
         xmlKeepBlanksDefault(0);
#endif
         xmlLineNumbersDefault(1);  // set line numbers

         pXmlDoc = xmlParseFile (fileSpec);

         if (0 == pXmlDoc) {
            printf ("Error parsing XML file\n");
            return 1;
         }

         xmlCleanupParser();

They went away.

I really don't see why it would be different for xmlKeepBlanksDefault
and xmlLineNumbersDefault: all globals are treated equally
in libxml (I'm pretty sure, because that code is actually generated).
You should check again, IMHO.

It really should not be necessary for me to have to deal with
a #define like
LIBXML_THREAD_ENABLED in my mainline code.

If your program has only one thread, you don't need to.
Just have a look at xmllint.c: it only
does xmlKeepBlanksDefault(0) and that does not
depend on LIBXML_THREAD_ENABLED.

Assume test.xml:

<!DOCTYPE a [
<!ELEMENT a (b)>
<!ELEMENT b EMPTY>
]>
<a>
    <b/>
</a>

~>xmllint --noblanks test.xml
<?xml version="1.0"?>
<!DOCTYPE a [
<!ELEMENT a (b)>
<!ELEMENT b EMPTY>
]>
<a><b/></a>

If your program has several threads, either
do xmlThrDefKeepBlanksDefaultValue() before creating
your threads or do xmlKeepBlanksDefault() in each thread.

-sbi

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml





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