[Lxml-checkins] r42246 - lxml/trunk/src/lxml

scoder at codespeak.net scoder at codespeak.net
Sun Apr 22 22:04:11 CEST 2007


Author: scoder
Date: Sun Apr 22 22:04:11 2007
New Revision: 42246

Modified:
   lxml/trunk/src/lxml/objectify.pyx
Log:
define XMLSchema namespace in objectify and provide default nsmap in DataElement

Modified: lxml/trunk/src/lxml/objectify.pyx
==============================================================================
--- lxml/trunk/src/lxml/objectify.pyx	(original)
+++ lxml/trunk/src/lxml/objectify.pyx	Sun Apr 22 22:04:11 2007
@@ -101,7 +101,12 @@
 setPytypeAttributeTag()
 
 
-# namespace for XML Schema instance
+# namespaces for XML Schema
+cdef object XML_SCHEMA_NS
+XML_SCHEMA_NS = "http://www.w3.org/2001/XMLSchema"
+cdef char* _XML_SCHEMA_NS
+_XML_SCHEMA_NS = _cstr(XML_SCHEMA_NS)
+
 cdef object XML_SCHEMA_INSTANCE_NS
 XML_SCHEMA_INSTANCE_NS = "http://www.w3.org/2001/XMLSchema-instance"
 cdef char* _XML_SCHEMA_INSTANCE_NS
@@ -1694,7 +1699,9 @@
 XML = fromstring
 
 cdef object _DEFAULT_NSMAP
-_DEFAULT_NSMAP = { "py": PYTYPE_NAMESPACE, "xsi": XML_SCHEMA_INSTANCE_NS }
+_DEFAULT_NSMAP = { "py"  : PYTYPE_NAMESPACE,
+                   "xsi" : XML_SCHEMA_INSTANCE_NS,
+                   "xsd" : XML_SCHEMA_NS}
 
 def Element(_tag, attrib=None, nsmap=None, _pytype=None, **_attributes):
     """Objectify specific version of the lxml.etree Element() factory that
@@ -1722,6 +1729,8 @@
     if the type can be identified.  If '_pytype' or '_xsi' are among the
     keyword arguments, they will be used instead.
     """
+    if nsmap is None:
+        nsmap = _DEFAULT_NSMAP
     if attrib is not None:
         if python.PyDict_Size(_attributes):
             attrib.update(_attributes)


More information about the lxml-checkins mailing list