Re: [xml] Re: Welcome to xml

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Sat Sep 09 2000 - 13:25:56 EDT


On Sat, Sep 09, 2000 at 05:25:41PM +0200, Manuel Guesdon wrote:
>
> Hello,
>
> I have a question on xmlParserCtxt.userData. I wanted to use it as a "user data" (a value I can use to specify anything I want) but this doesn't seems to be the purpose of this variable.
>
> The documentation/headers describe it as "the document being built"
> void *userData; /* the document being built */
>
> but xmlInitParserCtxt(xmlParserCtxtPtr ctxt) initialize it like this:
> ctxt->userData = ctxt;
> (BTW, ctxt->vctxt.userData is also initalized to ctxt)
>
>
> In parser.c, theres's a call to startDocument handler with this userData
> ctxt->sax->startDocument(ctxt->userData);
>
> and startDocument assume this ctxt->userData is a xmlParserCtxt:
>
> startDocument(void *ctx)
> {
> xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
> ...
>
> So, is this userData is really a "user data" I can use as I want or is it a private variable I shouldn't change ? Or is there a problem in the code ?

  This field is an "user data" for the SAX interface. If you use your
own set of SAX callbacks, then you can initialize to whatever you want.
On the other hand libxml uses it when building a DOM tree so in that
case you should not change any value put there libxml would definitly
break if you do (the DOM tree building routines operate on top of the
SAX interface and are just the predefined default SAX handlers).

Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | Today's Bookmarks :
Tel : +33 476 615 257  | 655, avenue de l'Europe | Linux XML libxml WWW
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Gnome rpm2html rpmfind
 http://www.w3.org/People/all#veillard%40w3.org  | RPM badminton Kaffe
----
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 : Sat Sep 09 2000 - 13:43:58 EDT