Eivind Eidheim Elseth
Eivind Eidheim Elseth

Reputation: 2354

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?

Upvotes: 5

Views: 766

Answers (4)

Jonadabe
Jonadabe

Reputation: 84

I'm using this:

<!DOCTYPE html>
<html vocab="http://www.w3.org/2011/rdfa-context/rdfa-1.1">
<!-- you can use one or more prefixes
cat:        http://www.w3.org/ns/dcat#
qb:         http://purl.org/linked-data/cube#
grddl:      http://www.w3.org/2003/g/data-view#
ma:         http://www.w3.org/ns/ma-ont#
owl:        http://www.w3.org/2002/07/owl#
rdf:        http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfa:       http://www.w3.org/ns/rdfa#
rdfs:       http://www.w3.org/2000/01/rdf-schema#
rif:        http://www.w3.org/2007/rif#
rr:         http://www.w3.org/ns/r2rml#
skos:       http://www.w3.org/2004/02/skos/core#
skosxl:     http://www.w3.org/2008/05/skos-xl#
wdr:        http://www.w3.org/2007/05/powder#
void:       http://rdfs.org/ns/void#
wdrs:       http://www.w3.org/2007/05/powder-s#
xhv:        http://www.w3.org/1999/xhtml/vocab#
xml:        http://www.w3.org/XML/1998/namespace
xsd:        http://www.w3.org/2001/XMLSchema#
prov:       http://www.w3.org/ns/prov#
sd:         http://www.w3.org/ns/sparql-service-description#
org:        http://www.w3.org/ns/org#
gldp:       http://www.w3.org/ns/people#
cnt:        http://www.w3.org/2008/content#
dcat:       http://www.w3.org/ns/dcat#
earl:       http://www.w3.org/ns/earl#
ht:         http://www.w3.org/2006/http#
ptr:        http://www.w3.org/2009/pointers#
cc:         http://creativecommons.org/ns#
ctag:       http://commontag.org/ns#
dc:         http://purl.org/dc/terms/
dc11:       http://purl.org/dc/elements/1.1/
dcterms:    http://purl.org/dc/terms/
foaf:       http://xmlns.com/foaf/0.1/
gr:         http://purl.org/goodrelations/v1#
ical:       http://www.w3.org/2002/12/cal/icaltzd#
og:         http://ogp.me/ns#
rev:        http://purl.org/stuff/rev#
sioc:       http://rdfs.org/sioc/ns#
v:          http://rdf.data-vocabulary.org/#
vcard:      http://www.w3.org/2006/vcard/ns#
schema:     http://schema.org/
describedby:http://www.w3.org/2007/05/powder-s#describedby
license:    http://www.w3.org/1999/xhtml/vocab#license
role:       http://www.w3.org/1999/xhtml/vocab#role
-->
<head>
    <meta property="og:title dc:title" content="This is a test!">
    <meta property="dc:description" content="This is a description test">
</head>
<body>
          <header typeof="role:banner schema:Organization">
    <div>
        <h1>
            <a href="/" title="home" rel="home" accesskey="1">
                <img class="logo" property="schema:image" src="my-image.png" width="160" alt="My logo">
            </a>
        </h1>
        <h2>
            <span property="schema:description">creative design and rock-solid development</span>
        </h2>
    </div>
</header>
...and so on...
</body>
</html>

You can read more about it here http://rdfa.info

Upvotes: 0

Chawathe Vipul S
Chawathe Vipul S

Reputation: 1696

xmlns is remnant from when RDFa was confined to X HTML. There is such a thing as XHTML5 that allows for XML operations such as XSLT alongside HTML functionality, so regardless of deprecated status to xmlns for building RDFa's own identity, killing xmlns is unlikely. As for newer techniques, even if you move on, some tools might have to play catch-up.

Upvotes: 1

scor
scor

Reputation: 940

also, make sure to use the NU validator which supports HTML5 and RDFa correctly: http://validator.w3.org/nu/

Upvotes: 1

cygri
cygri

Reputation: 9482

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.

Upvotes: 5

Related Questions