Skip to content

Commit

Permalink
* Fixed handling #FIXED and defaulted attributes of omitted open-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Wielemaker committed Mar 16, 2001
1 parent 3ead495 commit 14d9fbd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
* FIXED: Proper handling of plain <!DOCTYPE doc>
* FIXED: Include #FIXED and defaulted arguments for omitted tags
(reported by Richard O'Keefe).

* ADDED: handle plain <!DOCTYPE doc> silently if the catalog contains
a DOCTYPE doc file.dtd entry.

* FIXED: Various issues in attribute handling with new routines supplied
by Richard O'Keefe. Added shorttag(Bool) to options you can set.
Expand Down
2 changes: 2 additions & 0 deletions Test/ok/oma.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[element(oma, [foo=foo], [element(obo, [bar=bar], [element(p, [], ['Hello world.']), element(p, [], ['Where did the attributes go?'])])])].
[].
8 changes: 8 additions & 0 deletions Test/oma.sgml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE oma [ <!ELEMENT oma O O (obo)>
<!ATTLIST oma foo CDATA #FIXED "foo">
<!ELEMENT obo O O (p+)>
<!ATTLIST obo bar CDATA #FIXED "bar">
<!ELEMENT p - O (#PCDATA)>
]>
<p>Hello world.
<p>Where did the attributes go?
32 changes: 28 additions & 4 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ int load_dtd_from_file(dtd_parser *p, const char *file);
void free_dtd_parser(dtd_parser *p);
static const ichar * isee_character_entity(dtd *dtd, const ichar *in,
int *chr);
static int add_default_attributes(dtd_parser *p, dtd_element *e,
int natts,
sgml_attribute *atts);


/*******************************
Expand Down Expand Up @@ -2489,7 +2492,14 @@ push_element(dtd_parser *p, dtd_element *e, int callback)

p->first = TRUE;
if ( callback && p->on_begin_element )
(*p->on_begin_element)(p, e, 0, NULL);
{ sgml_attribute atts[MAXATTRIBUTES];
int natts = 0;

if ( !(p->flags & SGML_PARSER_NODEFS) )
natts = add_default_attributes(p, e, natts, atts);

(*p->on_begin_element)(p, e, natts, atts);
}

if ( e->structure )
{ if ( e->structure->type == C_CDATA ||
Expand Down Expand Up @@ -2610,7 +2620,14 @@ open_element(dtd_parser *p, dtd_element *e, int warn)
WITH_CLASS(p, EV_OMITTED,
{ open_element(p, f, TRUE);
if ( p->on_begin_element )
(*p->on_begin_element)(p, f, 0, NULL);
{ sgml_attribute atts[MAXATTRIBUTES];
int natts = 0;

if ( !(p->flags & SGML_PARSER_NODEFS) )
natts = add_default_attributes(p, f, natts, atts);

(*p->on_begin_element)(p, f, natts, atts);
}
});
}
}
Expand Down Expand Up @@ -3065,6 +3082,9 @@ add_default_attributes(dtd_parser *p, dtd_element *e,
int natts, sgml_attribute *atts)
{ dtd_attr_list *al;

if ( e == CDATA_ELEMENT )
return natts;

for(al=e->attributes; al; al=al->next)
{ dtd_attr *a = al->attribute;

Expand Down Expand Up @@ -3239,14 +3259,17 @@ process_doctype(dtd_parser *p, const ichar *decl, const ichar *decl0)
if ( (s=isee_identifier(dtd, decl, "system")) )
{ et = sgml_calloc(1, sizeof(*et));
et->type = ET_SYSTEM;
decl = s;
} else if ( (s=isee_identifier(dtd, decl, "public")) )
{ et = sgml_calloc(1, sizeof(*et));
et->type = ET_PUBLIC;
}
decl = s;
} else if ( isee_func(dtd, decl, CF_DSO) )
goto local;

if ( et )
{ et->name = id;
if ( !(s=process_entity_value_declaration(p, s, et)) )
if ( !(s=process_entity_value_declaration(p, decl, et)) )
return FALSE;
decl = s;
}
Expand All @@ -3270,6 +3293,7 @@ process_doctype(dtd_parser *p, const ichar *decl, const ichar *decl0)
if ( et )
free_entity_list(et);

local:
if ( (s=isee_func(dtd, decl, CF_DSO)) ) /* [...] */
{ int grouplevel = 1;
data_mode oldmode = p->dmode;
Expand Down

0 comments on commit 14d9fbd

Please sign in to comment.