W3C验证器无法处理RDF / XML

时间:2014-07-02 09:37:45

标签: xml rdf w3c-validation

我试图用停靠点和时间来描述一个非常基本的地铁火车站地图。 This RDF to Turtle converter可以解析我的XML,但是W3C验证器会抛出:Error: Your document does not contain any RDF statement.

我无法弄清楚为什么我的文档无效,因为它不是一个非常特殊的用例?我的空白节点被描述为Resourceaccording 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>

2 个答案:

答案 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)
        …

前几条消息是关键

  • {W135}顶级rdf:RDF元素不在RDF名称空间中。可能是个错误。
  • {W135} rdf:RDF并不特别。 RDF名称空间的名称空间绑定不正确。它应该是<http://www.w3.org/1999/02/22-rdf-syntax-ns#>而不是<http://w3.org/1999/02/22-rdf-syntax-ns#>
  • {W135} rdf:说明并不特别。 RDF名称空间的名称空间绑定不正确。它应该是<http://www.w3.org/1999/02/22-rdf-syntax-ns#>而不是<http://w3.org/1999/02/22-rdf-syntax-ns#>
  • {W135} rdf:约不是特别的。 RDF名称空间的名称空间绑定不正确。它应该是<http://www.w3.org/1999/02/22-rdf-syntax-ns#>而不是<http://w3.org/1999/02/22-rdf-syntax-ns#>
  • {E201}此属性元素的属性不允许包含任何内容;期待结束元素标记。