Re: [xml] (no subject)



Daniel Veillard writes:
On Sun, Sep 28, 2003 at 10:35:57AM -0400, Jim Crafton wrote:
I am using libxml for a docbook editor. I would like to provide  
autocompletion for docbook, such that when you type a "<" character the 
 
editor is able to supply a valid set of tags, and even better, would be 
 
the ability to have the tags correspond with the parent, so you only 
see  
the appropriate tags for where you are at in the document. So I *think* 
 
(I am a bit new to this so bear with me) I can use libxml to read the  
docbook DTD to pull down all the valid tags for docbook. Is this right, 
 
and if so, how do I do this?  I didn't see an obvious samples of this  
(or maybe I missed something. 

  yes
  xmlValidGetValidElements

hmm. This function isn't really suitable for an editor.
It only list's elements, that leave the document valid.
So for a content model like
<!ELEMENT a (b,c)>
and a newly inserted a element, it won't list any apropriate elements,
since <a><b>...</b></a> isn't valid.
Editing requires invalid documents as intermediate states here.

So IMHO there is no simple function in libxml available, that can tell
an editor which elements it should offer for insert at a given position.

xmlValidGetPotentialChildren gives a list of all elements in the content
model of an element, so an editor using this function would suggest
b and c even if b is already inserted.

        Morus



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