static int wordin_processf( fields *wordin, char *data, char *filename, long nref, param *p ) { int status, ret = 1; xml top; xml_init( &top ); xml_tree( data, &top ); status = wordin_assembleref( &top, wordin ); xml_free( &top ); if ( status==BIBL_ERR_MEMERR ) ret = 0; return ret; }
int medin_processf( fields *medin, char *data, char *filename, long nref ) { int status; xml top; xml_init( &top ); xml_tree( data, &top ); status = medin_assembleref( &top, medin ); xml_free( &top ); if ( status==BIBL_OK ) return 1; return 0; }
char * xml_tree( char *p, xml *onode ) { newstr tag; xml_attrib *attrib; int type, is_style = 0; newstr_init( &tag ); while ( *p ) { /* retain white space for <style> tags in endnote xml */ if ( onode->tag && onode->tag->data && !strcasecmp(onode->tag->data,"style") ) is_style=1; while ( *p && *p!='<' ) { if ( onode->value->len>0 || is_style || !is_ws( *p ) ) newstr_addchar( onode->value, *p ); p++; } if ( *p=='<' ) { newstr_empty( &tag ); p = xml_processtag( p, &tag, &attrib, &type ); if ( type==XML_OPEN || type==XML_OPENCLOSE || type==XML_DESCRIPTOR ) { xml *nnode = xml_new(); newstr_newstrcpy( nnode->tag, &tag ); nnode->a = attrib; xml_appendnode( onode, nnode ); if ( type==XML_OPEN ) p = xml_tree( p, nnode ); } else if ( type==XML_CLOSE ) { /*check to see if it's closing for this one*/ goto out; /* assume it's right for now */ } } } out: newstr_free( &tag ); return p; }
int xml_getencoding( newstr *s ) { newstr descriptor; xml descriptxml; int file_charset = CHARSET_UNKNOWN; char *p, *q; p = strstr( s->data, "<?xml" ); if ( !p ) p = strstr( s->data, "<?XML" ); if ( p ) { q = strstr( p, "?>" ); if ( q ) { newstr_init( &descriptor ); newstr_segcpy( &descriptor, p, q+2 ); xml_init( &descriptxml ); xml_tree( descriptor.data, &descriptxml ); file_charset = xml_getencodingr( &descriptxml ); xml_free( &descriptxml ); newstr_free( &descriptor ); newstr_segdel( s, p, q+2 ); } } return file_charset; }