How to use RDFa “vocab” within XHTML

牧云@^-^@ 提交于 2019-12-08 07:09:04

问题


I'm trying to get this (simple) webpage done for my assignment and it needs to pass through http://validator.w3.org/
It also needs to use RDFa. However no matter what I do, the RDFa vocab never gets passed by the validator.

Here's what I got:

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML+RDFa 1.0//EN' 'http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd'>

<body vocab="http://xmlns.com/foaf/0.1/">

What am I doing wrong?


回答1:


The vocab attribute is defined in RDFa 1.1, but with your current DOCTYPE, you are using RDFa 1.0.

Your options:

  • Keep using XHTML 1.1 and RDFa 1.0, and use the xmlns:… attribute(s) instead of the invalid vocab attribute:

    <body xmlns:foaf="http://xmlns.com/foaf/0.1/">
    

    (Then you have to use the prefix foaf:.)

  • Keep using XHTML 1.1, but switch to a DOCTYPE that supports RDFa 1.1:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
    
  • Switch to XHTML5, which supports RDFa 1.1 by default:

    <!DOCTYPE html>
    



回答2:


Do you really have to use XHTML? I would recommend to use an HTML5 doctype. http://www.w3.org/TR/html-rdfa/ has some examples.

Also, make sure you use the NU validator from W3C: https://validator.w3.org/nu/ - the one you are using is old and should no longer be used.



来源:https://stackoverflow.com/questions/31461167/how-to-use-rdfa-vocab-within-xhtml

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