def createSectionXML(self, doc, issue_data, title, abbrev):
     section = doc.createElement('section')
     section_title_tag = self.createXMLTextTag(doc, 'title', title)
     abbrev_tag = self.createXMLTextTag(doc, 'abbrev', abbrev)
     locale = tools.convertLangToLocale(issue_data['DocLanguage'])
     abbrev_tag.setAttribute('locale', locale)
     section.appendChild(section_title_tag)
     section.appendChild(abbrev_tag)
     
     return section
 def createArticleXML(self, doc, article, date_published):
     '''
     Given an article dict, create the OJS XML
     corresponding to this data
     '''
     #=======================================================================
     # Create article stub with title
     #=======================================================================
     article_tag = doc.createElement('article')
     doc_language = tools.convertLangToLocale(article['DocLanguage'])
     article_tag.setAttribute('locale',doc_language)
     article_tag.setAttribute('language',article['DocLanguage'])
     title_tag = self.createXMLTextTag(doc, 'title', article['TitleDocMain'])
     article_tag.appendChild(title_tag)
     #=======================================================================
     # Add DBC-id to article
     #=======================================================================
     '''
     this code causes OJS to panic - we don't know why it should be here.
     so we're killing it.
     dbc_marcx_id = article['dbcMarcxID'] if 'dbcMarcxID' in article else ''
     dbc_id_tag = self.createXMLTextTag(doc, 'id', dbc_marcx_id)
     dbc_id_tag.setAttribute('type','dbcMarcxID')
     article_tag.appendChild(dbc_id_tag)
     '''
     #=======================================================================
     # Add page range
     #=======================================================================
     start_page = article['start_page']
     end_page = article['end_page']
     # legr: Calculate offset so real start- and end page can be forwarded to OJS
     offset = self.get_calculated_offset()
     if offset == 0:
         print("Warning: offset = 0. Maybe all pages are uncounted?")
     else:
         print("Information: Calculated offset value: {0}".format(offset))
     page_range = "{0}-{1}".format(start_page + offset, end_page + offset)
     pages_tag = self.createXMLTextTag(doc, 'pages', page_range)
     article_tag.appendChild(pages_tag)
     #=======================================================================
     # Add date published tag
     #=======================================================================
     published_tag = self.createXMLTextTag(doc, 'date_published', date_published) 
     article_tag.appendChild(published_tag)
     #=======================================================================
     # Add authors
     #=======================================================================
     # don't add an author tag if we don't have one (e.g. Front Matter)
     if 'Author' in article: #Author is a list of zero, one or multuple authors
         for author in article['Author']:
             author_tag = self.createAuthorXML(doc, author)
             article_tag.appendChild(author_tag)
     #=======================================================================
     # Add subjects
     # see http://pkp.sfu.ca/wiki/index.php/Importing_and_Exporting_Data#Creating_the_XML_Import_File
     #=======================================================================
     if 'Subject' in article: #Author is a list of zero, one or multuple authors
         indexing_tag = doc.createElement('indexing')
         subjects = ''
         if isinstance(article['Subject'],list):
             subjects = ';'.join(article['Subject'])
         else:
             subjects = article['Subject']
         subject_tag = self.createXMLTextTag(doc,'subject',subjects) 
         subject_tag.setAttribute('locale',tools.convertLangToLocale('da'))
         indexing_tag.appendChild(subject_tag)
         article_tag.appendChild(indexing_tag)
     #=======================================================================
     # Add pdf-link
     #=======================================================================
     md5_hash = tools.getHashName(article['TitleDocMain'])
     pdf_name = tools.getArticleName(md5_hash, start_page,end_page)
     galley_tag = self.createGalleyXML(doc, pdf_name)
     article_tag.appendChild(galley_tag)
     return article_tag