sparql - 关于 SPARQL CONSTRUCT 查询的内容协商的奇怪行为
问题描述
向特定端点发出 SPARQL CONSTRUCT 查询时,Apache Jena 库 3.14.0 发出如下错误消息。
端点返回的内容类型:application/sparql-results+xml 这不是有效的 RDF 语法
我写的代码如下。
QueryEngineHTTP qeh = new QueryEngineHTTP(endpointUrl, rq);
qeh.setAcceptHeader("application/rdf+xml");
Model m = qeh.execConstruct();
端点是https://id.nlm.nih.gov/mesh/sparql
。查询如下。
CONSTRUCT {?s <http://id.nlm.nih.gov/mesh/vocab#altLabel> ?o}
FROM <http://id.nlm.nih.gov/mesh/2020>
WHERE {
?s <http://id.nlm.nih.gov/mesh/vocab#altLabel> ?o ;
a <http://id.nlm.nih.gov/mesh/vocab#Term> .
FILTER(isLiteral(?o))
} LIMIT 3
通过 curl 工具发出此查询时,我得到了很好的结果。
% curl -LH 'Accept: application/rdf+xml' --data-urlencode query@test.rq https://id.nlm.nih.gov/mesh/sparql
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:j.0="http://id.nlm.nih.gov/mesh/vocab#">
<rdf:Description rdf:about="http://id.nlm.nih.gov/mesh/2020/T000963157">
<j.0:altLabel xml:lang="en">Topics, Exhibitions as</j.0:altLabel>
</rdf:Description>
<rdf:Description rdf:about="http://id.nlm.nih.gov/mesh/2020/T000950545">
<j.0:altLabel xml:lang="en">Psychiatric Fetishism</j.0:altLabel>
</rdf:Description>
<rdf:Description rdf:about="http://id.nlm.nih.gov/mesh/2020/T000950541">
<j.0:altLabel xml:lang="en">Psychological Extraversion</j.0:altLabel>
</rdf:Description>
</rdf:RDF>
解决方案
推荐阅读
- reactjs - react-native-version-number:verifyReleaseResources 在 React Native 应用程序中
- apache-kafka - 我可以让一个组的所有消费者消费来自 kafka 主题的所有分区的消息吗?
- c++ - Qt:qmake中VERSION和VER_MAJ、VER_MIN、VER_PAT的区别
- javascript - 使用 react-select 超出最大更新深度
- javascript - 尝试将我的智能电视应用连接到 Azure 数据库
- python - 将多个函数部署到终端中的 Google Cloud Functions?
- android - Android RecyclerView 多重过滤器
- python - 如何运行 python 事后测试?
- sql-server - 如何使用 AzureRm.Sql PowerShell 库创建 Azure SQL 托管实例?
- sql - 无论类型如何,如何对 SQL 表的所有列进行 md5?