Index: src/sans/dataloader/readers/cansas_constants.py
===================================================================
--- src/sans/dataloader/readers/cansas_constants.py	(revision 76cd1aeb8047424a5dc9e1d0e5c3eaa0f17c3bb4)
+++ src/sans/dataloader/readers/cansas_constants.py	(revision e090c624be36edc71affcb29782996c8bb013693)
@@ -8,7 +8,48 @@
     format = ''
     
+    
     def __init__(self):
         self.ns = self.CANSAS_NS
         self.format = self.CANSAS_FORMAT
+    
+    
+    def _iterate_namespace(self, namespace):
+        """
+        Method to iterate through a cansas constants tree based on a list of
+        names
+        
+        :param namespace: A list of names that match the tree structure of
+            cansas_constants
+        """
+        # The current level to look through in cansas_constants.
+        return_me = currentLevel()
+        return_me.current_level = self.CANSAS_FORMAT.get("SASentry")
+        # Defaults for variable and datatype
+        return_me.ns_variable = "{0}.meta_data[\"{2}\"] = \"{1}\""
+        return_me.ns_datatype = "content"
+        return_me.ns_optional = True
+        for name in namespace:
+            if name != "SASentry":
+                return_me.current_level = \
+                        return_me.current_level.get("children").get(name, "")
+                if return_me.current_level == "":
+                    return_me.current_level = \
+                            return_me.current_level.get("<any>", "")
+                cl_variable = return_me.current_level.get("variable", "")
+                cl_datatype = return_me.current_level.get("storeas", "")
+                cl_units_optional = \
+                            return_me.current_level.get("units_required", "")
+                # Where are how to store the variable for the given namespace
+                # CANSAS_CONSTANTS tree is hierarchical, so is no value, inherit
+                return_me.ns_variable = cl_variable if cl_variable != "" else \
+                                    return_me.ns_variable
+                return_me.ns_datatype = cl_datatype if cl_datatype != "" else \
+                                    return_me.ns_datatype
+                return_me.ns_optional = cl_units_optional if \
+                                    cl_units_optional != return_me.ns_optional \
+                                    else return_me.ns_optional
+        return return_me    
+    
+    
     """
     CANSAS_NS holds the base namespace and the default schema file information
@@ -24,4 +65,5 @@
                           }
                  }
+    
     
     """
@@ -697,3 +739,15 @@
                                    }
                      }
