Using ODF Relax NG schema to generate easier XML writing classes

Jos van den Oever jos at vandenoever.info
Fri Jun 10 07:52:00 BST 2011


On Friday, June 10, 2011 08:42:46 AM Thorsten Zachmann wrote:
> Hello,
> 
> On Friday, June 10, 2011 08:22:04 Jos van den Oever wrote:
> > Here is an idea to improve code quality in Calligra.
> > 
> > Currently, we use KoXmlWriter to write ODF XML. For this, functions like
> > startElement, endElement, addAttribute are used.
> > 
> > By using the Relax NG schema, we could generate a wrapper around this
> > class which would give us functions like
> > 
> >  TextPWriter TextContentWriter::startTextP();
> >  void TextHWriter::writeTextOutlineLevel(quint32 level);
> 
> I don't really like this approach. We will end up with quite a lot of
> classes which all have very different methods. And my IDE (vi) will not
> help me with that. Also the classes can get very big for some tags as a
> lot of attributes are allowed. And it will make it not possible to add
> custom attributes as used in some cases.
All names are derived with camelcasing the information in normal calls. So you 
do not need to know more then you do now. Yes, the classes will be diverse and 
many, but this has no runtime consequenses except in debug binaries.

An additional idea is that required attributes can go in the start calls, e.g.
 startTextH(outlinelevel)

You can still use custom attributes. We currently attributes and elements: we 
have a OpenDocument-v1.2-cd05-schema-koffice.rng which we use for testing. 
Itadds our extensions on top of the official rng. That is the one we would use 
to generate the wrappers. This way, the extensions that calligra uses are easy 
to find.

> I would much more prefer that we increase our automated testing to find
> this problems. That should be fairly easy to do. Also if integrated into
> the stuff Cyrille is doing it should work quite nicely to not allow moving
> to master- verified when e.g. invalid odf is produced. We need a way to
> define the additional tags that we want to use.
> 
> Thorsten
> _______________________________________________
> calligra-devel mailing list
> calligra-devel at kde.org
> https://mail.kde.org/mailman/listinfo/calligra-devel



More information about the calligra-devel mailing list