Re: [xml] Interactive node insertion

Date view Thread view Subject view Author view

From: Mathias Hasselmann (Mathias.Hasselmann@gmx.de)
Date: Mon Oct 04 1999 - 11:53:12 EDT


Mathias Hasselmann wrote:
>
> Daniel Veillard wrote:
> >
> > > After parsing and validating a xml file I would like to insert new
> > > elements interactivly without breaking the validated tree.
> > >
> > > Since users don't have to know the DTD I need a way to find out, which
> > > insertions are allowed for a selected elements.
> > >
> > > Is there a common way to do this?
> >
> > Hum, no, and that's a good point.
> > I added validation to the parsing step, but it's not really glued in
> > the tree manipulation functions yet.
> >
> > Would something like:
> >
> > int xmlIsValidChild(const xmlChar *parent, const xmlChar *child);
> >
> > suit your needs, or does something more prospective like returning
> > the list of valid child be more useful. In the later, I'm afraid it
> > won't be really more easy to use/remap the existing list based functions
> > and switch to arrays. All advanced structured editors I have seen in
> > the past were "guiding" the user with a list of possible childs. So
> > the second kind of function would still be useful.
>
> The second function is similar to that what I want. But since we have
> xmlGetDtdElementDesc the list easily could be build by walking through
> xmlElement::children and calling xmlIsValidChild for each (unique)
> name. (We simply would need xmlIsValidChild.)
>
> BUT at least I would need something more specific functions:
>
> * int xmlIsPrependable (xmlNode element, const xmlChar *new_element);
> * int xmlIsValidReplacement (xmlNode element,
> const xmlChar *new_element);
> * int xmlIsAppendable (xmlNode element, const xmlChar *new_element);
>
> (xmlIsValidChild implemented by using such functions,
> xmlGetValidChilds too...)
>
> Probably you find a function declaration more generical than this,
> but since DTD are quite powerfull I think we have to separate the
> cases mentioned...

Probably that could work:

  GSList*/char** xmlGetValidElements (xmlNode after, xmlNode behind);

   * to insert before 'node':

        xmlGetValidElements (node->prev, node);

   * to insert behind 'node':

        xmlGetValidElements (node, node->next);

   * to insert replace 'node':

        xmlGetValidElements (node->prev, node->next);

   * to prepend a child to 'node':

        xmlGetValidElements (NULL, node->childs);

   * to append a child to 'node':

        xmlGetValidElements (node->last, NULL);

To the only problem to me is how to implement xmlGetValidElements...

Ciao,
Mathias

-- 
WWW: http://www.arco.de/~mhasselm/ http://www.dominanz-haus.de/
PGP-Fingerprint: 4D15 89ED 7299 6428 FEE6  C66F 5D40 6504 55E5 72F3
----
Message from the list xml@rufus.w3.org
Archived at : http://rufus.w3.org/veillard/XML/messages
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rufus.w3.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:29:48 EDT