diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c
index 1a312c0..727101f 100644
--- a/gio/glib-compile-schemas.c
+++ b/gio/glib-compile-schemas.c
@@ -838,6 +838,7 @@ schema_state_free (gpointer data)
 
 static void
 schema_state_add_child (SchemaState  *state,
+                        GHashTable   *schemas,
                         const gchar  *name,
                         const gchar  *schema,
                         GError      **error)
@@ -857,6 +858,28 @@ schema_state_add_child (SchemaState  *state,
       return;
     }
 
+  if (!g_hash_table_lookup (schemas, schema))
+    {
+      g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
+                   _("<schema id='%s'> not (yet) defined."), schema);
+
+      {
+        /* For now we only want to print a scary warning.  In the
+         * future, we will give a hard error.
+         *
+         * See bug #646039.
+         */
+
+        if (error)
+          {
+            g_printerr ("*** WARNING ***: %s\n", (*error)->message);
+            g_clear_error (error);
+          }
+      }
+
+      return;
+    }
+
   g_hash_table_insert (state->keys, childname,
                        key_state_new_child (schema));
 }
@@ -1305,6 +1328,7 @@ start_element (GMarkupParseContext  *context,
 
           if (COLLECT (STRING, "name", &name, STRING, "schema", &schema))
             schema_state_add_child (state->schema_state,
+                                    state->schema_table,
                                     name, schema, error);
           return;
         }
