Re: alternative gmarkup parser



On 10/21/00 Havoc Pennington wrote:
> typedef enum
> {
>   /* Hmm, can't think of any at the moment */
>   G_MARKUP_FOO = 1 << 0
>   
> } GMarkupParseFlags;

Maybe G_MARKUP_SKIP_WHITE_SPACE could be useful to skip white
space at the beginning of a tag content to better support tag
nesting, for example.

> struct _GMarkupParser
> {
>   /* Called for open tags <foo bar="baz"> */
>   void (*start_element)  (GMarkupParseContext *context,
>                           const gchar         *element_name,
>                           const gchar        **attribute_names,
>                           const gchar        **attribute_values,
>                           gpointer             user_data,
>                           GError             **error);

Why not expose the GMarkupAttribute GSList here? There is no reason
to copy things that way all the time. If we later change the
implementation to use, say, GArray we'll have a slight performance hit, 
but why take it all the time?:-)
The order of the attributes should be preserved
(just do a g_slist_reverse() before calling the handler).

>   /* Called on error, including one set by other
>    * methods in the vtable. The GError should not be freed.
>    */
>   void (*error)          (GMarkupParseContext *context,
>                           GError              *error,
>                           gpointer             user_data);

user_data and error are swapped here, just for consistency.

Also, what about a callback for entities? It could be:

	gchar* (*entity)       (GMarkupParseContext *context,
	                        gchar               *enitity,
							GError              *error,
							gpointer             user_data);

This will be called for non-standard entities and will return the
text to substitute in the xml stream (the text will need to be g_free()d).
If the callback is not set, issue an error as you do now.

Thanks,
	lupus

-- 
Paolo Molaro, Open Source Developer, Linuxcare, Inc.
+39.049.8043411 tel, +39.049.8043412 fax
lupus linuxcare com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.




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