openrdf-sesame SPARQLResultsXMLWriter 和 XSL
如何在 SPARQLResultsXMLWriter 提供的 XML 输出流中添加 xsl 样式表?
RepositoryConnection con = repository.getConnection();
SPARQLResultsXMLWriter sparqlWriter = new SPARQLResultsXMLWriter(out);
try {
TupleQuery query = con.prepareTupleQuery(org.openrdf.query.QueryLanguage.SPARQL, qs);
query.evaluate(sparqlWriter);
}
finally {
con.close();
}
我正在寻找类似的东西,
com.hp.hpl.jena.query.ResultSetFormatter.outputAsXML(outStream,resulSet,**xslFilePath**);
由 Jena Framework 提供...类似于 Sesame
谢谢, 恩佐
how can i add xsl stylesheet in XML out stream provided by SPARQLResultsXMLWriter?
RepositoryConnection con = repository.getConnection();
SPARQLResultsXMLWriter sparqlWriter = new SPARQLResultsXMLWriter(out);
try {
TupleQuery query = con.prepareTupleQuery(org.openrdf.query.QueryLanguage.SPARQL, qs);
query.evaluate(sparqlWriter);
}
finally {
con.close();
}
I'm looking for something like this,
com.hp.hpl.jena.query.ResultSetFormatter.outputAsXML(outStream,resulSet,**xslFilePath**);
provided by Jena Framework... the similar for Sesame
Thanks,
Enzo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认的 Sesame SPARQLResultsXMLWriter 没有此选项。然而,定制它应该相当容易。您需要做的是创建
info.aduna.xml.XMLWriter
类的子类(该类是 SPARQLResultsXMLWriter 内部使用的用于正确格式化 XML 的实用程序类)。在此子类中,添加 getter/setter 来指定样式表链接,然后重写 startDocument 方法,如下所示:然后只需将这个自定义的 XMLWriter 提供给您的 SPARQLResultsXMLWriter 并将样式表引用设置为正确的值:
未经测试,但相当有信心这应该工作。
或者,向 Sesame 项目提出功能请求和/或向他们提供补丁。
The default Sesame SPARQLResultsXMLWriter does not have an option for this. However, it should be fairly easy to customize it. What you need to do is create a subclass of the class
info.aduna.xml.XMLWriter
(which is a utility class for correctly formatted XML that is used by the SPARQLResultsXMLWriter internally). In this subclass, add a getter/setter to specify the stylesheet link, and then override the startDocument method like so:Then just supply this customized XMLWriter to your SPARQLResultsXMLWriter and set the stylesheet ref to the correct value:
Untested, but fairly confident this should work.
Alternatively, raise a feature request with the Sesame project and/or supply them with a patch.