Re: [xml] xmlWriter's indent support: initial patch

Hi Daniel:

 Hum, you're doing something not allowed which is changing APIs:

-xmlNewTextWriterFilename(const char *uri, int compression)
+xmlNewTextWriterFilename(const char *uri, int compression, int indent)

xmlNewTextWriterFilename is a public function, it was released with a given
signature, and changing it is not proper. You must create a new function
to pass the extra argument, that's the drawback of building things pieces by
pieces in a library... The fact that you had to change the example
is a good indication that this can't fly as is :-) .

        Ok, I see... It breaks any code depending on it.

The best is to make
an extra new public function xmlNewTextWriterIndentFilename() and get
xmlNewTextWriterFilename() to call it with indent = 0. The alternative would simply to have a function int xmlTextWriterIndent(xmlTextWriterPtr writer, int indent);
I think it's more in line with ObjectOriented APIs and a better general API.


Also the general usage seems that the default indentation string is
"  " not " ", i.e.  two spaces, not one. I think I would change this

        Nops. It's a single space :)

I would also provide a way to set the indentation like
   int xmlTextWriterSetIndent(xmlTextWriterPtr writer, const xmlChar *str);

        No problem.

Also I don't understand why xmlTextWriterWriteIndent() need to be made public.
What's the purpose ?
        Well... no special purpose. I'll change it.

  I think the API need a bit of refactoring before going in for the reasons
I expose, this keep most of the patch code unchanged. I could do the
change or take a new patch from you, as you prefer...

        If you don't mind, I'd like to implement it. Mainly because I
gonna use xmlWriter API in a large application so I'd like to know its
core, and also it's a good way to learn how to design a professional
class API :)
        I'll do all these considerations you've made.



Lucas Brasilino
brasilino recife pe gov br
Emprel -        Empresa Municipal de Informatica (pt_BR)
                Municipal Computing Enterprise (en_US)
Recife - Pernambuco - Brasil
Fone: +55-81-34167078

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