def _create_record_lxml(marcxml,<EOL>verbose=CFG_BIBRECORD_DEFAULT_VERBOSE_LEVEL,<EOL>correct=CFG_BIBRECORD_DEFAULT_CORRECT,<EOL>keep_singletons=CFG_BIBRECORD_KEEP_SINGLETONS):
parser = etree.XMLParser(dtd_validation=correct,<EOL>recover=(verbose <= <NUM_LIT:3>))<EOL>if correct:<EOL><INDENT>marcxml = '<STR_LIT>''<STR_LIT>' % (marcxml,)<EOL><DEDENT>try:<EOL><INDENT>tree = etree.parse(StringIO(marcxml), parser)<EOL><DEDENT>except Exception as e:<EOL><INDENT>raise InvenioBibRecordParserError(str(e))<EOL><DEDENT>record = {}<EOL>field_position_global = <NUM_LIT:0><EOL>controlfield_iterator = tree.iter(tag='<STR_LIT>')<EOL>for controlfield in controlfield_iterator:<EOL><INDENT>tag = controlfield.attrib.get('<STR_LIT>', '<STR_LIT:!>').encode("<STR_LIT>")<EOL>ind1 = '<STR_LIT:U+0020>'<EOL>ind2 = '<STR_LIT:U+0020>'<EOL>text = controlfield.text<EOL>if text is None:<EOL><INDENT>text = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>text = text.encode("<STR_LIT>")<EOL><DEDENT>subfields = []<EOL>if text or keep_singletons:<EOL><INDENT>field_position_global += <NUM_LIT:1><EOL>record.setdefault(tag, []).append((subfields, ind1, ind2, text,<EOL>field_position_global))<EOL><DEDENT><DEDENT>datafield_iterator = tree.iter(tag='<STR_LIT>')<EOL>for datafield in datafield_iterator:<EOL><INDENT>tag = datafield.attrib.get('<STR_LIT>', '<STR_LIT:!>').encode("<STR_LIT>")<EOL>ind1 = datafield.attrib.get('<STR_LIT>', '<STR_LIT:!>').encode("<STR_LIT>")<EOL>ind2 = datafield.attrib.get('<STR_LIT>', '<STR_LIT:!>').encode("<STR_LIT>")<EOL>if ind1 in ('<STR_LIT>', '<STR_LIT:_>'):<EOL><INDENT>ind1 = '<STR_LIT:U+0020>'<EOL><DEDENT>if ind2 in ('<STR_LIT>', '<STR_LIT:_>'):<EOL><INDENT>ind2 = '<STR_LIT:U+0020>'<EOL><DEDENT>subfields = []<EOL>subfield_iterator = datafield.iter(tag='<STR_LIT>')<EOL>for subfield in subfield_iterator:<EOL><INDENT>code = subfield.attrib.get('<STR_LIT:code>', '<STR_LIT:!>').encode("<STR_LIT>")<EOL>text = subfield.text<EOL>if text is None:<EOL><INDENT>text = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>text = text.encode("<STR_LIT>")<EOL><DEDENT>if text or keep_singletons:<EOL><INDENT>subfields.append((code, text))<EOL><DEDENT><DEDENT>if subfields or keep_singletons:<EOL><INDENT>text = '<STR_LIT>'<EOL>field_position_global += <NUM_LIT:1><EOL>record.setdefault(tag, []).append((subfields, ind1, ind2, text,<EOL>field_position_global))<EOL><DEDENT><DEDENT>return record<EOL>
Create a record object using the LXML parser.

If correct == 1, then perform DTD validation
If correct == 0, then do not perform DTD validation

If verbose == 0, the parser will not give warnings.
If 1 <= verbose <= 3, the parser will not give errors, but will warn
    the user about possible mistakes (implement me!)
If verbose > 3 then the parser will be strict and will stop in case of
    well-formedness errors or DTD errors.