From 556f1650b14a8c8f0dcce60589731480741e805f Mon Sep 17 00:00:00 2001 From: "Fred L. Drake, Jr." Date: Tue, 28 Oct 2003 21:25:43 +0000 Subject: [PATCH] extend the "Communicating between handlers" section a bit; needed to mention the need to accumulate data between calls to the character data handler --- expat/doc/reference.html | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/expat/doc/reference.html b/expat/doc/reference.html index 9ed9f90f..16a0050e 100644 --- a/expat/doc/reference.html +++ b/expat/doc/reference.html @@ -502,8 +502,31 @@ handler.

without using globals, you'll need to define a data structure to hold the shared variables. You can then tell Expat (with the XML_SetUserData function) to pass a -pointer to this structure to the handlers. This is typically the first -argument received by most handlers.

+pointer to this structure to the handlers. This is the first +argument received by most handlers. In the reference section, an argument to a callback function is named +userData and have type void * if the user +data is passed; it will have the type XML_Parser if the +parser itself is passed. When the parser is passed, the user data may +be retrieved using XML_GetUserData.

+ +

One common case where multiple calls to a single handler may need +to communicate using an application data structure is the case when +content passed to the character data handler (set by XML_SetCharacterDataHandler) needs to be accumulated. A +common first-time mistake with any of the event-oriented interfaces to +an XML parser is to expect all the text contained in an element to be +reported by a single call to the character data handler. Expat, like +many other XML parsers, reports such data as a sequence of calls; +there's no way to know when the end of the sequence is reached until a +different callback is made. A buffer referenced by the user data +structure proves both an effective and convenient place to accumulate +character data.

+ + +

XML Version