View Single Post
Old 01-15-2008, 03:28 AM   #45
daudi
Addict
daudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-books
 
Posts: 281
Karma: 904
Join Date: Oct 2007
Location: Kent, UK
Device: iRex iLiad, Psion 5MX, nokia n800
Doh! It's amazing what a good night's sleep and really big cup of tea can do.
Gogolo, take a look at the batch layout file (posted above), I think you should be able to see what it does. It uses the cat command to write the template to a file name specified at the end of the cat line. You should be able to modify this layout file to produce a DOS bat file that writes the lines out using echo. Something like this:
Code:
echo "<?xml version="1.0" encoding="utf-8"?>"  > \format{\bibtexkey}.manifest.xml
echo "<package>"  >>  \format{\bibtexkey}.manifest.xml                                                                        
echo "<metadata>"  >>  \format{\bibtexkey}.manifest.xml
etc. Note the single > to redirect output to a new file and subsequent >> to append to that file. This assumes that echo will happily echo everything between the quotes. You might need to escape the quotes in the first line or use single quotes, but hopefully the idea is clear. If echo does agree to play nicely, then once you've done this for each line and then used it to export several refs, you'll end up with a DOS bat file that should create each manifest file.

If there are problems with echoing (e.g. the < or other characters) then it's back to python/jython. I think the layout file would be really simple, something like:

Code:
f = open('\format{\bibtextkey.manifest.xml}', 'w')
bib = """
<?xml version="1.0" encoding="utf-8"?>
<package><metadata><dc-metadata>
<Title>\format[Replace("&",and),AuthorLastFirst,AuthorLastFirstAbbreviator,AuthorAndsCommaReplacer]{\author}</Title>
***etc. rest of manifest here***
"""
f.write(bib)
f.close()
So you'd use this layout file to create a python script (e.g. myrefs.py) that you'd run with something like:

Code:
java -jar jython.jar myrefs.py
I think I'll play with using jython again a little more it was fun, and it allows access to the java libraries so it could then be possible to create guis and things if necessary.

And for those wondering why I don't just use java in the first place: i) I find it takes too long to write quick code to do simple tasks; and ii) I'm not very good at it.
daudi is offline   Reply With Quote