Re: [xml] Whitespace problem with external DTD validation

Date view Thread view Subject view Author view

From: Bill Kendrick (William.Kendrick@wcom.com)
Date: Tue Oct 10 2000 - 17:50:29 EDT


On Tue, 10 Oct 2000 14:27:12 Daniel Veillard wrote:
>
> On Mon, Oct 09, 2000 at 04:47:08PM -0700, Bill Kendrick wrote:
> >
> > In other words, the difference between:
> >
> > <tag1>foo</tag1>
> > <tag2>bar</tag2>
> >
> > and:
> >
> > <tag1>foo</tag1><tag2>bar</tag2>
> >
> >
> > The validator accepts the latter (no whitespace between tags),
> > but complains about the former (whitespace between tags).
> >
> <snip>
> >
> > At this point (I just started working with XML and DTD's last
> > Friday ;) ), I don't know much, but I ASSUME either the problem
> > is a bug, or there's some "ignore whitespace between tags" flag
> > to set somewhere, or something...
>
> Okay here is the answer ....
> What you are doing is
> 1/ parsing without a DTD
> 2/ trying to validate the result using a DTD.
> instead of
> 3/ parsing an validating at the same time
>
> What's happening ???
> Simply that during 1/ when the XML parser see </p> <p>
> it can't say for sure whether those blanks are significant or not,
> and by default it keeps them as text nodes in the tree. Then in 2/
> the parser see extra text nodes and barfs because it doesn't expect
> PCDATA there.
>
> Solutions:
> Quick: use 3/ add
> xmlDoValidityCheckingDefaultValue = 1;
> before calling the parser and the XML parser will automatically
> validate

Well, the XML documents do not have DTDs embeded in them (they will be
coming over a network connection from a Point of Sale client device).

I tried what you suggested ("xmlDoValidityCheckingDefaultValue = 1;"
before my call to xmlParseFile()"), and now I get errors during
the loading, AND still getting the same error about whitespace!!! <:^(

  test-with-whitespace.xml:3: validity error: Validation failed: no DTD found !
  <List>
       ^
  Element List content doesn't follow the Dtd
  Expecting (Item)+, got (CDATA Item CDATA Item CDATA Item CDATA)
  test-with-whitespace.xml: invalid

The example code I'm writing is less than 250 lines long, and the XML and
DTD files are 14 lines long, total.. May I email them all to you so you can
see exactly what I'm trying to do and you can point out my errors? :)

> Serious: the code doing the validity checking in valid.c should attempt to
> detect those unsignificant white spaces in the tree and avoid
> generating validity errors for them

Are there plans to implement this? The project must be up and running
by October 27th. :)

-bill!
William.Kendrick@wcom.com
ext 6218

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Oct 10 2000 - 18:43:16 EDT