我试图用停靠点和时间来描述一个非常基本的地铁火车站地图。 This RDF to Turtle converter可以解析我的XML,但是W3C验证器会抛出:Error: Your document does not contain any RDF statement.
我无法弄清楚为什么我的文档无效,因为它不是一个非常特殊的用例?我的空白节点被描述为Resource
,according to the specification。或者我必须使用nodeID
多个空白节点?
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ex="http://example.com/">
<rdf:Description rdf:about="http://example.com/HaltestelleA">
<ex:verbundenMit rdf:parseType="Resource">
<ex:Haltestelle rdf:resource="http://example.com/HaltestelleB" />
<ex:Linie rdf:resource="http://example.com/Linie1" />
<ex:Zeit>2</ex:Zeit>
</ex:verbundenMit>
<ex:verbundenMit rdf:parseType="Resource">
<ex:Haltestelle rdf:resource="http://example.com/HaltestelleB" />
<ex:Linie rdf:resource="http://example.com/Linie2" />
<ex:Zeit>7</ex:Zeit>
</ex:verbundenMit>
</rdf:Description>
</rdf:RDF>
答案 0 :(得分:3)
问题在于你的命名空间声明:
xmlns:rdf="http://w3.org/1999/02/22-rdf-syntax-ns#"
应该是:
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
答案 1 :(得分:3)
这已经有了答案,但我认为如果RDF / XML验证器没有告诉你,值得指出如何你可以确定这一点。如果您使用Jena的rdfcat
命令行工具来读取文件并再次打印出来,您将获得更有用的消息。我已将您的数据保存为data.rdf,以下是发生的情况:
$ rdfcat data.rdf
08:06:13 WARN riot :: {W135} Top-level rdf:RDF element is not in the RDF namespace. Probably a mistake.
08:06:13 WARN riot :: {W135} rdf:RDF is not special. The namespace binding of the RDF namespace is incorrect. It should be <http://www.w3.org/1999/02/22-rdf-syntax-ns#> not <http://w3.org/1999/02/22-rdf-syntax-ns#>
08:06:13 WARN riot :: {W135} rdf:Description is not special. The namespace binding of the RDF namespace is incorrect. It should be <http://www.w3.org/1999/02/22-rdf-syntax-ns#> not <http://w3.org/1999/02/22-rdf-syntax-ns#>
08:06:13 WARN riot :: {W135} rdf:about is not special. The namespace binding of the RDF namespace is incorrect. It should be <http://www.w3.org/1999/02/22-rdf-syntax-ns#> not <http://w3.org/1999/02/22-rdf-syntax-ns#>
08:06:13 ERROR riot :: {E201} The attributes on this property element, are not permitted with any content; expecting end element tag.
Exception in thread "main" org.apache.jena.riot.RiotException: {E201} The attributes on this property element, are not permitted with any content; expecting end element tag.
at org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.error(ErrorHandlerFactory.java:128)
at org.apache.jena.riot.lang.LangRDFXML$ErrorHandlerBridge.error(LangRDFXML.java:241)
…
前几条消息是关键
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
而不是<http://w3.org/1999/02/22-rdf-syntax-ns#>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
而不是<http://w3.org/1999/02/22-rdf-syntax-ns#>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
而不是<http://w3.org/1999/02/22-rdf-syntax-ns#>