emit_start_element (GMarkupParseContext *context,
GError **error)
{
- int i;
+ int i, j = 0;
const gchar *start_name;
const gchar **attr_names;
const gchar **attr_values;
GError *tmp_error;
+ /* In case we want to ignore qualified tags and we see that we have
+ * one here, we push a subparser. This will ignore all tags inside of
+ * the qualified tag.
+ *
+ * We deal with the end of the subparser from emit_end_element.
+ */
+ if (context->flags & G_MARKUP_IGNORE_QUALIFIED && strchr (current_element (context), ':'))
+ {
+ static const GMarkupParser ignore_parser;
+ g_markup_parse_context_push (context, &ignore_parser, NULL);
+ return;
+ }
+
attr_names = g_newa (const gchar *, context->cur_attr + 2);
attr_values = g_newa (const gchar *, context->cur_attr + 2);
for (i = 0; i < context->cur_attr + 1; i++)
{
- attr_names[i] = context->attr_names[i]->str;
- attr_values[i] = context->attr_values[i]->str;
+ /* Possibly omit qualified attribute names from the list */
+ if ((context->flags & G_MARKUP_IGNORE_QUALIFIED) && strchr (context->attr_names[i]->str, ':'))
+ continue;
+
+ attr_names[j] = context->attr_names[i]->str;
+ attr_values[j] = context->attr_values[i]->str;
+ j++;
}
- attr_names[i] = NULL;
- attr_values[i] = NULL;
+ attr_names[j] = NULL;
+ attr_values[j] = NULL;
/* Call user callback for element start */
tmp_error = NULL;
possibly_finish_subparser (context);
+ /* We might have just returned from our ignore subparser */
+ if (context->flags & G_MARKUP_IGNORE_QUALIFIED && strchr (current_element (context), ':'))
+ {
+ g_markup_parse_context_pop (context);
+ pop_tag (context);
+ return;
+ }
+
tmp_error = NULL;
if (context->parser->end_element)
(* context->parser->end_element) (context,
* caller know the location of the error. When this flag is set the
* location information is also prefixed to errors generated by the
* #GMarkupParser implementation functions
+ * @G_MARKUP_IGNORE_QUALIFIED: Ignore (don't report) qualified
+ * attributes and tags, along with their contents. A qualified
+ * attribute or tag is one that contains ':' in its name (ie: is in
+ * another namespace). Since: 2.40.
*
* Flags that affect the behaviour of the parser.
*/
{
G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1,
- G_MARKUP_PREFIX_ERROR_POSITION = 1 << 2
+ G_MARKUP_PREFIX_ERROR_POSITION = 1 << 2,
+ G_MARKUP_IGNORE_QUALIFIED = 1 << 3
} GMarkupParseFlags;
/**