Пример #1
0
dom1.childNodes[0].appendChild(physicalDescriptionNode)

identifier = dom1.createElement('identifier')
identifierText = dom1.createTextNode(pid)
identifier.appendChild(identifierText)
identifier.setAttribute('type', 'fedora')
dom1.childNodes[0].appendChild(identifier)

locationXML = '''    <location>
        <physicalLocation>University of Prince Edward Island, Robertson Library (Charlottetown,PE)
        </physicalLocation>
    </location>'''

location = parseString(locationXML)
locationNode = dom1.importNode(location.childNodes[0],True)
dom1.childNodes[0].appendChild(locationNode)


accessXML = '''    <accessCondition type="useAndReproduction"> Use of this resource is governed by the Canadian
        Copyright Act. Unless otherwise noted you must contact the right&apos;s holder(s) for permission
        to publish or reproduce this resource.
    </accessCondition>'''
access = parseString(accessXML)
accessNode = dom1.importNode(access.childNodes[0],True)
dom1.childNodes[0].appendChild(accessNode)
#dom1.writexml(open(outputFile, 'w'),encoding="iso9660-1")
#outfile = open( outputFile, 'w')
#outfile.write(str(dom1.toxml()))
write_unicode_to_file(outputFile, dom1.toxml())

Пример #2
0
typeOfResource = {'p':'still image',
                  'i':'still image',
                  'm':'cartographic',
                  'd':'text',
                  'n':'text',
                  'f':'text',
                  'a':'still image'}


dcdom = parse(book_dc)

replace_node( dcdom, 'dc:type', 'image' )

dc_title = dcdom.getElementsByTagName('dc:title')
old_title = dc_title[0].childNodes[0]

new_title = figureTypes[figureType] + ' ' + figureNum + ' - ' + pageTypes[pageType] + ' ' + str(int(pageNumber[0:3])) + ' - ' + old_title.toxml()
write_unicode_to_file( os.path.dirname(img_dc) + '/label.txt', new_title)
replace_node( dcdom, 'dc:title',  new_title)
replace_node( dcdom, 'dc:identifier', pid )
replace_node( dcdom, 'dc:format', 'electronic' )

extra_format_nodes = dcdom.getElementsByTagName( 'dc:format' )
extra_format_nodes.pop(0) # Keep first element that we just changed.
for x in extra_format_nodes:
    x.parentNode.removeChild(x)

#dcdom.writexml(open(img_dc, 'w'))
write_unicode_to_file(img_dc, dcdom.toxml())
Пример #3
0
physicalDescriptionNode = modsdom.importNode(physicalDescription.childNodes[0], True)
modsdom.childNodes[0].appendChild(physicalDescriptionNode)

identifier = modsdom.createElement('identifier')
identifierText = modsdom.createTextNode(pid)
identifier.appendChild(identifierText)
identifier.setAttribute('type', 'fedora')

modsdom.childNodes[0].appendChild(identifier)


locationXML = '''    <location>
        <physicalLocation>University of Prince Edward Island, Robertson Library (Charlottetown,PE)
        </physicalLocation>
    </location>'''

location = parseString(locationXML)
locationNode = modsdom.importNode(location.childNodes[0],True)
modsdom.childNodes[0].appendChild(locationNode)


accessXML = '''    <accessCondition type="useAndReproduction"> Use of this resource is governed by the Canadian
        Copyright Act. Unless otherwise noted you must contact the right&apos;s holder(s) for permission
        to publish or reproduce this resource.
    </accessCondition>'''
access = parseString(accessXML)
accessNode = modsdom.importNode(access.childNodes[0],True)
modsdom.childNodes[0].appendChild(accessNode)
#dom1.writexml(open(outputFile, 'w'),encoding="iso9660-1")
write_unicode_to_file(outputFile, modsdom.toxml())