Author: jackson
Date: 2007-06-13 01:58:43 -0400 (Wed, 13 Jun 2007)
New Revision: 79379

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/xaml.cpp
Log:

        * xaml.cpp: When using the xaml_create_from_str we automatically
        add the default and x: namespaces.



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-06-13 05:57:33 UTC (rev 79378)
+++ trunk/moon/src/ChangeLog    2007-06-13 05:58:43 UTC (rev 79379)
@@ -1,3 +1,8 @@
+2007-06-13  Jackson Harper  <[EMAIL PROTECTED]>
+
+       * xaml.cpp: When using the xaml_create_from_str we automatically
+       add the default and x: namespaces.
+
 2007-06-12  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        * ffvideo.cpp: Fixed to subclass the new MediaElement class.

Modified: trunk/moon/src/xaml.cpp
===================================================================
--- trunk/moon/src/xaml.cpp     2007-06-13 05:57:33 UTC (rev 79378)
+++ trunk/moon/src/xaml.cpp     2007-06-13 05:58:43 UTC (rev 79379)
@@ -60,10 +60,13 @@
        GHashTable *namespace_map;
        GString *char_data_buffer;
 
+       bool implicit_default_namespace;
+
        int state;
        
        XamlParserInfo (XML_Parser parser) : parser (parser), top_element 
(NULL), current_element (NULL),
-                                            current_namespace (NULL), 
char_data_buffer (NULL), top_kind(Value::INVALID)
+                                            current_namespace (NULL), 
char_data_buffer (NULL), top_kind (Value::INVALID),
+                                            implicit_default_namespace (false)
        {
                namespace_map = g_hash_table_new (g_str_hash, g_str_equal);
        }
@@ -228,15 +231,19 @@
 {
        XamlParserInfo *p = (XamlParserInfo *) data;
        char **name = g_strsplit (el, "|", -1);
+       char *element;
+       
+       if (name [1]) {
+               // Find the proper namespace
+               p->current_namespace = (XamlNamespace *) g_hash_table_lookup 
(p->namespace_map, name [0]);
+               element = name [1];
+       } else if (p->implicit_default_namespace) {
+               p->current_namespace = default_namespace;
+               element = name [0];
+       }
 
-       g_assert (name [1]); // No namespace ??
+       start_element (data, element, attr);
 
-       // Find the proper namespace
-
-       p->current_namespace = default_namespace;
-
-       start_element (data, name [1], attr);
-
        g_strfreev (name);
 }
 
@@ -304,6 +311,14 @@
 }
 
 void
+add_default_namespaces (XamlParserInfo *p)
+{
+       p->implicit_default_namespace = true;
+       g_hash_table_insert (p->namespace_map, (char *) 
"http://schemas.microsoft.com/winfx/2006/xaml/presentation";, default_namespace);
+       g_hash_table_insert (p->namespace_map, (char *) 
"http://schemas.microsoft.com/winfx/2006/xaml";, x_namespace);
+}
+
+void
 free_recursive (XamlElementInstance *el)
 {
        
@@ -405,6 +420,10 @@
        }
 
        parser_info = new XamlParserInfo (p);
+
+       // from_str gets the default namespaces implictly added
+       add_default_namespaces (parser_info);
+
        XML_SetUserData (p, parser_info);
 
        XML_SetElementHandler (p, start_element_handler, end_element_handler);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to