Code

by default, try square arrangement, not 1 row as before
[inkscape.git] / src / dialogs / rdf.cpp
index a0bb04ad17adfda1bd41ccada84292b852054947..70cac4e1fe8cdc69f092ade6c3cbaf6cc1b982ec 100644 (file)
 #include "xml/repr.h"
 #include "rdf.h"
 #include "sp-item-group.h"
+#include "inkscape.h"
 
 /*
 
    Example RDF XML from various places...
  
-<rdf:RDF xmlns="http://web.resource.org/cc/"
+<rdf:RDF xmlns="http://creativecommons.org/ns#"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
 <Work rdf:about="">
@@ -48,7 +49,7 @@
 </Work>
 
 
-  <rdf:RDF xmlns="http://web.resource.org/cc/"
+  <rdf:RDF xmlns="http://creativecommons.org/ns#"
       xmlns:dc="http://purl.org/dc/elements/1.1/"
       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
   <Work rdf:about="">
         <dc:title>John Cliff</dc:title>
      </Agent></dc:rights>
      <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-     <license rdf:resource="http://web.resource.org/cc/PublicDomain" />
+     <license rdf:resource="http://creativecommons.org/ns#PublicDomain" />
   </Work>
   
-  <License rdf:about="http://web.resource.org/cc/PublicDomain">
-     <permits rdf:resource="http://web.resource.org/cc/Reproduction" />
-     <permits rdf:resource="http://web.resource.org/cc/Distribution" />
-     <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+  <License rdf:about="http://creativecommons.org/ns#PublicDomain">
+     <permits rdf:resource="http://creativecommons.org/ns#Reproduction" />
+     <permits rdf:resource="http://creativecommons.org/ns#Distribution" />
+     <permits rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
   </License>
   
 </rdf:RDF>
@@ -91,132 +92,125 @@ struct rdf_double_t rdf_license_empty [] = {
 };
 
 struct rdf_double_t rdf_license_cc_a [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_sa [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
-    { "cc:requires", "http://web.resource.org/cc/ShareAlike", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
+    { "cc:requires", "http://creativecommons.org/ns#ShareAlike", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_nd [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_nc [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:prohibits", "http://web.resource.org/cc/CommercialUse", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:prohibits", "http://creativecommons.org/ns#CommercialUse", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_nc_sa [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:prohibits", "http://web.resource.org/cc/CommercialUse", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
-    { "cc:requires", "http://web.resource.org/cc/ShareAlike", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:prohibits", "http://creativecommons.org/ns#CommercialUse", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
+    { "cc:requires", "http://creativecommons.org/ns#ShareAlike", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_nc_nd [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:prohibits", "http://web.resource.org/cc/CommercialUse", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:prohibits", "http://creativecommons.org/ns#CommercialUse", },
     { NULL, NULL }
 };
 
-struct rdf_double_t rdf_license_gpl [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
-    { "cc:requires", "http://web.resource.org/cc/ShareAlike", },
-    { "cc:requires", "http://web.resource.org/cc/SourceCode", },
+struct rdf_double_t rdf_license_pd [] = {
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
     { NULL, NULL }
 };
 
-struct rdf_double_t rdf_license_pd [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
+struct rdf_double_t rdf_license_freeart [] = {
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
+    { "cc:requires", "http://creativecommons.org/ns#ShareAlike", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
     { NULL, NULL }
 };
 
-struct rdf_double_t rdf_license_freeart [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
-    { "cc:requires", "http://web.resource.org/cc/ShareAlike", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
+struct rdf_double_t rdf_license_ofl [] = {
+    { "cc:permits", "http://scripts.sil.org/pub/OFL/Reproduction", },
+    { "cc:permits", "http://scripts.sil.org/pub/OFL/Distribution", },
+    { "cc:permits", "http://scripts.sil.org/pub/OFL/Embedding", },
+    { "cc:permits", "http://scripts.sil.org/pub/OFL/DerivativeWorks", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/Notice", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/Attribution", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/ShareAlike", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/DerivativeRenaming", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/BundlingWhenSelling", },
     { NULL, NULL }
 };
 
 struct rdf_license_t rdf_licenses [] = {
     { N_("CC Attribution"), 
-      "http://creativecommons.org/licenses/by/2.5/",
+      "http://creativecommons.org/licenses/by/3.0/",
       rdf_license_cc_a,
     },
 
     { N_("CC Attribution-ShareAlike"), 
-      "http://creativecommons.org/licenses/by-sa/2.5/",
+      "http://creativecommons.org/licenses/by-sa/3.0/",
       rdf_license_cc_a_sa,
     },
 
     { N_("CC Attribution-NoDerivs"), 
-      "http://creativecommons.org/licenses/by-nd/2.5/",
+      "http://creativecommons.org/licenses/by-nd/3.0/",
       rdf_license_cc_a_nd,
     },
 
     { N_("CC Attribution-NonCommercial"), 
-      "http://creativecommons.org/licenses/by-nc/2.5/",
+      "http://creativecommons.org/licenses/by-nc/3.0/",
       rdf_license_cc_a_nc,
     },
 
     { N_("CC Attribution-NonCommercial-ShareAlike"), 
-      "http://creativecommons.org/licenses/by-nc-sa/2.5/",
+      "http://creativecommons.org/licenses/by-nc-sa/3.0/",
       rdf_license_cc_a_nc_sa,
     },
 
     { N_("CC Attribution-NonCommercial-NoDerivs"), 
-      "http://creativecommons.org/licenses/by-nc-nd/2.5/",
+      "http://creativecommons.org/licenses/by-nc-nd/3.0/",
       rdf_license_cc_a_nc_nd,
     },
 
-    { N_("GNU General Public License"), 
-      "http://creativecommons.org/licenses/GPL/2.0/",
-      rdf_license_gpl,
-    },
-
-    { N_("GNU Lesser General Public License"), 
-      "http://creativecommons.org/licenses/LGPL/2.1/",
-      rdf_license_gpl,
-    },
-
     { N_("Public Domain"),
-      "http://web.resource.org/cc/PublicDomain",
+      "http://creativecommons.org/licenses/publicdomain/",
       rdf_license_pd,
     },
 
@@ -225,6 +219,11 @@ struct rdf_license_t rdf_licenses [] = {
       rdf_license_freeart,
     },
 
+    { N_("Open Font License"),
+      "http://scripts.sil.org/OFL",
+      rdf_license_ofl,
+    },
+
     { NULL, NULL, rdf_license_empty, }
 };
 
@@ -341,7 +340,7 @@ rdf_string(struct rdf_t * rdf)
     gchar *string=NULL;
 
     gchar *rdf_head="\
-<rdf:RDF xmlns=\"http://web.resource.org/cc/\"\
+<rdf:RDF xmlns=\"http://creativecommons.org/ns#\"\
     xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\
     xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\
 ";
@@ -536,12 +535,22 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
     Inkscape::XML::Node * temp=NULL;
     Inkscape::XML::Node * child=NULL;
     Inkscape::XML::Node * parent=repr;
+
+    Inkscape::XML::Document * xmldoc = parent->document();
+    g_return_val_if_fail (xmldoc != NULL, FALSE);
+
+    // set document's title element to the RDF title
+    if (!strcmp(entity->name, "title")) {
+        SPDocument *doc = SP_ACTIVE_DOCUMENT;
+        if(doc && doc->root) doc->root->setTitle(text);
+    }
+
     switch (entity->datatype) {
         case RDF_CONTENT:
             temp = sp_repr_children(parent);
             if ( temp == NULL ) {
-                temp = sp_repr_new_text( text );
-                g_return_val_if_fail (temp != NULL, 0);
+                temp = xmldoc->createTextNode( text );
+                g_return_val_if_fail (temp != NULL, FALSE);
 
                 parent->appendChild(temp);
                 Inkscape::GC::release(temp);
@@ -550,14 +559,14 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
             }
             else {
                 temp->setContent(text);
-                               return TRUE;
+                return TRUE;
             }
 
         case RDF_AGENT:
             temp = sp_repr_lookup_name ( parent, "cc:Agent", 1 );
             if ( temp == NULL ) {
-                temp = sp_repr_new ( "cc:Agent" );
-                g_return_val_if_fail (temp != NULL, 0);
+                temp = xmldoc->createElement ( "cc:Agent" );
+                g_return_val_if_fail (temp != NULL, FALSE);
 
                 parent->appendChild(temp);
                 Inkscape::GC::release(temp);
@@ -566,8 +575,8 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
 
             temp = sp_repr_lookup_name ( parent, "dc:title", 1 );
             if ( temp == NULL ) {
-                temp = sp_repr_new ( "dc:title" );
-                g_return_val_if_fail (temp != NULL, 0);
+                temp = xmldoc->createElement ( "dc:title" );
+                g_return_val_if_fail (temp != NULL, FALSE);
 
                 parent->appendChild(temp);
                 Inkscape::GC::release(temp);
@@ -576,8 +585,8 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
 
             temp = sp_repr_children(parent);
             if ( temp == NULL ) {
-                temp = sp_repr_new_text( text );
-                g_return_val_if_fail (temp != NULL, 0);
+                temp = xmldoc->createTextNode( text );
+                g_return_val_if_fail (temp != NULL, FALSE);
 
                 parent->appendChild(temp);
                 Inkscape::GC::release(temp);
@@ -605,8 +614,8 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
                     parent->removeChild(temp);
                 }
 
-                temp = sp_repr_new ( "rdf:Bag" );
-                g_return_val_if_fail (temp != NULL, 0);
+                temp = xmldoc->createElement ( "rdf:Bag" );
+                g_return_val_if_fail (temp != NULL, FALSE);
 
                 parent->appendChild(temp);
                 Inkscape::GC::release(temp);
@@ -622,13 +631,13 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
             strlist = g_strsplit( text, ",", 0);
 
             for (i = 0; (str = strlist[i]); i++) {
-                temp = sp_repr_new ( "rdf:li" );
+                temp = xmldoc->createElement ( "rdf:li" );
                 g_return_val_if_fail (temp != NULL, 0);
 
                 parent->appendChild(temp);
                 Inkscape::GC::release(temp);
 
-                child = sp_repr_new_text( g_strstrip(str) );
+                child = xmldoc->createTextNode( g_strstrip(str) );
                 g_return_val_if_fail (child != NULL, 0);
 
                 temp->appendChild(child);
@@ -650,6 +659,9 @@ rdf_get_rdf_root_repr ( SPDocument * doc, bool build )
     g_return_val_if_fail (doc        != NULL, NULL);
     g_return_val_if_fail (doc->rroot != NULL, NULL);
 
+    Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+    g_return_val_if_fail (xmldoc != NULL, NULL);
+
     Inkscape::XML::Node * rdf = sp_repr_lookup_name ( doc->rroot, XML_TAG_NAME_RDF );
 
     if (rdf == NULL) {
@@ -661,14 +673,17 @@ rdf_get_rdf_root_repr ( SPDocument * doc, bool build )
 
         Inkscape::XML::Node * parent = sp_repr_lookup_name ( svg, XML_TAG_NAME_METADATA );
         if ( parent == NULL ) {
-            parent = sp_repr_new( XML_TAG_NAME_METADATA );
+            parent = xmldoc->createElement( XML_TAG_NAME_METADATA );
             g_return_val_if_fail ( parent != NULL, NULL);
 
             svg->appendChild(parent);
             Inkscape::GC::release(parent);
         }
 
-        rdf = sp_repr_new( XML_TAG_NAME_RDF );
+        Inkscape::XML::Document * xmldoc = parent->document();
+        g_return_val_if_fail (xmldoc != NULL, FALSE);
+
+        rdf = xmldoc->createElement( XML_TAG_NAME_RDF );
         g_return_val_if_fail (rdf != NULL, NULL);
 
         parent->appendChild(rdf);
@@ -682,7 +697,7 @@ rdf_get_rdf_root_repr ( SPDocument * doc, bool build )
     Inkscape::XML::Node * want_metadata = sp_repr_parent ( rdf );
     g_return_val_if_fail (want_metadata != NULL, NULL);
     if (strcmp( want_metadata->name(), XML_TAG_NAME_METADATA )) {
-            Inkscape::XML::Node * metadata = sp_repr_new( XML_TAG_NAME_METADATA );
+            Inkscape::XML::Node * metadata = xmldoc->createElement( XML_TAG_NAME_METADATA );
             g_return_val_if_fail (metadata != NULL, NULL);
 
             /* attach the metadata node */
