Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug in TXMLDocument?

93 views
Skip to first unread message

Jeff Rafter

unread,
Aug 28, 2002, 8:17:50 AM8/28/02
to
> Shouldn't whitespaces ignored by XML parsers, should they?

Not always-- sometimes it is very important. You should be abnle to call
normalize to eliminate adjacent nodes. Also, some parsers require validation
mode to know whether or not whitespace is ignorable. As another solution you
can turn off indentation for the output and the problem will go away. If it
is a for loop that is giving a problem just check the nodeType.

HTH,

--
Jeff Rafter
Defined Systems
http://www.defined.net
XML Development and Developer Web Hosting


Uwe Fechner

unread,
Aug 29, 2002, 12:55:35 AM8/29/02
to
Rolf Baenziger wrote:

> Shouldn't whitespaces ignored by XML parsers, should they?

As far as I know, whitespace are ignored, if you use the
following code:

type
doc: IDomDocument;

(doc as IDomParseOptions).preserveWhiteSpace:=false;
(doc as IdomPersist).load('filename');

At least this works with libxmldom.pas and with msxml.

I am not shure, it it works with TXMLDocument, too.

If it doesn't, you could still right a procedure that removes
all whitespace nodes from the document, after you have parsed
it.

Regards:

Uwe

Mark Edington (Borland)

unread,
Aug 30, 2002, 8:12:18 PM8/30/02
to
> Shouldn't whitespaces ignored by XML parsers, should they?

Which DOM Vendor are you using? Is poPreserveWhitespace false on the
TXMLDocument component? MSXML and OpenXML both support ignoring the
formatting whitespace #text nodes. The Xerces parser included with Delphi 7
or Kylix 3 doesn't support ignoring whitespace by default. If that is what
you are using then you can enable it by setting a property on the global
XercesDOM variable in the xercesxmldom.pas unit like this:

uses
xercesxmldom;

initialization
XercesDOM.EnablePreserveWhitespace(True);

With that set, the poPreserveWhitespace option on TXMLDocument will be
respected (if False). Be aware this is a post-parse operation and will have
performance implications for larger documents. There is basically a
recursive routine that removes the formatting nodes after the fact. Xerces
does not support ignoring formatting whitespace like MSXML does.

Mark


<rolf.baenziger[at]no_spam.remove.franke.com>" <

unread,
Sep 4, 2002, 9:45:34 AM9/4/02
to
Mark Edington (Borland) wrote:
>>Shouldn't whitespaces ignored by XML parsers, should they?
>
> Which DOM Vendor are you using?

MSXML

> Is poPreserveWhitespace false on the
> TXMLDocument component?

Was not! With ParseOptions = [poPreserveWhitespace] it works fine!

thx
Rolf

0 new messages