def __init__(self, node):
     """
     Iterate the provided DOM Node, parsing the facet name and any child
     value counts.  Facet values are additionally merged into a tree
     structure based on common name prefixes, and then flattened out again.
     This allows for parent-child relationships and nested value counts.
     See merge_values.
     
     Parses the facet counts into this Result's facets list.
     
     Takes a parsed xml document.
     """
     (self.name, self.values) = (xmlutils.get_attribute(node, "name"), [])
     
     for c in xmlutils.get_child_nodes(node, "int"):
         
         value = xmlutils.get_attribute(c, "name")
         count = xmlutils.get_int(c)
         self.values.append(self.create_value(value, count))
     
     self.merge_values()
Exemple #2
0
 def _parse_results(self):
     """
     Parse the results array into the documents list.  Each resulting
     document element is a dictionary. 
     """
     result = self._get_result_node()
     
     if not result:
         raise ValueError, "Results contained no result."
     
     self.count = int(xmlutils.get_attribute(result, "numFound"))
     
     for d in xmlutils.get_child_nodes(result, "doc"):
         data_dict = xmlutils.get_dictionary(d)
         document = registry[data_dict['model']](data_dict)
         self.documents.append(document)