我正在尝试使用内容协商来提供 HTTP 服务器上资源的 HTML 和 RDF/XML 表示。在服务器端这有效,即
curl -H "Accept: application/rdf+xml" http://localhost:8182/ontologies/1
将检索正确的版本。我也可以用 JavaScript/Dojo 做同样的事情:
function downloadOntologyRDF(ontologyId) {
dojo.xhrGet( {
url:"${baseUrl}/ontologies/" + ontologyId,
headers: {"Accept": "application/rdf+xml"},
timeout: 5000,
load: function(response, ioArgs) {
var preNode = document.createElement("pre");
preNode.appendChild(document.createTextNode(response));
var foo = new dijit.Dialog({
title: "RDF",
content: preNode,
style: "overflow: auto;"
});
foo.show();
return response;
},
error: function(response, ioArgs) {
alert("Retrieving the RDF version failed: " + response);
return response;
}
});
}
这将在弹出对话框中显示结果。我被卡住的地方是为用户提供了一种下载此版本的方法。我想在页面上有一个链接,可以在浏览器中将 RDF 显示为页面,或者直接打开保存对话框。如果不求助于查询参数或其他技巧,这是否可能?