XML import translators

63 views
Skip to first unread message

adamsmith

unread,
Mar 12, 2012, 3:49:56 AM3/12/12
to zoter...@googlegroups.com
I've mostly finished writing marcXML parsing as part of a library translator. It's written using DOMparser & and feeds the data to the marc translator.
I'm thinking that it may very well be worthwhile putting that code into a separate import translator, but I'm not user how to proceed. The documentation suggest using E4X for xml translators
http://www.zotero.org/support/dev/translators/coding#import_translators
which would  be easy, but doesn't work outside of FF. Should I just treat the file this as text with
var line;
while((line = Zotero.read()) !== false)) {

and then use


var parser = new DOMParser();
var doc = parser.parseFromString(text, "text/xml");

Or is there a more elegant solution?

Avram Lyon

unread,
Mar 12, 2012, 4:34:22 AM3/12/12
to zoter...@googlegroups.com
On Mon, Mar 12, 2012 at 12:49 AM, adamsmith <bst...@gmx.de> wrote:
> Or is there a more elegant solution?

Without code diving, I can't say whether there's a more elegant solution.

If Simon can chip in here, it'd be good to get a full listing of what
input formats can be specified, so we can update the docs accordingly.

Avram

adamsmith

unread,
Mar 12, 2012, 4:12:08 PM3/12/12
to zoter...@googlegroups.com
For what it's worth, using Zotero.read and then parseFromString works smoothly, so unless there are compelling reasons against it I'll use that for now.

Simon Kornblith

unread,
Mar 12, 2012, 5:15:32 PM3/12/12
to zotero-dev
We currently support:

rdf/xml (used in Bibliontology RDF.js, Zotero RDF.js, and RDF.js)
rdf/n3 (unused, same as rdf/xml but with N3 output)
xml/e4x (used in MODS and TEI)

In theory there's an xml/dom mode for which Zotero.getXML() returns a
DOM document, but it's quite likely that it's been broken since
Firefox 5, so DOMParser is probably the best option at the moment.

Simon
Reply all
Reply to author
Forward
0 new messages