Esempio n. 1
0
/* <AuthorList CompleteYN="Y">
 *    <Author>
 *        <LastName>Barondeau</LastName>
 *        <ForeName>David P</ForeName>
 *        ( or <FirstName>David P</FirstName> )
 *        <Initials>DP</Initials>
 *    </Author>
 *    <Author>
 *        <CollectiveName>Organization</CollectiveName>
 *    </Author>
 * </AuthorList>
 */
static int
medin_author( xml *node, str *name )
{
	char *p;
	if ( xml_tag_matches( node, "LastName" ) ) {
		if ( str_has_value( name ) ) {
			str_prepend( name, "|" );
			str_prepend( name, xml_value_cstr( node ) );
		}
		else str_strcat( name, xml_value( node ) );
	} else if ( xml_tag_matches( node, "ForeName" ) ||
	            xml_tag_matches( node, "FirstName" ) ) {
		p = xml_value_cstr( node );
		while ( p && *p ) {
			if ( str_has_value( name ) ) str_addchar( name, '|' );
			while ( *p==' ' ) p++;
			while ( *p && *p!=' ' ) str_addchar( name, *p++ );
		}
	} else if ( xml_tag_matches( node, "Initials" ) && !strchr( name->data, '|' )) {
		p = xml_value_cstr( node );
		while ( p && *p ) {
			if ( str_has_value( name ) ) str_addchar( name, '|' );
			if ( !is_ws(*p) ) str_addchar( name, *p++ );
		}
	}
	if ( node->next ) medin_author( node->next, name );
	return BIBL_OK;
}
Esempio n. 2
0
static int
medin_corpauthor( xml *node, str *name )
{
	if ( xml_tag_matches( node, "CollectiveName" ) ) {
		str_strcpy( name, xml_value( node ) );
	} else if ( node->next ) medin_corpauthor( node->next, name );
	return BIBL_OK;
}
Esempio n. 3
0
static PyObject*
py_xml_value(PyObject *self, PyObject *args)
{
    int n;
    if (!PyArg_ParseTuple(args, "i:xml_value", &n))
        return NULL;
    char* val = new char[81];
    int iok = xml_value(n, val);
    if (iok < 0) return reportError(iok);
    PyObject* r = Py_BuildValue("s",val);
    delete val;
    return r;
}
void xmlmethods(int nlhs, mxArray* plhs[],
                int nrhs, const mxArray* prhs[])
{
    int j, m, iok = 0;
    char* file, *key, *val, *nm;
    int job = getInt(prhs[1]);
    int i = getInt(prhs[2]);

    // Check for proper number of arguments
    if (!nargs_ok(job,nrhs-1)) {
        mexErrMsgTxt("Wrong number of inputs.");
        return;
    } else if (nlhs > 1) {
        mexErrMsgTxt("Too many output arguments");
    }

    // options that do not return a value
    if (job < 20) {
        switch (job) {
        case 0:
            nm = getString(prhs[3]);
            iok = xml_new(nm);
            break;
        case 1:
            iok = xml_del(i);
            break;
        case 2:
            iok = xml_copy(i);
            break;
        case 4:
            file = getString(prhs[3]);
            iok = xml_build(i, file);
            break;
        case 5:
            key = getString(prhs[3]);
            val = getString(prhs[4]);
            iok = xml_addAttrib(i, key, val);
            break;
        case 6:
            key = getString(prhs[3]);
            iok = xml_child(i, key);
            break;
        case 7:
            m = getInt(prhs[3]);
            iok = xml_child_bynumber(i, m);
            break;
        case 8:
            key = getString(prhs[3]);
            iok = xml_findID(i, key);
            break;
        case 9:
            key = getString(prhs[3]);
            iok = xml_findByName(i, key);
            break;
        case 10:
            iok = xml_nChildren(i);
            break;
        case 11:
            key = getString(prhs[3]);
            val = getString(prhs[4]);
            iok = xml_addChild(i, key, val);
            break;
        case 12:
            key = getString(prhs[3]);
            j = getInt(prhs[4]);
            iok = xml_addChildNode(i, j);
            break;
        case 13:
            file = getString(prhs[3]);
            iok = xml_write(i, file);
            break;
        case 14:
            j = getInt(prhs[3]);
            iok = xml_removeChild(i, j);
            break;
        case 15:
            file = getString(prhs[3]);
            iok = xml_get_XML_File(file, 0);
            break;
        default:
            mexErrMsgTxt("unknown job parameter");
        }
        plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
        double* h = mxGetPr(plhs[0]);
        *h = double(iok);
        if (iok < 0) {
            reportError();
        }
        return;
    }

    // options that return strings
    char* v = (char*)mxCalloc(80, sizeof(char));
    switch (job) {
    case 20:
        // return an attribute
        key = getString(prhs[3]);
        iok = xml_attrib(i, key, v);
        break;
    case 21:
        // return the value of the node
        iok = xml_value(i, v);
        break;
    case 22:
        iok = xml_tag(i, v);
        break;
    default:
        mexErrMsgTxt("unknown job parameter");
    }
    if (iok < 0) {
        plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
        double* h = mxGetPr(plhs[0]);
        *h = double(iok);
        if (iok < 0) {
            reportError();
        }
    } else {
        plhs[0] = mxCreateString(v);
    }
}