问题
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 invalidvocab
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