[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: none
From: |
David Philippi |
Subject: |
Re: none |
Date: |
Thu, 15 Aug 2002 12:11:01 +0200 |
User-agent: |
KMail/1.4.1 |
On Wednesday 14 August 2002 17:26, Ingo Ruhnke wrote:
> Factories must not jump around in the XML tree, they should work on
> the node they get and fail if it is an empty one. Since the above kind
> cause quite funny and hard to track down errors, like this one:
> AxisFactory::create(cur);
> AxisFactory::create(cur->next);
Taking a look into the code I've found the reason why the factories check for
empty nodes. While I still consider a create(cur->next) ugly, I do call them
using create(cur->children) after I've found the start of the section.
As long as we don't want to enforce a very strict syntax in the config file
it's quite possible that a factory will be called with an empty node first
this way (as far as I understand libxml).
In order to change this, I'd have do step down into cur->children itself to
check for empty nodes and then call the factory.
I dislike this for two reasons:
1) the controller shouldn't be interested in what's inside a <scroller> tag
2) I don't know how to get back to the parent using clean code
I won't write code like
if ( ! strcmp(reinterpret_cast<const char*>(cur->name), "scroller"))
{
cur=cur->children;
while (xmlIsBlankNode(cur))
cur = cur->next;
scroller = ScrollerFactory::create(cur);
cur=cur->parent; // does this exist?
}
only to avoid a xmlIsBlankNode inside the factory. In my opinion a factory
should be able to deal with a
<scroller>
<some-scroller>
</scroller>
itself. It's not that it really does jump around in the tree, it's starting
point is the node below <scroller> and it won't ever touch anything above.
Bye David
- Re: none, Ingo Ruhnke, 2002/08/14
- Re: none, David Philippi, 2002/08/15
- Re: none,
David Philippi <=