Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

const gchar* rdf_get_repr_text ( Inkscape::XML::Node repr,
struct rdf_work_entity_t entity 
)

Pull the text out of an RDF entity, depends on how it's stored.

Returns:
A pointer to the entity's static contents as a string
Parameters:
reprThe XML element to extract from
entityThe desired RDF/Work entity

Definition at line 442 of file rdf.cpp.

References Inkscape::XML::Node::attribute(), Inkscape::XML::Node::content(), Inkscape::XML::Node::firstChild(), Inkscape::XML::Node::name(), sp_repr_children(), Inkscape::XML::Node::sp_repr_lookup_name(), and sp_repr_next().

Referenced by rdf_get_work_entity().

{
    g_return_val_if_fail (repr != NULL, NULL);
    g_return_val_if_fail (entity != NULL, NULL);
    static gchar * bag = NULL;
    gchar * holder = NULL;

    Inkscape::XML::Node * temp=NULL;
    switch (entity->datatype) {
        case RDF_CONTENT:
            temp = sp_repr_children(repr);
            if ( temp == NULL ) return NULL;
            
            return temp->content();

        case RDF_AGENT:
            temp = sp_repr_lookup_name ( repr, "cc:Agent", 1 );
            if ( temp == NULL ) return NULL;

            temp = sp_repr_lookup_name ( temp, "dc:title", 1 );
            if ( temp == NULL ) return NULL;

            temp = sp_repr_children(temp);
            if ( temp == NULL ) return NULL;

            return temp->content();

        case RDF_RESOURCE:
            return repr->attribute("rdf:resource");

        case RDF_XML:
            return "xml goes here";

        case RDF_BAG:
            /* clear the static string.  yucky. */
            if (bag) g_free(bag);
            bag = NULL;

            temp = sp_repr_lookup_name ( repr, "rdf:Bag", 1 );
            if ( temp == NULL ) {
                /* backwards compatible: read contents */
                temp = sp_repr_children(repr);
                if ( temp == NULL ) return NULL;
            
                return temp->content();
            }

            for ( temp = sp_repr_children(temp) ;
                  temp ;
                  temp = sp_repr_next(temp) ) {
                if (!strcmp(temp->name(),"rdf:li") &&
                    temp->firstChild()) {
                    const gchar * str = temp->firstChild()->content();
                    if (bag) {
                        holder = bag;
                        bag = g_strconcat(holder, ", ", str, NULL);
                        g_free(holder);
                    }
                    else {
                        bag = g_strdup(str);
                    }
                }
            }
            return bag;

        default:
            break;
    }
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index