[xml] Comments from a LibXml newbie

Date view Thread view Subject view Author view

From: Leo Davidson (leo@ox.compsoc.net)
Date: Mon Oct 16 2000 - 05:51:56 EDT


A couple of small comments which I hope are helpful. As mentioned in my
previous message, I'm a LibXml newbie so please forgive me if I'm being an
idiot!

Before anything else, let me say that LibXml looks great and I thank you for
your time, effort and kindness in developing it and allowing other people to
use it freely.

What I say below is based on 2.2.4 but, from inspection, is still valid for
2.2.5.

SAX handler overrides:

Although I've decided to go the SAX route now, my initial experiments were
using the DOM route, specifically xmlParseFile. Since I'm writing a GUI
application, errors going to stderr would never reach the user so I wanted
to override the error functions.

I saw that xmlParseFile just calls the similar SAX function with the default
handlers which build a DOM tree, so I created a copy of those handlers,
replaced the error functions with my own and then passed this to
xmlSAXParseFile.

When I called xmlParseFile my program crashed because the default handlers
assume that ctxt->userData is set to ctxt, but ctxt->userData gets NULLed if
you provide your own set of SAX handlers.

This may sound stupid, but what if you could provide a xmlSAXHandlerPtr
block which says for each function one of three things:
1) use the default
2) do nothing
3) use my function

This allows people to take advantage of the default DOM building functions
while being able to override or disable those they may need to change, like
the error functions.

...Ah, but what about the user data? Well, it makes things a bit messier,
but if you know whether a function is user-provided or not you can pass the
function either ctxt or ctxt->userdata when you call it...

Heh, well, I hope this suggestion makes sense. Sorry if I have totally
missed the point or said something stupid! As I say, I'm no longer planning
on using a DOM tree at load time so, personally, I don't need this anymore,
but I figure someone else might.

ParseFile error feedback:

If I call xml(SAX)ParseFile and the file doesn't exist (or can't be read,
and so on), it returns NULL without calling an error handler. If there a way
to get the reason for failure? Writing my own LibXml I/O handler looked like
too much effort for me at the moment and for now I'm going to read the files
to a buffer and use xmlSAXUserParseMemory.

This list:

BTW, some posts seem to be sent to xml@rpmfind.net and others to
xml@xmlsoft.org -- does it matter which I use?

Thanks for reading,
        Leo

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Oct 16 2000 - 09:43:24 EDT