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

Document * sp_repr_do_read ( xmlDocPtr  doc,
const gchar *  default_ns 
)

Reads in a XML file to create a Document

Definition at line 375 of file repr-io.cpp.

References Inkscape::XML::Node::name(), and sp_repr_do_read().

Referenced by sp_repr_do_read(), and sp_repr_read_file().

{
    if (doc == NULL) return NULL;
    xmlNodePtr node=xmlDocGetRootElement (doc);
    if (node == NULL) return NULL;

    GHashTable * prefix_map;
    prefix_map = g_hash_table_new (g_str_hash, g_str_equal);

    Document *rdoc = new Inkscape::XML::SimpleDocument();

    Node *root=NULL;
    for ( node = doc->children ; node != NULL ; node = node->next ) {
        if (node->type == XML_ELEMENT_NODE) {
            Node *repr=sp_repr_svg_read_node(rdoc, node, default_ns, prefix_map);
            rdoc->appendChild(repr);
            Inkscape::GC::release(repr);

            if (!root) {
                root = repr;
            } else {
                root = NULL;
                break;
            }
        } else if ( node->type == XML_COMMENT_NODE ) {
            Node *comment=sp_repr_svg_read_node(rdoc, node, default_ns, prefix_map);
            rdoc->appendChild(comment);
            Inkscape::GC::release(comment);
        }
    }

    if (root != NULL) {
        /* promote elements of SVG documents that don't use namespaces
         * into the SVG namespace */
        if ( default_ns && !strcmp(default_ns, SP_SVG_NS_URI)
             && !strcmp(root->name(), "svg") )
        {
            promote_to_svg_namespace(root);
        }
    }

    g_hash_table_destroy (prefix_map);

    return rdoc;
}


Generated by  Doxygen 1.6.0   Back to index