Changeset 985
- Timestamp:
- 08/10/07 12:27:39 (1 year ago)
- Files:
-
- BibIt/trunk/bibchunker.py (modified) (4 diffs)
- BibIt/trunk/mungexlinksforsplit.xsl (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
BibIt/trunk/bibchunker.py
r952 r985 28 28 NSD = {'mods': MODS, 'xlink': XLINK} 29 29 30 XLINKCLEANUPXSLT = 'mungexlinksforsplit.xsl' 31 32 30 33 MODSTOP = '<?xml version="1.0" encoding="UTF-8"?>\n<mods xmlns="http://www.loc.gov/mods/v3"\n' \ 31 34 + 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\nxmlns:mods="http://www.loc.gov/mods/v3"\n' \ … … 39 42 40 43 try: 41 opts, args = getopt.getopt(argv, "s:d:x: ", ["source=", "destination=", "htmlsource="])44 opts, args = getopt.getopt(argv, "s:d:x:h", ["source=", "destination=", "htmlsource=", "help"]) 42 45 except getopt.GetoptError: 43 usage()46 print __doc__ 44 47 sys.exit(2) 45 48 … … 80 83 print 'made new directories for %s' % modspath 81 84 82 modsxml = etree.tounicode(mods, pretty_print=1).encode('utf-8', 'xmlcharrefreplace') 85 86 modsxml = etree.tounicode(doxlinkcleanup(mods), pretty_print=1).encode('utf-8', 'xmlcharrefreplace') 83 87 modsxml = MODSTOP + modsxml[5:].strip() 84 88 modsfilepath = os.path.join(modspath, modsfile) … … 104 108 sys.exit(2) 105 109 110 def doxlinkcleanup(source): 111 contextpath = os.getcwd() 112 xslt_doc = etree.parse(os.path.join(contextpath, XLINKCLEANUPXSLT)) 113 transform = etree.XSLT(xslt_doc) 114 result = etree.XML(etree.tounicode(transform(source))) 115 return result 116 117 106 118 if __name__ == "__main__": 107 119 main(sys.argv[1:])
