pingus-devel
[Top][All Lists]
Advanced

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

Re: none


From: Ingo Ruhnke
Subject: Re: none
Date: 15 Aug 2002 13:17:31 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

David Philippi <address@hidden> writes:

> 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).

Having a ->next in a child function causes quite weird behaviour:

<something></something>
<somethingelse></somethingelse>

When I pass a function a pointer to 'something', which should do
something with the content of 'something', I expect it to use the
'something' node, not to jump mysteriously to 'somethingelse', which
it currently does. At best the function shouldn't even have access to
'somethingelse', but as far as I understand libxml one cannot forbit
that. The child function may be freely jump around in the content of
'something' and call xmlIsBlankNode() there, thats ok, but it
shouldn't play around with the something-root-node itself.

> 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?
>   }

ScrollerFactory shouldn't care about the child content, neighter
should ScrollerFactory play around with the root-node.

The problem is that the factories play around with the root-node, not
with the child node. The ->children call refers to the parent node.

<action-axis>   <- this is what the factory caller gets and what the ->children 
is refering to
  <axis-button> <- this is what factory gets and which ->next is called on
  [...]
  </axis-button>
</action-axis>

Anyway, beside this problem we should either add a
JumpToNextNonEmptyNode(xmlNodePtr& cur); or find a way to tell libxml
to skip them automatically. I am currently using a very minimal subset
of libxml functions, so the chances are very good that it provides a
way nice ways to handle this.

-- 
WWW:      http://pingus.seul.org/~grumbel/ 
Games:    http://pingus.seul.org/~grumbel/gamedesigns/
JabberID: address@hidden 
ICQ:      59461927




reply via email to

[Prev in Thread] Current Thread [Next in Thread]