[xml] [libxml1] handling of (xmlDocPtr)doc->encoding upon save ?

Me again,

        libxml2 has the xmlSaveFileEnc(), which allows to specify the
encoding to be used upon saving the file. IIRC, if the encoding parameter is
given, even if it's set to "UTF-8", then it the EncodingDecl will be written
        libxml1 has an explicit check in xmlSaveFile(), so that if
doc->encoding equals "UTF-8", there will be no EncodingDecl output.

It would be good if :
        1) libxml1 provided 
                xmlSaveFileEnc(const char *filename,
                               xmlDocPtr doc, const char *enc) {
                     doc->encoding = enc;
        2) libxml1's behaviour was aligned on libxml2 in that aspect (ie, if
doc->encoding is NULL, don't write the EncodingDecl ; if doc->encoding is
set to anything, write it out, even if it's an explicit UTF-8) (it's a check
in xmlDocContentDump, which just has to be removed).

I've been able to make libxml1 produce documents with an explicit
encoding="utf-8" (note the lower case) declaration, which is almost fine 
according to section 4.3.3 of XML 1.0, but well, I would be much quieter if
either (2) was done, or at least a promise of not changing current

        -- Cyrille


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