我想通過從matlab中發送DOI(數字對象標識符)到http://www.crossref.org來檢索bibtex數據(用於構建參考書目)。通過從matlab中發送DOI來從crossref中檢索bibtex數據:從ruby中翻譯
交叉引用API說明是這樣的:根據this源
curl -LH "Accept: text/bibliography; style=bibtex" http://dx.doi.org/10.1038/nrd842
。
從here另一個例子表明,在ruby
如下:
open("http://dx.doi.org/10.1038/nrd842","Accept" => "text/bibliography; style=bibtex"){|f| f.each {|line| print line}}
雖然我聽說的紅寶石石頭我想這樣做在MATLAB和不知道如何翻譯的紅寶石消息或解釋交叉引用命令。
以下是我迄今發送DOI給交叉引用和檢索XML數據(可變retdat
),而不是中文提供,格式爲:
clear
clc
doi = '10.1038/nrd842';
URL_PATTERN = 'http://dx.doi.org/%s';
fetchurl = sprintf(URL_PATTERN,doi);
numinputs = 1;
www = java.net.URL(fetchurl);
is = www.openStream;
%Read stream of data
isr = java.io.InputStreamReader(is);
br = java.io.BufferedReader(isr);
%Parse return data
retdat = [];
next_line = toCharArray(br.readLine)'; %First line contains headings, determine length
%Loop through data
while ischar(next_line)
retdat = [retdat, 13, next_line];
tmp = br.readLine;
try
next_line = toCharArray(tmp)';
if strcmp(next_line,'M END')
next_line = [];
break
end
catch
break;
end
end
%Cleanup java objects
br.close;
isr.close;
is.close;
幫助翻譯紅寶石聲明的東西MATLAB可以使用發佈的腳本發送來建立與crossref的通信將不勝感激。
編輯:
附加約束條件包括代碼(後面至少到R14)的向後兼容性:>(另外,沒有用紅寶石,由於解決了上述問題,但不是「MATLAB」。解決辦法見here對於如何通過system('ruby script.rb')
調用從MATLAB的紅寶石。
取代事情的來龍去脈爲什麼原始的Java,而不是['urlread'](http://www.mathworks.com/help/matlab/ref /urlread.html)? – horchler
這就是歷史:代碼是從另一個應用程序借來的。 –
用於設置請求標頭和其他細節,[見本](http://undocumentedmatlab.com/blog/expanding-urlreads-capabilities/)。 – horchler