def processResourceElement(d, element):
     uri = xpathFirst(element, '@rdf:about')
     if uri:
         d['@id'] = uri
     elementCurie = tagToCurie(element.tag)
     if elementCurie != 'rdf:Description' and not elementCurie in TYPES_TO_IGNORE:
         d['@type'] = elementCurie
     for child in element.iterchildren(tag=Element):
         processRelationElement(d, child)
def fieldsFromAnnotation(lxmlNode):
    for annotation in lxmlNode.getchildren():
        if annotation.tag == curieToTag('oa:Annotation'):
            for child in annotation.iterchildren():
                fieldname = tagToCurie(child.tag)
                if child.tag != HAS_BODY:
                    yield fieldname + ".uri", child.attrib.get(RDF_RESOURCE)
                else:
                    bodyNode = child.getchildren()[0]
                    for bodyChildNode in bodyNode.iterchildren():
                        yield _yieldField(bodyChildNode)
 def processRelationElement(d, element):
     try:
         elementCurie = tagToCurie(element.tag)
     except KeyError:
         return
     if elementCurie == 'prov:wasDerivedFrom':
         return
     objects = []
     value = element.text
     if value and value.strip():
         value = value.strip()
         if elementCurie in DECIMAL_VALUE_RELATIONS:
             value = Decimal(value)
         if elementCurie in SINGLE_LITERAL_VALUE_RELATIONS:
             d[elementCurie] = value
             return
         objects.append(value)
     uri = xpathFirst(element, '@rdf:resource')
     if uri:
         if elementCurie == 'rdf:type':
             typeCurie = uriToCurie(uri)
             if not typeCurie in TYPES_TO_IGNORE:
                 d['@type'] = typeCurie
             return
         value = uri
         if not uri in urisResolved:
             urisResolved.add(uri)
             descriptionElement = xpathFirst(rdf, '//*[@rdf:about="%s"]' % uri)
             if not descriptionElement is None:
                 value = {}
                 processResourceElement(value, descriptionElement)
         objects.append(value)
     for child in element.iterchildren(tag=Element):
         resourceDict = {}
         processResourceElement(resourceDict, child)
         objects.append(resourceDict)
     if objects:
         d.setdefault(elementCurie, []).extend(objects)
         prefix, _, _ = elementCurie.partition(':')
         context[prefix] = namespaces[prefix]
         if elementCurie in RESOURCE_RELATIONS:
             context[elementCurie] = {"@type": "@id"}