@@ -714,7 +729,10 @@ rdf_get_xml_repr( SPDocument * doc, gchar const * name, bool build )
         //printf("missing XML '%s'\n",name);
         if (!build) return NULL;
 
-        xml = sp_repr_new( name );
+        Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+        g_return_val_if_fail (xmldoc != NULL, NULL);
+
+        xml = xmldoc->createElement( name );
         g_return_val_if_fail (xml != NULL, NULL);
 
         xml->setAttribute("rdf:about", "" );
@@ -741,7 +759,10 @@ rdf_get_work_repr( SPDocument * doc, gchar const * name, bool build )
         //printf("missing XML '%s'\n",name);
         if (!build) return NULL;
 
-        item = sp_repr_new( name );
+        Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+        g_return_val_if_fail (xmldoc != NULL, NULL);
+
+        item = xmldoc->createElement( name );
         g_return_val_if_fail (item != NULL, NULL);
 
         work->appendChild(item);
@@ -765,17 +786,21 @@ rdf_get_work_entity(SPDocument * doc, struct rdf_work_entity_t * entity)
     g_return_val_if_fail (doc    != NULL, NULL);
     if ( entity == NULL ) return NULL;
     //printf("want '%s'\n",entity->title);
+    bool bIsTitle = !strcmp(entity->name, "title");
 
     Inkscape::XML::Node * item;
     if ( entity->datatype == RDF_XML ) {
         item = rdf_get_xml_repr ( doc, entity->tag, FALSE );
     }
     else {
-        item = rdf_get_work_repr( doc, entity->tag, FALSE );
+        item = rdf_get_work_repr( doc, entity->tag, bIsTitle ); // build title if necessary
     }
     if ( item == NULL ) return NULL;
