Пример #1
0
    def parse(self, xml, namespace):
        matches = xpath.find_all(xml, self.xpath, namespace)

        if not BaseField in self.field_type.__bases__:
            
            results = [self.field_type(xml=match) for match in matches]
        else:
            field = self.field_type(xpath = '.')
            results = [field.parse(xpath.domify(match), namespace) for match in matches]
        if self.order_by:
            results.sort(lambda a,b : cmp(getattr(a, self.order_by), getattr(b, self.order_by)))
        return results
Пример #2
0
    def parse(self, xml, namespace):
        matches = xpath.find_all(xml, self.xpath, namespace)

        if not BaseField in self.field_type.__bases__:

            results = [self.field_type(xml=match) for match in matches]
        else:
            field = self.field_type(xpath='.')
            results = [
                field.parse(xpath.domify(match), namespace)
                for match in matches
            ]
        if self.order_by:
            results.sort(lambda a, b: cmp(getattr(a, self.order_by),
                                          getattr(b, self.order_by)))
        return results
Пример #3
0
 def parse(self, xml, namespace):
     match = xpath.find_all(xml, self.xpath, namespace)
     if len(match) == 1:
         return self.field_type(xml=match[0])
     return None
Пример #4
0
 def parse(self, xml, namespace):
     match = xpath.find_all(xml, self.xpath, namespace)
     if len(match) == 1:
         return self.field_type(xml=match[0])
     return None