def createArticles(self,section,section_type):
     if not mets_tools.docTypeExists(self.meta_data, section_type):
         # Create section, e.g. FrontMatter if it doesn't exists
         section_data = {'doc_type': section_type,'content': [{'name':'TitleDocMain','data':section_type}]}
         self.meta_data = mets_tools.addNewDocStruct(self.meta_data,section_data)
     articles = section.articles
     #TODO: Create articles-docstruct if not already there
     section_attrib = ('TYPE',section_type)
     for article in articles:
         article_data = self.createArticleData(article)
         if article_data and not self.articleExists(article_data):
             self.meta_data = mets_tools.addNewDocStruct(self.meta_data,
                                                         article_data,
                                                         section_attrib)
    for item in required_fields:
        if item not in data: 
            raise DataError("{0} missing value {1}".format(anchor_file, item))
    return data

if __name__ == '__main__':
    image_src = '/opt/digiverso/goobi/metadata/201/images/master_orig'
    src = '/opt/digiverso/goobi/metadata/201/meta.xml'
    #src = '/opt/digiverso/goobi/metadata/194/meta - complete data.xml'
    dest = os.path.join(os.path.dirname(src),'meta_new.xml')
    dict_tree,ns  = dict_tools.parseXmlToDict(src)
    
    # Add images - i.e. create phys struct map, file sec and set pathimages
    if not mets_tools.containsImages(dict_tree):
        dict_tree = mets_tools.addImages(dict_tree,image_src) 
    
    content = [{'name': 'Abstract', 'data' : 'From the Roman Empire...' }, 
               {'name' : 'TitleDocMain', 'data' : 'Return of the oppressed'},
               {'name' : 'Author', 'type' : 'person', 'fields' :
                    [{'tag' : 'displayName', 'data' : 'Turchin, Peter'},
                     {'tag' : 'firstName', 'data' : 'Peter'},
                     {'tag' : 'lastName', 'data' : 'Turchin'}]
                }]
    new_doc_struct = {'content':content,
                      'doc_type':'Article',
                      'start_page':5,
                      'end_page':10}
    new_doc_struct = dict_tools.decodeDictTree(new_doc_struct)
    dict_tree = mets_tools.addNewDocStruct(dict_tree,new_doc_struct)
    
    xml = xml_tools.writeDictTreeToFile(dict_tree,dest)