Writing a translator - reusing an existing translator
Hi,
I'm writing a translator for a website where the majority of the
references come from NCBI PubMed, with a few coming from elsewhere.
The PubMed entries all have a link to the relevant page at PubMed, and
rather than parsing out the (more limited) info from the local
website, it would be better to get it from PubMed itself. I could copy
and paste the code from the PubMed translator, but it would be better
to get the translator to do its thing and return the results.
To illustrate, this is what the translator would look like:
// iterate through a list of journal articles from an xpath query
while ( c = citations.iterateNext() ) {
// check whether it's a PubMed link or not...
if ( c.nodeName=='A' && c.className.match('pmid') ) {
// get data using the NCBI PubMed translator
var newItem = ??? what would go here ???
} else {
// code to scrape the data from the local page
var newItem = new Zotero.Item("journalArticle");
... code to parse data from page ...
}
}
Any help would be greatly appreciated!
I'm writing a translator for a website where the majority of the
references come from NCBI PubMed, with a few coming from elsewhere.
The PubMed entries all have a link to the relevant page at PubMed, and
rather than parsing out the (more limited) info from the local
website, it would be better to get it from PubMed itself. I could copy
and paste the code from the PubMed translator, but it would be better
to get the translator to do its thing and return the results.
To illustrate, this is what the translator would look like:
// iterate through a list of journal articles from an xpath query
while ( c = citations.iterateNext() ) {
// check whether it's a PubMed link or not...
if ( c.nodeName=='A' && c.className.match('pmid') ) {
// get data using the NCBI PubMed translator
var newItem = ??? what would go here ???
} else {
// code to scrape the data from the local page
var newItem = new Zotero.Item("journalArticle");
... code to parse data from page ...
}
}
Any help would be greatly appreciated!
-
Rintze
There are quite a few translators that call upon other translators, like that for Nature (which calls the RIS-file-format-translator). I guess you could do something similar with the NCBI Pubmid translator.
This is an old discussion that has not been active in a long time. Instead of commenting here, you should start a new discussion. If you think the content of this discussion is still relevant, you can link to it from your new discussion.
Upgrade Storage