{ "translatorID":"5e3ad958-ac79-463d-812b-a86a9235c28f", "translatorType":1, "label":"RDF", "creator":"Simon Kornblith", "target":"rdf", "minVersion":"1.0.0b4.r1", "maxVersion":"", "priority":100, "inRepository":true, "lastUpdated":"2009-11-12 07:20:00" } Zotero.configure("dataMode", "rdf"); function detectImport() { // unfortunately, Mozilla will let you create a data source from any type // of XML, so we need to make sure there are actually nodes var nodes = Zotero.RDF.getAllResources(); if(nodes) { return true; } } var rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; var n = { bib:"http://purl.org/net/biblio#", dc:"http://purl.org/dc/elements/1.1/", dcterms:"http://purl.org/dc/terms/", prism:"http://prismstandard.org/namespaces/1.2/basic/", foaf:"http://xmlns.com/foaf/0.1/", vcard:"http://nwalsh.com/rdf/vCard#", vcard2:"http://www.w3.org/2006/vcard/ns#", // currently used only for NSF, but is probably // very similar to the nwalsh vcard ontology in a // different namespace link:"http://purl.org/rss/1.0/modules/link/", z:"http://www.zotero.org/namespaces/export#" }; var callNumberTypes = [n.dcterms+"LCC", n.dcterms+"DDC", n.dcterms+"UDC"]; var defaultUnknownType = "book"; // gets the first result set for a property that can be encoded in multiple // ontologies function getFirstResults(node, properties, onlyOneString) { for(var i=0; i to collection", 2); continue; } // all other items are added by ID collection.children.push({id:Zotero.RDF.getResourceURI(child), type:"item"}); } } return collection; } function processSeeAlso(node, newItem) { var relations; newItem.itemID = Zotero.RDF.getResourceURI(node); newItem.seeAlso = new Array(); if(relations = getFirstResults(node, [n.dc+"relation"])) { for each(var relation in relations) { newItem.seeAlso.push(Zotero.RDF.getResourceURI(relation)); } } } function processTags(node, newItem) { var subjects; newItem.tags = new Array(); if(subjects = getFirstResults(node, [n.dc+"subject"])) { for each(var subject in subjects) { if(typeof(subject) == "string") { // a regular tag newItem.tags.push(subject); } else { // a call number var type = Zotero.RDF.getTargets(subject, rdf+"type"); if(type) { type = Zotero.RDF.getResourceURI(type[0]); if(type == n.z+"AutomaticTag") { newItem.tags.push({tag:getFirstResults(subject, [rdf+"value"], true), type:1}); } } } } } } // gets the node with a given type from an array function getNodeByType(nodes, type) { if(!nodes) { return false; } for each(var node in nodes) { var nodeType = Zotero.RDF.getTargets(node, rdf+"type"); if(nodeType) { nodeType = Zotero.RDF.getResourceURI(nodeType[0]); if(nodeType == type) { // we have a node of the correct type return node; } } } return false; } // returns true if this resource is part of another (related by any arc besides // dc:relation or dcterms:hasPart) // // used to differentiate independent notes and files function isPart(node) { var arcs = Zotero.RDF.getArcsIn(node); var skip = false; for each(var arc in arcs) { arc = Zotero.RDF.getResourceURI(arc); if(arc != n.dc+"relation" && arc != n.dcterms+"hasPart") { // related to another item by some arc besides see also skip = true; } } return skip; } function importItem(newItem, node, type) { var container = undefined; // also deal with type detection based on parts, so we can differentiate // magazine and journal articles, and find container elements var isPartOf = getFirstResults(node, [n.dcterms+"isPartOf"]); // get parts of parts, because parts are sections of wholes. if(isPartOf) { for(var i=0; i