Exemple #1
0
static xode_spool _xode_tospool(xode node)
{
    xode_spool s;
    int level=0,dir=0;
    xode tmp;

    if(!node || xode_get_type(node) != XODE_TYPE_TAG)
	return NULL;

    s = xode_spool_newfrompool(xode_get_pool(node));
    if(!s) return(NULL);

    while(1)
    {
        if(dir==0)
        {
    	    if(xode_get_type(node) == XODE_TYPE_TAG)
            {
		        if(xode_has_children(node))
                {
		            _xode_tag2str(s,node,1);
        		    node = xode_get_firstchild(node);
		            level++;
		            continue;
        		}
                else
                {
		            _xode_tag2str(s,node,0);
		        }
	        }
            else
            {
		        xode_spool_add(s,xode_strescape(xode_get_pool(node),xode_get_data(node)));
	        }
	    }

    	tmp = xode_get_nextsibling(node);
	    if(!tmp)
        {
	        node = xode_get_parent(node);
	        level--;
	        if(level>=0) _xode_tag2str(s,node,2);
	        if(level<1) break;
	        dir = 1;
	    }
        else
        {
	        node = tmp;
	        dir = 0;
	    }
    }

    return s;
}
Exemple #2
0
static void _xode_expat_endElement(void* userdata, const char* name)
{
    xode *x = userdata;
    xode current = *x;

    current->complete = 1;
    current = xode_get_parent(current);

    /* if it's NULL we've hit the top folks, otherwise back up a level */
    if(current != NULL)
        *x = current;
}
Exemple #3
0
static void _xode_stream_endElement(xode_stream xs, const char* name)
{
    xode parent;

    /* if xode_stream is bad, get outa here */
    if(xs->status > XODE_STREAM_NODE) return;

    /* if it's already NULL we've received </stream>, tell the app and we're outta here */
    if(xs->node == NULL)
    {
        xs->status = XODE_STREAM_CLOSE;
        (xs->f)(XODE_STREAM_CLOSE, NULL, xs->arg);
    }else{
        parent = xode_get_parent(xs->node);

        /* we are the top-most node, feed to the app who is responsible to delete it */
        if(parent == NULL)
            (xs->f)(XODE_STREAM_NODE, xs->node, xs->arg);

        xs->node = parent;
    }
    xs->depth--;
}