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



In investigating this further, I found we built the Windows
version without
thread support and the UNIX version with thread support.  I
also found we
were intentionally trying to turn blank text nodes off by
making a call to
"xmlKeepBlanksDefault(0)" to make the DOM tree easier to work with.
Apparently this does not work in multi-threaded mode.  There
appears to be
another call - "xmlThrDefKeepBlanksDefault" - that must be
used in this
case.  But, this seems to be compiled out if threads are not
enabled.  We
therefore ended up with the following initialization logic in
our main code:

#ifdef LIBXML_THREAD_ENABLED
         xmlThrDefKeepBlanksDefaultValue(0);
#else
         xmlKeepBlanksDefault(0);
#endif

Kind of messy.  It would seem this could be kept under the
covers somewhere
(or perhaps it is and we missed it).

Globals are per threads when libxml2 is compiled --with-threads.
xmlThrDefKeepBlanksDefaultValue sets the value for new threads
that will be created later. xmlKeepBlanksDefault sets the value
for the current thread only. Assuming you are doing that at
program initialization, you should do

#ifdef LIBXML_THREAD_ENABLED
         xmlKeepBlanksDefault(0); /* for the "main" thread */
         xmlThrDefKeepBlanksDefaultValue(0); /* for other threads yet to be
created */
#else
         xmlKeepBlanksDefault(0);
#endif

You can also avoid global defaults in most cases.
I think you can set keepBlanks on the parser context.

-sbi




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