访问三元组对象的字面值

Accessing the literal value of the object of a triple

我正在开发一个验证海龟文件的验证器。在处理一个函数来检查所声明的基数对于每个对象是否正确时,我不知道如何访问文字的值。

文字值为Card=literal(type(xsd:nonNegativeInteger, '1'))(或1^^'http://www.w3.org/2001/XMLSchema#nonNegativeInteger')。

我找到一袋长度为 L 的属性。如何检查 L == Card

我已经尝试过以下方法:

% L and Card are both 1
rdf_canonical_literal(L, LiteralL), rdf_compare(=, LiteralL, Card).
% false

rdf_canonical_literal(L, LiteralL).
% LiteralL = 1^^'http://www.w3.org/2001/XMLSchema#integer'.

问题是 xsd:integerxsd:nonNegativeInteger 不相等。

然而,对我来说最简单的事情似乎是获得 Card 的值,但我真的不知道该怎么做。任何解决方案或在哪里可以找到这方面的例子的指针将不胜感激!!

如果您使用库 rdf11,那么最常见的数据类型 IRI 会自动解释为 Prolog 值。换句话说:根本不需要将 RDF 文字转换为 Prolog 值。示例:

?- [library(semweb/rdf11)].
?- rdf_assert(rdf:a, rdf:b, 1^^xsd:int).
?- rdf(_S, _P, N^^xsd:int).
N = 1.

您可以使用钩子扩展库 rdf11 以获取不太常见的数据类型 IRI,例如,我使用了很多让 rdf/[3,4] 解释的地理数据(数据类型 IRI geo:wktLiteral)自动作为 Prolog Well-Known Text (WKT) 符号。