Search code examples
htmlsemantic-webrdfa

What is the correct way to reference RDFa namespaces in HTML5?


I'm setting up a HTML5 webpage and want to include RDFa. I try checking the syntax with the w3 validator, and check the extracted RDF using the w3 RDFa distiller. When I declare namespaces using xmlns:<ns>="<uri>" the validator complains that the attribute is not allowed there, and the specs say that xmlns is deprecated, but if I try the other suggested prefix="<ns> <uri>" the distiller doesn't discover the RDFa embedded on my page. Which way should I stick to?


Solution

  • Use @prefix. The key to your problem is in the first couple of sentences on the W3C's RDFa Distiller page:

    This distiller corresponds to the RDFa 1.0 specification. In 2012, W3C has published an updated version of that specification, called RDFa Core 1.1. A new distiller, processing RDFa 1.1 content, has been implemented which suprecedes this one.

    The @prefix attribute is a new addition in RDFa 1.1 and therefore not recognized by the old Distiller.

    The W3C RDFa 1.1 Distiller should be able to handle it correctly.