solexml.cc (speech_tools-2.4-release) | : | solexml.cc (speech_tools-2.5.0-release) | ||
---|---|---|---|---|
skipping to change at line 244 | skipping to change at line 244 | |||
{ | { | |||
(void)c; (void)p; (void)data; | (void)c; (void)p; (void)data; | |||
} | } | |||
void Sole_Parser_Class::element_open(XML_Parser_Class &c, | void Sole_Parser_Class::element_open(XML_Parser_Class &c, | |||
XML_Parser &p, | XML_Parser &p, | |||
void *data, | void *data, | |||
const char *name, | const char *name, | |||
XML_Attribute_List &attributes) | XML_Attribute_List &attributes) | |||
{ | { | |||
(void)c; (void)p; (void)attributes; | (void)c; (void)p; (void)attributes; | |||
Parse_State *state = (Parse_State *)data; | Parse_State *state = (Parse_State *)data; | |||
state->depth++; | state->depth++; | |||
if (strcmp(name, "solexml")==0) | if (strcmp(name, "solexml")==0) | |||
{ | { | |||
state->relName=attributes.val("relation"); | state->relName=attributes.val("relation"); | |||
printf("start solexml relation=%s\n", (const char *)state->relName); | printf("start solexml relation=%s\n", (const char *)state->relName); | |||
return; | return; | |||
} | } | |||
else if (strcmp(name, "text-elem")==0) | else if (strcmp(name, "text-elem")==0) | |||
{ | { | |||
// ignore these | // ignore these | |||
return; | return; | |||
} | } | |||
ensure_relation(state); | ensure_relation(state); | |||
if (strcmp(name, "anaphora-elem")==0 | if (strcmp(name, "anaphora-elem")==0 | |||
|| strcmp(name, "wordlist")==0 | || strcmp(name, "wordlist")==0 | |||
|| strcmp(name, "w")==0) | || strcmp(name, "w")==0) | |||
{ | { | |||
EST_TList<EST_String> ids; | EST_TList<EST_String> ids; | |||
extract_ids(attributes, ids); | extract_ids(attributes, ids); | |||
EST_Litem *idp = ids.head(); | EST_Litem *idp = ids.head(); | |||
bool first=TRUE; | bool first=TRUE; | |||
for(; idp!= NULL; idp = idp->next()) | for(; idp!= NULL; idp = idp->next()) | |||
{ | { | |||
EST_String id = ids(idp); | EST_String id = ids(idp); | |||
if (id==EST_String::Empty) | if (id==EST_String::Empty) | |||
XML_Parser_Class::error(c, p, data, EST_String("Element With No Id")) | XML_Parser_Class::error(c, p, data, EST_String("Element With No | |||
; | Id")); | |||
if (first) | if (first) | |||
first=FALSE; | first=FALSE; | |||
else | else | |||
{ | { | |||
state->current = state->parent; | state->current = state->parent; | |||
state->parent=state->parent->up(); | state->parent=iup(state->parent); | |||
} | } | |||
EST_Item_Content *cont = get_contents(state, id); | EST_Item_Content *cont = get_contents(state, id); | |||
cont->set_name(id); | cont->set_name(id); | |||
XML_Attribute_List::Entries them; | XML_Attribute_List::Entries them; | |||
for(them.begin(attributes); them ; them++) | for(them.begin(attributes); them ; them++) | |||
{ | { | |||
EST_String k = them->k; | EST_String k = them->k; | |||
EST_String v = them->v; | EST_String v = them->v; | |||
cont->f.set(k,v); | cont->f.set(k,v); | |||
} | } | |||
EST_Item *item; | EST_Item *item; | |||
if (state->current == NULL) | if (state->current == NULL) | |||
if (state->parent == NULL) | if (state->parent == NULL) | |||
item = state->rel->append(); | item = state->rel->append(); | |||
else | else | |||
item = state->parent->insert_below(); | item = state->parent->insert_below(); | |||
else | else | |||
item = state->current->insert_after(); | item = state->current->insert_after(); | |||
item->set_contents(cont); | item->set_contents(cont); | |||
state->current=NULL; | state->current=NULL; | |||
state->parent=item; | state->parent=item; | |||
} | } | |||
} | } | |||
else | else | |||
EST_warning("SOLE XML Parser: unknown element %s", name); | EST_warning("SOLE XML Parser: unknown element %s", name); | |||
} | } | |||
void Sole_Parser_Class::element(XML_Parser_Class &c, | void Sole_Parser_Class::element(XML_Parser_Class &c, | |||
XML_Parser &p, | XML_Parser &p, | |||
void *data, | void *data, | |||
const char *name, | const char *name, | |||
XML_Attribute_List &attributes) | XML_Attribute_List &attributes) | |||
{ | { | |||
(void)c; (void)p; (void)attributes; | (void)c; (void)p; (void)attributes; | |||
Parse_State *state = (Parse_State *)data; | Parse_State *state = (Parse_State *)data; | |||
if (strcmp(name, "language")==0) | if (strcmp(name, "language")==0) | |||
{ | { | |||
state->utt->f.set("language", attributes.val("name")); | state->utt->f.set("language", attributes.val("name")); | |||
return; | return; | |||
} | } | |||
element_open(c, p, data, name, attributes); | element_open(c, p, data, name, attributes); | |||
element_close(c, p, data, name); | element_close(c, p, data, name); | |||
} | } | |||
void Sole_Parser_Class::element_close(XML_Parser_Class &c, | void Sole_Parser_Class::element_close(XML_Parser_Class &c, | |||
XML_Parser &p, | XML_Parser &p, | |||
void *data, | void *data, | |||
const char *name) | const char *name) | |||
{ | { | |||
(void)c; (void)p; (void)name; | (void)c; (void)p; (void)name; | |||
Parse_State *state = (Parse_State *)data; | Parse_State *state = (Parse_State *)data; | |||
if (strcmp(name, "anaphora-elem")==0 | if (strcmp(name, "anaphora-elem")==0 | |||
|| strcmp(name, "wordlist")==0 | || strcmp(name, "wordlist")==0 | |||
|| strcmp(name, "w")==0) | || strcmp(name, "w")==0) | |||
{ | { | |||
state->depth--; | state->depth--; | |||
state->current = state->parent; | state->current = state->parent; | |||
state->parent=state->parent->up();; | state->parent=iup(state->parent); | |||
} | } | |||
} | } | |||
void Sole_Parser_Class::pcdata(XML_Parser_Class &c, | void Sole_Parser_Class::pcdata(XML_Parser_Class &c, | |||
XML_Parser &p, | XML_Parser &p, | |||
void *data, | void *data, | |||
const char *chars) | const char *chars) | |||
{ | { | |||
(void)c; | (void)c; | |||
End of changes. 28 change blocks. | ||||
61 lines changed or deleted | 61 lines changed or added |