X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=sherlock%2Fxml%2Fparse.c;h=5581ed597cc70dce2297d770144aa33bd065e24d;hb=68721201144bd814bec0b361229de9009147c927;hp=d690ead5a0f09b0fae7f897c69251b8eb30a3e24;hpb=ca2850c6c8941faecb6e07be3379127330feb04a;p=libucw.git diff --git a/sherlock/xml/parse.c b/sherlock/xml/parse.c index d690ead5..5581ed59 100644 --- a/sherlock/xml/parse.c +++ b/sherlock/xml/parse.c @@ -749,6 +749,19 @@ xml_push_element(struct xml_context *ctx) xml_unget_char(ctx); xml_parse_attr(ctx); } + if (e->dtd) + SLIST_FOR_EACH(struct xml_dtd_attr *, a, e->dtd->attrs) + if (a->default_mode == XML_ATTR_REQUIRED) + { + if (!xml_attrs_find(ctx->tab_attrs, e, a->name)) + xml_error(ctx, "Missing required attribute %s in element <%s>", a->name, e->name); + } + else if (a->default_mode != XML_ATTR_IMPLIED && ctx->flags & XML_ALLOC_DEFAULT_ATTRS) + { + struct xml_attr *attr = xml_attrs_lookup(ctx->tab_attrs, e, a->name); + if (!attr->val) + attr->val = a->default_value; + } if ((ctx->flags & XML_REPORT_TAGS) && ctx->h_stag) ctx->h_stag(ctx); } @@ -1242,6 +1255,7 @@ xml_merge_chars(struct xml_context *ctx UNUSED, struct xml_node *node, struct me { p = mp_spread(pool, p, son->len + 1); memcpy(p, son->text, son->len); + p += son->len; } *p++ = 0; return mp_end(pool, p); @@ -1255,6 +1269,7 @@ xml_append_dom_chars(char *p, struct mempool *pool, struct xml_node *node) { p = mp_spread(pool, p, son->len + 1); memcpy(p, son->text, son->len); + p += son->len; } else if (son->type == XML_NODE_ELEM) p = xml_append_dom_chars(p, pool, son);