There's a lot going on in the patch, can you split it?
If I reorder the patch set as mentioned in my previous message, it should be easier to split this up in a meaningful way. Many of the helper functions would not be required until certain types of data are added to the XML (e.g., attributes).
If the above condition succeeds, then it'll jump to cleanup with
headerElement uninitialized.
Thanks, I'll fix that and will check for any similar instances.
Cheers,
Owen