Move doc to toplevel element, write <any> for unknown containers

Moving to <doc> allows us to better preserve whitespace.  XML has no
facility for whitespace-preserving attributes.

Second, for arrays and lists, both types with unknown element_type can
occur in the current scanner; it's least wrong if we write out an
<any> type.
This commit is contained in:
Colin Walters 2010-07-07 18:18:37 -04:00
parent 3d0dc7d214
commit 68b4fb43bb

View File

@ -76,6 +76,7 @@ typedef enum
STATE_ALIAS, /* 30 */
STATE_TYPE,
STATE_ATTRIBUTE,
STATE_DOC,
STATE_PASSTHROUGH
} ParseState;
@ -1957,6 +1958,22 @@ end_type (ParseContext *ctx)
}
}
static gboolean
start_doc (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
ParseContext *ctx,
GError **error)
{
if (strcmp (element_name, "doc") != 0 || ctx->node_stack == NULL)
return FALSE;
state_switch (ctx, STATE_DOC);
return TRUE;
}
static gboolean
start_attribute (GMarkupParseContext *context,
const gchar *element_name,
@ -2570,6 +2587,9 @@ start_element_handler (GMarkupParseContext *context,
attribute_names, attribute_values,
ctx, error))
goto out;
else if (start_doc (context, element_name, attribute_names,
attribute_values, ctx, error))
goto out;
break;
case 'e':
@ -3207,6 +3227,13 @@ end_element_handler (GMarkupParseContext *context,
}
break;
case STATE_DOC:
if (strcmp ("doc", element_name) == 0)
{
state_switch (ctx, ctx->prev_state);
}
break;
case STATE_PASSTHROUGH:
ctx->unknown_depth -= 1;
if (ctx->unknown_depth == 0)