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




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