[xml] best strategy for automatically supplying a top-level element?

I'm designing a commercial XML-based language for document interchange (don't ask ;-) called UFO (unified/universal formatting objects). I'm a complete libxml newbie, though a real industry oldie (35 years, almost--ouch), and trying to get up to speed quickly.

For various reasons ("practicality beats purity", to steal a Python idiom) I need to auto-supply a top-level element wrapper (<ufo> ... </ufo>) if it's not supplied by the input.

Is the best way to do this to use the push interface to the parser, reading the first 1K or so and (skipping any <?xml...?> declaration and other PI's), inserting the initial <ufo> if missing and the final </ufo> later if ditto?

That seems like the simplest method, and avoids using the i/o buffer callback machinery.

Ideas? Brickbats? ;-) Thanks.

--Chris Ryland / Em Software, Inc. / www.emsoftware.com

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