Using ODF Relax NG schema to generate easier XML writing classes

Thorsten Zachmann t.zachmann at zagge.de
Sat Jun 11 06:52:25 BST 2011


On Friday, June 10, 2011 08:43:39 Jos van den Oever wrote:
> On Friday, June 10, 2011 08:30:36 AM Pierre Stirnweiss wrote:
> > I like the idea.
> > On the headerWriter example you give, the end-element is written when the
> > Writer gets out of scope. We'd need to verify that all our start/end
> > element couples are within the same scope however.
> 
> Yes, i did this on purpose. Extra scopes can be added to force calling of
> the destructor. Alternatively, an endElement() function can be added.
> 
> I would love to know a way to make it impossible to compile code like this:
>   TextPWriter textP1 = textContentWriter.startTextPWriter();
>   TextPWriter textP2 = textContentWriter.startTextPWriter();
>   textP1.writeText("hello");
> 
> At debug time, such errors can be detected by passing a digital baton
> between the classes and reporting an error if a class tries to write
> without having a baton. In the above code, the textP1 would have the baton
> and
> textContentWriiter cannot instantiate a textP2 until it gets back the baton
> when textP1 is destructed. That would add overhead that can disabled in a
> release.
Not sure If I understood correctly but how would that solved stuff of nested 
tags?

Thorsten



More information about the calligra-devel mailing list