-    
+   
+class currentLevel:
+     
+    current_level = ''
+    ns_variable = ''
+    ns_datatype = ''
+    ns_optional = True
+     
+    def __init__(self):
+        self.current_level = ''
+        self.ns_variable = ''
+        self.ns_datatype = "content"
+        self.ns_optional = True
Index: src/sans/dataloader/readers/cansas_reader.py
===================================================================
--- src/sans/dataloader/readers/cansas_reader.py	(revision 76cd1aeb8047424a5dc9e1d0e5c3eaa0f17c3bb4)
+++ src/sans/dataloader/readers/cansas_reader.py	(revision e090c624be36edc71affcb29782996c8bb013693)
@@ -40,24 +40,4 @@
 
 
-def write_node(doc, parent, name, value, attr={}):
-    """
-    :param doc: document DOM
-    :param parent: parent node
-    :param name: tag of the element
-    :param value: value of the child text node
-    :param attr: attribute dictionary
-    
-    :return: True if something was appended, otherwise False
-    """
-    if value is not None:
-        node = doc.createElement(name)
-        node.appendChild(doc.createTextNode(str(value)))
-        for item in attr:
-            node.setAttribute(item, attr[item])
-        parent.appendChild(node)
-        return True
-    return False
-                
-
 def get_content(location, node):
     """
@@ -101,14 +81,23 @@
 
 
-
-class CANSASError(Exception):
-    """Base class all CANSAS reader exceptions are derived"""
-    pass
-
-class NotCANSASFileError(CANSASError):
-    def __init__(self):
-        self.value = "This is not a proper CanSAS file."
-    def __str__(self):
-        return repr(self.value)
+def write_node(doc, parent, name, value, attr={}):
+    """
+    :param doc: document DOM
+    :param parent: parent node
+    :param name: tag of the element
+    :param value: value of the child text node
+    :param attr: attribute dictionary
+    
+    :return: True if something was appended, otherwise False
+    """
+    if value is not None:
+        node = doc.createElement(name)
+        node.appendChild(doc.createTextNode(str(value)))
+        for item in attr:
+            node.setAttribute(item, attr[item])
+        parent.appendChild(node)
+        return True
+    return False
+                
 
 class Reader():
@@ -274,34 +263,4 @@
         return name
     
-    def _iterate_namespace(self, namespace):
-        """
-        Method to iterate through a cansas constants tree based on a list of
-        names
-        
-        :param namespace: A list of names that match the tree structure of
-            cansas_constants
-        """
-        # The current level to look through in cansas_constants.
-        current_level = CANSAS_FORMAT.get("SASentry")
-        # Defaults for variable and datatype
-        ns_variable = "{0}.meta_data[\"{2}\"] = \"{1}\""
-        ns_datatype = "content"
-        ns_optional = True
-        for name in namespace:
-            if name != "SASentry":
-                current_level = current_level.get("children").get(name, "")
-                if current_level == "":
-                    current_level = current_level.get("<any>", "")
-                cl_variable = current_level.get("variable", "")
-                cl_datatype = current_level.get("storeas", "")
-                cl_units_optional = current_level.get("units_required", "")
-                # Where are how to store the variable for the given namespace
-                # CANSAS_CONSTANTS tree is hierarchical, so is no value, inherit
-                ns_variable = cl_variable if cl_variable != "" else ns_variable
-                ns_datatype = cl_datatype if cl_datatype != "" else ns_datatype
-                ns_optional = cl_units_optional if cl_units_optional != \
-                                    ns_optional else ns_optional
-        return current_level, ns_variable, ns_datatype, ns_optional
-    
     
     def _unit_conversion(self, new_current_level, attr, data1d, \
@@ -397,7 +356,8 @@
                 ns.append(tagname)
                 attr = node.attrib
+                children = node.getchildren()
+                save_data1d = data1d
                 
                 # Look for special cases
-                save_data1d = data1d
                 if tagname == "SASdetector":
                     data1d = Detector()
@@ -420,11 +380,24 @@
                 elif tagname == "aperture":
                     data1d = Aperture()
-                
+                if tagname == "Idata" and children is not None:
+                    dql = 0
+                    dqw = 0
+                    for child in children:
+                        tag = child.tag.replace(base_ns, "")
+                        if tag == "dQl":
+                            dql = 1
+                        if tag == "dQw":
+                            dqw = 1
+                    if dqw == 1 and dql == 0:
+                        data1d.dxl = numpy.append(data1d.dxl, 0.0)
+                    elif dql == 1 and dqw == 0:
+                        data1d.dxw = numpy.append(data1d.dxw, 0.0)
+                                
                 # Get where to store content
-                new_current_level, ns_var, ns_datatype, \
-                                    optional = self._iterate_namespace(ns)
+                cs_values = constants._iterate_namespace(ns)
                 # If the element is a child element, recurse
-                if node.getchildren() is not None:
-                    # Returned value is new Data1D object with all previous and new values in it.
+                if children is not None:
+                    # Returned value is new Data1D object with all previous and 
+                    # new values in it.
                     data1d, extras = self._parse_entry(node, ns, data1d, extras)
                     
@@ -437,22 +410,28 @@
                 
                 # If the value is a float, compile with units.
-                if ns_datatype == "float":
+                if cs_values.ns_datatype == "float":
                     # If an empty value is given, store as zero.
                     if node_value is None or node_value.isspace() \
                                             or node_value.lower() == "nan":
                         node_value = "0.0"
-                    node_value, unit = self._unit_conversion(new_current_level,\
-                                             attr, data1d, node_value, optional)
+                    node_value, unit = self._unit_conversion(\
+                                cs_values.current_level, attr, data1d, \
+                                node_value, cs_values.ns_optional)
                     
-                # If appending to a dictionary (meta_data | run_name), name sure the key is unique
-                if ns_var == "{0}.meta_data[\"{2}\"] = \"{1}\"":
-                    # If we are within a Process, Detector, Collimation or Aperture instance, pull out old data1d
-                    tagname = self._create_unique_key(data1d.meta_data, tagname, 0)
+                # If appending to a dictionary (meta_data | run_name)
+                # make sure the key is unique
+                if cs_values.ns_variable == "{0}.meta_data[\"{2}\"] = \"{1}\"":
+                    # If we are within a Process, Detector, Collimation or 
+                    # Aperture instance, pull out old data1d
+                    tagname = self._create_unique_key(data1d.meta_data, \
+                                                      tagname, 0)
                     if isinstance(data1d, Data1D) == False:
-                        store_me = ns_var.format("data1d", node_value, tagname)
+                        store_me = cs_values.ns_variable.format("data1d", \
+                                                            node_value, tagname)
                         extras.append(store_me)
-                        ns_var = None
-                if ns_var == "{0}.run_name[\"{2}\"] = \"{1}\"":
-                    tagname = self._create_unique_key(data1d.run_name, tagname, 0)
+                        cs_values.ns_variable = None
+                if cs_values.ns_variable == "{0}.run_name[\"{2}\"] = \"{1}\"":
+                    tagname = self._create_unique_key(data1d.run_name, \
+                                                      tagname, 0)
                 
                 # Check for Data1D object and any extra commands to save
@@ -461,8 +440,8 @@
                         exec item
                 # Don't bother saving empty information unless it is a float
-                if ns_var is not None and node_value is not None and \
+                if cs_values.ns_variable is not None and node_value is not None and \
                             node_value.isspace() == False:
                     # Format a string and then execute it.
-                    store_me = ns_var.format("data1d", node_value, tagname)
+                    store_me = cs_values.ns_variable.format("data1d", node_value, tagname)
                     exec store_me
                 # Get attributes and process them
@@ -470,5 +449,6 @@
                     for key in node.keys():
                         try:
-                            cansas_attrib = new_current_level.get("attributes").get(key)
+                            cansas_attrib = \
+                            cs_values.current_level.get("attributes").get(key)
                             attrib_variable = cansas_attrib.get("variable")
                             if key == 'unit' and unit != '':
@@ -525,6 +505,5 @@
         main_node.setAttribute("xmlns:xsi",
                                "http://www.w3.org/2001/XMLSchema-instance")
-        main_node.setAttribute("xsi:schemaLocation",
-                               "{0} http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd".format(ns))
+        main_node.setAttribute("xsi:schemaLocation", "{0} http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd".format(ns))
         
         doc.appendChild(main_node)
