'Re: [xml] "Control over encoding declaration (prolog and meta)'



Hi,

on 1/14/2004 6:27 PM Daniel Veillard wrote:
On Wed, Jan 14, 2004 at 05:28:55PM +0100, Kasimier Buchcik wrote:

I'm trying to serialize documents to UTF-16LE, with full control over 
the prolog - I need the encoding declaration to differ from the target 
encoding. Doing so I used the static function "xmlDocContentDumpOutput" 
as a template, the prolog is constructed and "xmlNodeDumpOutput" is 
called (with the target encoding) on every child of the document node. 
It works all fine except for one case: if the document is a XHTML 
document, "xmlNodeDumpOutput" calls "xhtmlNodeDumpOutput", this sets the 
meta encoding (with "htmlSetMetaEncoding") to the target encoding. Here 
I lose the control over the declared encoding.

[...]

Are there any other possibilities to gain full control over the encoding 
declaration if serializing?


  There is far more simple. Redefine the encoding handler for the advertized
encoding declaration and provide the functions generating the bits you want !
   http://xmlsoft.org/html/libxml-encoding.html#xmlNewCharEncodingHandler
   and
   http://xmlsoft.org/html/libxml-encoding.html#xmlRegisterCharEncodingHandler
user provided handler will override the default ones. And you won't have
to make all this mess or change the code.

  http://xmlsoft.org/encoding.html#extend

Would this approach be thread-save? I would expect this procedure to 
temporarily change the encoding handler for e.g. ISO-8859-1 to UTF-16LE, 
but if I'm serializing an other document to ISO-8859-1 at the same time, 
I would get false results. Or is the registration of encoding handlers 
somehow implemented per-thread like?


Thanks,

Kasimier




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