-
     const gchar * result = rdf_get_repr_text ( item, entity );
+    if(!result && bIsTitle && doc->root) {         // if RDF title not set
+        result = doc->root->title();               // get the document's <title>
+        rdf_set_work_entity(doc, entity, result);  // and set the RDF
+    }
     //printf("found '%s' == '%s'\n", entity->title, result );
     return result;
 }
@@ -811,8 +836,8 @@ rdf_set_work_entity(SPDocument * doc, struct rdf_work_entity_t * entity,
 
 #undef DEBUG_MATCH
 
-bool
-rdf_match_license ( Inkscape::XML::Node * repr, struct rdf_license_t * license )
+static bool
+rdf_match_license(Inkscape::XML::Node const *repr, struct rdf_license_t const *license)
 {
     g_assert ( repr != NULL );
     g_assert ( license != NULL );
@@ -823,13 +848,13 @@ rdf_match_license ( Inkscape::XML::Node * repr, struct rdf_license_t * license )
 #endif
 
     int count = 0;
-    for (struct rdf_double_t details = license->details;
+    for (struct rdf_double_t const *details = license->details;
          details->name; details++ ) {
         count++;
     }
     bool * matched = (bool*)calloc(count,sizeof(bool));
 
-    for (Inkscape::XML::Node * current = sp_repr_children ( repr );
+    for (Inkscape::XML::Node const *current = sp_repr_children(repr);
          current;
          current = sp_repr_next ( current ) ) {
 
@@ -905,7 +930,7 @@ rdf_match_license ( Inkscape::XML::Node * repr, struct rdf_license_t * license )
 struct rdf_license_t *
 rdf_get_license(SPDocument * document)
 {
-    Inkscape::XML::Node repr = rdf_get_xml_repr ( document, XML_TAG_NAME_LICENSE, FALSE );
+    Inkscape::XML::Node const *repr = rdf_get_xml_repr ( document, XML_TAG_NAME_LICENSE, FALSE );
     if (repr) {
         for (struct rdf_license_t * license = rdf_licenses;
              license->name; license++ ) {
@@ -927,23 +952,26 @@ rdf_get_license(SPDocument * document)
  *  
  */
 void
-rdf_set_license(SPDocument * document, struct rdf_license_t const * license)
+rdf_set_license(SPDocument * doc, struct rdf_license_t const * license)
 {
     // drop old license section
-    Inkscape::XML::Node * repr = rdf_get_xml_repr ( document, XML_TAG_NAME_LICENSE, FALSE );
+    Inkscape::XML::Node * repr = rdf_get_xml_repr ( doc, XML_TAG_NAME_LICENSE, FALSE );
     if (repr) sp_repr_unparent(repr);
 
     if (!license) return;
 
     // build new license section
-    repr = rdf_get_xml_repr ( document, XML_TAG_NAME_LICENSE, TRUE );
+    repr = rdf_get_xml_repr ( doc, XML_TAG_NAME_LICENSE, TRUE );
     g_assert ( repr );
 
     repr->setAttribute("rdf:about", license->uri );
 
-    for (struct rdf_double_t * detail = license->details;
+    Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+    g_return_if_fail (xmldoc != NULL);
+
+    for (struct rdf_double_t const * detail = license->details;
          detail->name; detail++) {
-        Inkscape::XML::Node * child = sp_repr_new( detail->name );
+        Inkscape::XML::Node * child = xmldoc->createElement( detail->name );
         g_assert ( child != NULL );
 
         child->setAttribute("rdf:resource", detail->resource );
@@ -963,17 +991,19 @@ struct rdf_entity_default_t rdf_defaults[] = {
 };
 
 void
-rdf_set_defaults ( SPDocument * document )
+rdf_set_defaults ( SPDocument * doc )
 {
-    g_assert ( document != NULL );
+    g_assert ( doc != NULL );
 
     // Create metadata node if it doesn't already exist
-    if (!sp_item_group_get_child_by_name ((SPGroup *) document->root, NULL,
+    if (!sp_item_group_get_child_by_name ((SPGroup *) doc->root, NULL,
                                           XML_TAG_NAME_METADATA)) {
         // create repr
-        Inkscape::XML::Node * rnew = sp_repr_new (XML_TAG_NAME_METADATA);
+        Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+        g_return_if_fail (xmldoc != NULL);
+        Inkscape::XML::Node * rnew = xmldoc->createElement (XML_TAG_NAME_METADATA);
         // insert into the document
-        document->rroot->addChild(rnew, NULL);
+        doc->rroot->addChild(rnew, NULL);
         // clean up
         Inkscape::GC::release(rnew);
     }
@@ -985,8 +1015,8 @@ rdf_set_defaults ( SPDocument * document )
         struct rdf_work_entity_t * entity = rdf_find_entity ( rdf_default->name );
         g_assert ( entity != NULL );
 
-        if ( rdf_get_work_entity ( document, entity ) == NULL ) {
-            rdf_set_work_entity ( document, entity, rdf_default->text );
+        if ( rdf_get_work_entity ( doc, entity ) == NULL ) {
+            rdf_set_work_entity ( doc, entity, rdf_default->text );
         }
     }
 }