Re: [xml] Differences in DOM parsing on Windows and UNIX?
- From: "Ed Day" <eday obj-sys com>
- To: <xml gnome org>
- Subject: Re: [xml] Differences in DOM parsing on Windows and UNIX?
- Date: Tue, 7 Oct 2003 10:16:43 -0400
As a follow-up, I do not see why this logic cannot be embedded in
xmlKeepBlanksDefault:
int
xmlKeepBlanksDefault(int val) {
int old = xmlKeepBlanksDefaultValue;
xmlKeepBlanksDefaultValue = val;
xmlIndentTreeOutput = !val;
/* add this here.. */
#ifdef LIBXML_THREAD_ENABLED
xmlThrDefKeepBlanksDefaultValue(val);
#endif
return(old);
}
Is there any use case where it would make sense for the value to be
different in the main thread then in the newly created threads?
Regards,
Ed Day
----- Original Message -----
From: "Ed Day" <eday obj-sys com>
To: "Stéphane Bidoul" <stephane bidoul softwareag com>
Cc: <xml gnome org>
Sent: Tuesday, October 07, 2003 9:30 AM
Subject: Re: [xml] Differences in DOM parsing on Windows and UNIX?
Hi Stephane,
As far as I know, I only have a main thread in my program. It is not
multi-threaded. But "xmlKeepBlanksDefault(0)" did not turn off blanks in
the main thread.
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: Monday, October 06, 2003 5:48 PM
Subject: 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
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
_______________________________________________
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]