right syntax for adding author of journalArticle and how to combine 2 XPath expressions

I'm currently tinkering with a translator (using the new framework) and have two questions:

1. What is the correct way to scrape the author name(s) of a journal article? Below is a code snippet. My script only works (i.e. an icon appears and stuff gets added to zotero when it is clicked) when the "creators"-line is commented out like beneath (without any author added though).
FW.Scraper({
itemType : 'journalArticle',
detect : "always",
// creators : FW.Xpath('//td[contains(text(),"Author")]/../td[2]/a').text()

Additonally, I find it confusing that there is no mention of any author, translator or similar metadata field at neither at http://www.zotero.org/support/dev/translators/framework#fwscraper1 nor at http://gsl-nagoya-u.net/http/pub/csl-fields/journalArticle.html


2. Having said that, I find the translator framework quite good to work with, especially using Firebug. I would like to know though, if and how the result/content of two XPath expressions can be combined into one metadata field. Something like this in pseudo-code:
extra : .join(FW.Xpath('//td[@class="content"]/td[2]'),
FW.Xpath('//td[@class="content"]/td[3]').text()


Is this possible in the framework or would I need to code a full-fledged script?
  • Generally, these questions are better asked on zotero dev, the home for the more techy issues. But while you're here:
    1. look at the sample translator - you want to append
    .cleanAuthor("author"), at the end (alternatively you can use "editor", "translator" etc.) that is likely enough to get it to work.


    The reason they're not on the Nagoya page is that the tables are auto-generated and that didn't work for creator types. But I do think it's worth putting it in the framework documentation.

    2. I don't know - my sense is that you'll need to pre-process this, but I'm not sure.
  • As adamsmith said, definitely post this to zotero-dev (http://groups.google.com/group/zotero-dev). I'd also encourage you to try using Scaffold (http://www.zotero.org/support/dev/translators/scaffold), since it makes the whole process much easier (and it gets even better with Scaffold 3.0 for Zotero 2.1.9+).

    Both things can be done within the framework-- post to zotero-dev, preferably with a link to the complete code hosted somewhere like gist.github.com, and I'll respond there.
  • I haven't tested this, but it should be possible to use a | to join xpath statements, e.g.:

    xtra : FW.Xpath('//td[@class="content"]/td[2] | //td[@class="content"]/td[3]').text();

    but that will yield an array, I think, rather than a joined string, and only certain fields (creators & tags) can handle multiple entries. You could join the strings using xpath functions, e.g. concat.

    But this is speculation. Could you explain what you are trying to do (on zotero-dev if possible, I don't usually read the forums) and hopefully we can help to come up with a solution? Thanks!

    best, Erik
Sign In or Register to comment.