简体   繁体   English

W3C验证程序无法处理RDF / XML

[英]W3C validator can't process RDF/XML

I'm trying to describe a very basic metro train station map with stops and times. 我正在尝试用停靠点和时间来描述一个非常基本的地铁火车站地图。 This RDF to Turtle converter can parse my XML, but the W3C validator throws: Error: Your document does not contain any RDF statement. 此RDF至Turtle转换器可以解析我的XML,但W3C验证程序将抛出: Error: Your document does not contain any RDF statement.

I can't figure out why my document isn't valid because it isn't some very special use case? 我无法弄清楚为什么我的文档无效,因为它不是非常特殊的用例? My blank nodes are described as Resource , according to the specification . 根据规范 ,我的空白节点称为“ Resource Or do I have to use nodeID for multiple blank nodes? 还是我必须对多个空白节点使用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>

The problem is in your namespace declarations: 问题出在您的命名空间声明中:

xmlns:rdf="http://w3.org/1999/02/22-rdf-syntax-ns#"

should be: 应该:

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

This already has an answer, but I think it's worth pointing out how you could have determined this, if the RDF/XML validator doesn't tell you. 这已经有了答案,但是如果RDF / XML验证器没有告诉您,那么我应该指出如何确定这一点。 If you use Jena's rdfcat command line tool to read the file and print it out again, you get a more useful message. 如果使用耶拿(Jena)的rdfcat命令行工具读取文件并再次打印出该文件,则会得到一条更有用的消息。 I've saved your data as data.rdf, and here's what happens: 我已将您的数据另存为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)
        …

Those first few messages are the key 前几条消息是关键

  • {W135} Top-level rdf:RDF element is not in the RDF namespace. {W135}顶级rdf:RDF元素不在RDF名称空间中。 Probably a mistake. 可能是个错误。
  • {W135} rdf:RDF is not special. {W135} rdf:RDF不特殊。 The namespace binding of the RDF namespace is incorrect. RDF名称空间的名称空间绑定不正确。 It should be <http://www.w3.org/1999/02/22-rdf-syntax-ns#> not <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#>
  • {W135} rdf:Description is not special. {W135} rdf:说明并不特殊。 The namespace binding of the RDF namespace is incorrect. RDF名称空间的名称空间绑定不正确。 It should be <http://www.w3.org/1999/02/22-rdf-syntax-ns#> not <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#>
  • {W135} rdf:about is not special. {W135} rdf:about并不特殊。 The namespace binding of the RDF namespace is incorrect. RDF名称空间的名称空间绑定不正确。 It should be <http://www.w3.org/1999/02/22-rdf-syntax-ns#> not <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#>
  • {E201} The attributes on this property element, are not permitted with any content; {E201}此属性元素上的属性,不允许包含任何内容。 expecting end element tag. 期待结束元素标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM