简体   繁体   中英

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.

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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