def get_record_rich(self, filename, ref_extract_callback=None):
self.document = parse(filename)<EOL>rec = create_record()<EOL>articles = self.document.getElementsByTagName('<STR_LIT>')<EOL>for article in articles:<EOL><INDENT>article_type = article.getAttribute('<STR_LIT>')<EOL>if not article_type == '<STR_LIT>':<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>doi = get_value_in_tag(self.document, '<STR_LIT>')<EOL>date = '<STR_LIT>'<EOL>for tag in self.document.getElementsByTagName('<STR_LIT>'):<EOL><INDENT>year = get_value_in_tag(tag, '<STR_LIT>')<EOL>month = get_value_in_tag(tag, '<STR_LIT>').zfill(<NUM_LIT:2>)<EOL>day = get_value_in_tag(tag, '<STR_LIT>').zfill(<NUM_LIT:2>)<EOL>date = "<STR_LIT>" % (year, month, day)<EOL><DEDENT>if not date:<EOL><INDENT>for tag in self.document.getElementsByTagName('<STR_LIT>'):<EOL><INDENT>year = get_value_in_tag(tag, '<STR_LIT>')<EOL>month = get_value_in_tag(tag, '<STR_LIT>').zfill(<NUM_LIT:2>)<EOL>day = get_value_in_tag(tag, '<STR_LIT>').zfill(<NUM_LIT:2>)<EOL>date = "<STR_LIT>" % (year, month, day)<EOL><DEDENT><DEDENT>first_page = get_value_in_tag(article, '<STR_LIT>')<EOL>last_page = get_value_in_tag(article, '<STR_LIT>')<EOL>subjects = article.getElementsByTagName('<STR_LIT>')<EOL>subjects = map(xml_to_text, subjects)<EOL>subject = '<STR_LIT:U+002CU+0020>'.join(subjects)<EOL>copyright_statement = get_value_in_tag(article, '<STR_LIT>')<EOL><DEDENT>journal = get_value_in_tag(self.document, '<STR_LIT>')<EOL>journal, volume = fix_journal_name(journal, self.journal_mappings)<EOL>issues = self.document.getElementsByTagName('<STR_LIT>')<EOL>for issue in issues:<EOL><INDENT>volume += get_value_in_tag(issue, '<STR_LIT>')<EOL>year = get_value_in_tag(issue, '<STR_LIT>')<EOL><DEDENT>title = get_value_in_tag(self.document, '<STR_LIT>')<EOL>authors = self.document.getElementsByTagName('<STR_LIT>')<EOL>affiliations = self.document.getElementsByTagName('<STR_LIT>')<EOL>def affiliation_pair(a):<EOL><INDENT>return a.getAttribute('<STR_LIT>'), get_value_in_tag(<EOL>a, '<STR_LIT>'<EOL>)<EOL><DEDENT>affiliations = map(affiliation_pair, affiliations)<EOL>affiliations = dict(affiliations)<EOL>def author_pair(a):<EOL><INDENT>surname = get_value_in_tag(a, '<STR_LIT>')<EOL>first_name = get_value_in_tag(a, '<STR_LIT>')<EOL>middle_name = get_value_in_tag(a, '<STR_LIT>')<EOL>if middle_name:<EOL><INDENT>name = '<STR_LIT>' % (surname, first_name, middle_name)<EOL><DEDENT>else:<EOL><INDENT>name = '<STR_LIT>' % (surname, first_name)<EOL><DEDENT>try:<EOL><INDENT>affid = a.getElementsByTagName(<EOL>'<STR_LIT>'<EOL>)[<NUM_LIT:0>].getAttribute('<STR_LIT>')<EOL>affiliation = affiliations[affid]<EOL><DEDENT>except IndexError:<EOL><INDENT>affiliation = '<STR_LIT>'<EOL><DEDENT>except KeyError:<EOL><INDENT>affiliation = '<STR_LIT>'<EOL><DEDENT>return name, affiliation<EOL><DEDENT>authors = map(author_pair, authors)<EOL>abstract = get_value_in_tag(self.document, '<STR_LIT>')<EOL>references = self.document.getElementsByTagName('<STR_LIT>')<EOL>for reference in references:<EOL><INDENT>subfields = []<EOL>label = reference.getAttribute('<STR_LIT:N>')<EOL>if label:<EOL><INDENT>subfields.append(('<STR_LIT:o>', label))<EOL><DEDENT>bibliosets = reference.getElementsByTagName('<STR_LIT>')<EOL>for tag in bibliosets:<EOL><INDENT>ref_year = get_value_in_tag(tag, '<STR_LIT>')<EOL>ref_journal = get_value_in_tag(tag, '<STR_LIT>')<EOL>ref_journal, ref_volume = fix_journal_name(<EOL>ref_journal, self.journal_mappings<EOL>)<EOL>ref_volume += get_value_in_tag(tag, '<STR_LIT>')<EOL>ref_page = get_value_in_tag(tag, '<STR_LIT>')<EOL>if ref_year:<EOL><INDENT>subfields.append(('<STR_LIT:y>', ref_year))<EOL><DEDENT>if ref_journal and ref_volume and ref_page:<EOL><INDENT>subfields.append(('<STR_LIT:s>', '<STR_LIT>' % (ref_journal,<EOL>ref_volume,<EOL>ref_page)))<EOL><DEDENT>reference.removeChild(tag)<EOL><DEDENT>text_ref = xml_to_text(reference)<EOL>if ref_extract_callback:<EOL><INDENT>ref_xml = ref_extract_callback(text_ref)<EOL>dom = parseString(ref_xml)<EOL>fields = dom.getElementsByTagName("<STR_LIT>")[<NUM_LIT:0>]<EOL>fields = fields.getElementsByTagName("<STR_LIT>")<EOL>if fields:<EOL><INDENT>subfields.append(('<STR_LIT>', '<STR_LIT>'))<EOL><DEDENT>for field in fields:<EOL><INDENT>data = field.firstChild.data<EOL>code = field.getAttribute("<STR_LIT:code>")<EOL>if code == '<STR_LIT:m>' and bibliosets:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>subfields.append((code, data))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>subfields.append(('<STR_LIT:m>', text_ref))<EOL><DEDENT>if subfields:<EOL><INDENT>record_add_field(rec, '<STR_LIT>', ind1='<STR_LIT:C>', ind2='<STR_LIT:5>',<EOL>subfields=subfields)<EOL><DEDENT><DEDENT>if title:<EOL><INDENT>record_add_field(rec, '<STR_LIT>', subfields=[('<STR_LIT:a>', title)])<EOL><DEDENT>if date:<EOL><INDENT>record_add_field(rec, '<STR_LIT>', subfields=[('<STR_LIT:c>', date),<EOL>('<STR_LIT:t>', '<STR_LIT>')])<EOL><DEDENT>if doi:<EOL><INDENT>record_add_field(rec, '<STR_LIT>', ind1='<STR_LIT>', subfields=[('<STR_LIT:a>', doi),<EOL>('<STR_LIT:2>', '<STR_LIT>')])<EOL><DEDENT>if abstract:<EOL><INDENT>record_add_field(rec, '<STR_LIT>', subfields=[('<STR_LIT:a>', abstract),<EOL>('<STR_LIT>', '<STR_LIT>')])<EOL><DEDENT>first_author = True<EOL>for author in authors:<EOL><INDENT>if first_author:<EOL><INDENT>subfields = [('<STR_LIT:a>', author[<NUM_LIT:0>])]<EOL>if author[<NUM_LIT:1>]:<EOL><INDENT>subfields.append(('<STR_LIT:v>', author[<NUM_LIT:1>]))<EOL><DEDENT>record_add_field(rec, '<STR_LIT:100>', subfields=subfields)<EOL>first_author = False<EOL><DEDENT>else:<EOL><INDENT>subfields = [('<STR_LIT:a>', author[<NUM_LIT:0>])]<EOL>if author[<NUM_LIT:1>]:<EOL><INDENT>subfields.append(('<STR_LIT:v>', author[<NUM_LIT:1>]))<EOL><DEDENT>record_add_field(rec, '<STR_LIT>', subfields=subfields)<EOL><DEDENT><DEDENT>subfields = []<EOL>if journal and volume and first_page:<EOL><INDENT>subfields.append(('<STR_LIT:s>', "<STR_LIT>" % (journal,<EOL>volume,<EOL>first_page)))<EOL><DEDENT>if first_page and last_page:<EOL><INDENT>try:<EOL><INDENT>nuber_of_pages = int(last_page) - int(first_page)<EOL>record_add_field(rec, '<STR_LIT>',<EOL>subfields=[('<STR_LIT:a>', str(nuber_of_pages))])<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT>subfields.append(('<STR_LIT:c>', '<STR_LIT>' % (first_page,<EOL>last_page)))<EOL><DEDENT>if year:<EOL><INDENT>subfields.append(('<STR_LIT:y>', year))<EOL><DEDENT>record_add_field(rec, '<STR_LIT>', subfields=subfields)<EOL>record_add_field(rec, '<STR_LIT>', subfields=[('<STR_LIT:a>', '<STR_LIT>')])<EOL>if copyright_statement:<EOL><INDENT>record_add_field(rec, '<STR_LIT>',<EOL>subfields=[('<STR_LIT:f>', copyright_statement)])<EOL><DEDENT>if subject:<EOL><INDENT>record_add_field(rec, '<STR_LIT>', ind1='<STR_LIT:1>', ind2='<STR_LIT>',<EOL>subfields=[('<STR_LIT:2>', '<STR_LIT>'),<EOL>('<STR_LIT:a>', subject)])<EOL><DEDENT>try:<EOL><INDENT>return record_xml_output(rec)<EOL><DEDENT>except UnicodeDecodeError:<EOL><INDENT>message = "<STR_LIT>" + doi<EOL>sys.stderr.write(message)<EOL>return "<STR_LIT>"<EOL><DEDENT>
Gets the Marc xml of the files in xaml_rich directory

:param fileName: the name of the file to parse.
:type fileName: string

:returns: a string with the marc xml version of the file.