W3C validator can't process RDF/XML

两盒软妹~` 提交于 2019-12-11 13:33:06

问题


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.

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. Or do I have to use nodeID for multiple blank nodes?

<?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>

回答1:


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#"



回答2:


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. If you use Jena's rdfcat command line tool to read the file and print it out again, you get a more useful message. I've saved your data as data.rdf, and here's what happens:

$ 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. Probably a mistake.
  • {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#>
  • {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#>
  • {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#>
  • {E201} The attributes on this property element, are not permitted with any content; expecting end element tag.


来源:https://stackoverflow.com/questions/24527728/w3c-validator-cant-process-rdf-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!