2

I am using the API validator.nu:

https://github.com/validator/validator/wiki/Service:-Input:-POST-body

I want to force validation according to strict or transitional XHTML doctype :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

In the documentation, they are asking to send the request header: Content-type: text/html; charset=utf-8

I think that XHTML is a an XML-like code ?!

After sending the content which contains non-valid markup like <br> (no closing "/"), the web service doesn't return any errors. I think that is hanlding code as HTML5.

How to validate XHTML document ?

Ani Menon
  • 27,209
  • 16
  • 105
  • 126
AFA Med
  • 241
  • 2
  • 11

2 Answers2

1

There are two parts to your question:

I want to force validation according to strict or transitional XHTML doctype

You can't. Validator.nu does not support DTD based validation. It is an (X)HTML 5 validator, not a DTD based validator. The obsolete W3C validator provides an API that does support DTD checking, and other XML validators based on DTDs are available.

You should probably move to (X)HTML 5 though. It better reflects what browsers actually support than XHTML 1.0 does.

In the documentation, they are asking to send the request header: Content-type: text/html; charset=utf-8

I think that XHTML is a an XML-like code ?!

The documentation does say that that is only an example. The Content-Type for an XHTML document (including an XHTML 5 document) is application/xhtml+xml.

That should trigger XML parsing, so <br> should trigger an error. It will still be checking against the HTML 5 specification though, not the XHTML DTDs.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • It worked, but I also got an unexpected error "Bad value “Content-Type” for attribute “http-equiv” on XHTML element “meta” for – AFA Med May 15 '16 at 14:37
  • @Simohammedhttc — Why is it unexpected? You've made two claims about what the content-type of the document is and they don't match. – Quentin May 15 '16 at 14:38
  • I have to change the value of http-equiv, http://stackoverflow.com/questions/6320084/why-is-meta-http-equiv-content-script-type-mostly-unused – AFA Med May 15 '16 at 14:43
  • Note that moving to XHTML5 will entail changing lots of things to make it work, e.g. named entity references into numerical character references. – Mr Lister May 16 '16 at 08:05
0

Follow this :

  1. Goto : W3C Markup Validation Service
  2. Choose validate by URI or File Upload or Direct input.
  3. Then in More Options choose UTF-8 for character encoding and XHTML Strict for Document Type.
  4. Then click on Check.

You will get the XHTML Strict output.

Ani Menon
  • 27,209
  • 16
  • 105
  • 126