On Sat, Oct 16, 2004 at 10:08:57AM +0100, Angus Leeming wrote:
> Lars Gullik Bjønnes wrote:
> > This is my test expath code so far.
> > This gives me everything in the file... now I just need to make use of
> > it.
> > 
> > Signal driven.
> 
> Looks good. Also looks like lots still to do.
> 
> Seriously, if you would like some help with this, why not create a branch
> of the cvs tree and check in your work to date. Writing 100 tiny functions
> to handle the generation of each piece of the lyx data structure is going
> to be too boring for one man ;-)

May I suggest a slightly different approach?

Let's have some MetaInset that's  a proper LyX inset, i.e. deriving
from InsetBase, but which mainly acts as a data storage capable to store
attribute and CDATA contents. The parser (expat or whatever) only
generates a tree of these MetaInsets and in a second pass we transform
this into 'real' insets.

There are advantages:

1. We do not depend much on the parser. Setting up the parser->MetaInset
code should be 100 lines or so, so it's easy to switch from one parser
to another. 

2. It will be faster. For highly structured data as we usually have
(unless we are talking about a 500 page novell without any special char
insets or font changes) I think it is safe to promice a factor 3 over
e.g. directly using Qt 3.3's XML classes. Been there, done that. Or
better: Being there, doing that.

3. The MetaInset approach comes in handy for certain transformation that
are useful e.g. in mathed's CAS support, but also for plain writing of
.lyx files because LyX's internal structure is geared towards editing and
not necessarily towards writing files formats.
[Example: \frac is something that contains two other somethings of the
same kind. However, in LyX \frac is _something_ (an Inset) that contains
two _cells_ (MathArrays) which in turn can contain '_somethings_'. This
is sensible because that's about the only way to allow smooth editing of
a denominator from 'empty' (i.e. 'illegal situation') over 'one digit'
(i.e. a simple inset) to 'more than one digits'.]

4. The meta inset appraoch would also help to streamline existing
insets. The MetaInset would have some  'setAttribute(name, value)'
member which would naturally extend to things like
        'InsetCommand::setAttribute("cmdname", cmd)'
instead of 
        'InsetCommand::setCmdName(cmd)'
This in turn should be beneficial for e.g. the frontends which suddenly
have uniform access to all inset attributes.

Andre'

Reply via email to