- def __init__(self, edoc, parse_dublincore=True, provider=None):
- self.edoc = edoc
- self.provider = provider
-
- root_elem = edoc.getroot()
-
- dc_path = './/' + RDFNS('RDF')
+ _edoc = None
+ @property
+ def edoc(self):
+ if self._edoc is None:
+ data = self.source.get_string()
+ if not isinstance(data, unicode):
+ data = data.decode('utf-8')
+ data = data.replace(u'\ufeff', '')
+ try:
+ parser = etree.XMLParser(remove_blank_text=False)
+ self._edoc = etree.parse(StringIO(data.encode('utf-8')), parser)
+ except (ExpatError, XMLSyntaxError, XSLTApplyError), e:
+ raise ParseError(e)
+ return self._edoc
+
+ _rdf_elem = None
+ @property
+ def rdf_elem(self):
+ if self._rdf_elem is None:
+ dc_path = './/' + RDFNS('RDF')
+ self._rdf_elem = self.edoc.getroot().find(dc_path)
+ if self._rdf_elem is None:
+ raise NoDublinCore('Document has no DublinCore - which is required.')
+ return self._rdf_elem