How-to-validate

From RDFaWiki

Jump to: navigation, search

Contents

How to validate your XHTML+RDFa page

Q: I have enriched my page with RDFa now. How can I make sure it is done properly?

A: Validate it!

Q: Why should I want to validate?

A: You already said it, right? ;)


Ok, so what is needed to validate an XHTML+RDFa page? What follows is a step-by-step instruction - it's so super easy, everybody can do it (even I managed to do it :).

Prepare

Some tiny steps in advance. Note that you don't need to go through it, however, it helps minimising the error-rate in advance, hence saves you a lot of time (otherwise you maybe have some iterations in the actual validation step).

Include the correct DTD at the top of the page

Right before the <html ...> element you'll need:

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

Make sure it is 'proper XML'

In W3C-tech-talk this is called well-formed, however it just means close your tags properly (e.g. <span>XXX</span><span>ZZZ</span>, rather than <span>XXX<span>ZZZ) and nest them correctly (e.g. <div><span>YYY</span></div>, rather than <div>XXX<span>ZZZ</div></span>).

Some extra bits from XHTML

I usually forget to check if certain attributes are used correctly. For example, each <img> needs an @alt= and you should use @id= rather than @name=. This can be nasty regarding forms, etc. but it is necessary.

The other thing you should be aware of is to encode the ampersand in URIs, that is use
http://example.com/q=a&amp;b
rather than http://example.com/q=a&b.

Validate

Now, let's assume you want to validate the page http://sw-app.org/mic.xhtml, that is check if this is a proper XHTML+RDFa page. Note that we can only do the syntactic check, here; this is no gurantee that the resulting RDF is somehow semantically sound.

The good news is that you're nearly there: Navigate to http://validator.w3.org/ and you should see the following:

W3C Validator

Note that if you don't have the page online, yet you can also upload a file or paste in the code (see the other two tabs in the W3C Validator).

Next, hit the Check button and you're done!

Have a look at the output. If all plays well you can reward yourself with adding the following to your page:

<p>
 <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml-rdfa" alt="Valid XHTML + RDFa" /></a>
</p>

Finally, enjoy validating!

Personal tools