- From: Bjoern Hoehrmann <derhoermi@gmx.net>
- Date: Wed, 01 Nov 2006 15:32:55 +0100
- To: www-validator@w3.org
Hi, I wrote a DOM-based XML DTD Validator in ECMAScript. It cannot parse DTDs, but given a DTD in a custom format, it will validate an element or an entire document against that DTD. It comes with pre-defined DTDs for XHTML 1.0 Strict, XHTML 1.0 Transitional, and XHTML 1.1. A demo is available at http://www.bjoernsworld.de/temp/jsdtd-valid.xhtml http://www.bjoernsworld.de/temp/jsdtd-invalid.xhtml The code is available at http://www.bjoernsworld.de/temp/BH_DOM_DTD_Validator.js.gz It should work with HTML and XHTML documents; for XHTML documents, if the browser ensures that the document is well-formed, this Validator is as powerful (or limited) as the W3C Markup Validator with the following caveat: attributes of types ID/IDREF/NMTOKEN/NMTOKENS are not checked for proper syntax; this is simply because I did not bother writing the regular expressions for these types. While the code is not particularily optimized, on my computer the SMIL 2.0 specification's single-file version (~ 2.00 MB) is validated in 8s by Opera 9, in 20s by Firefox trunk, and in ~ 100s by IE6, which is a bit funny considering IE6 loads the document faster by some orders of magnitude. You can use this Validator e.g. to validate user comments if you allow XHTML code somewhere, your own code, e.g. to conditionally display a "valid" / "invalid" icon on your homepage for improved quality testing, or you can modify the pre-defined DTDs to provide better validation as the Markup Validator. Converting DTDs into the format required by this tool is rather simple, but my tools to do that are too crude to publish. If you would like to use the Validator with any DTD not provided inline, please let me know and I might consider converting it, if possible. The code is huge unless gzip-compressed as I've done it above. The compressed version is currently 9999 bytes. If you use only e.g. the XHTML 1.0 Strict DTD and use one of the common compactor tools to strip comments and such, and then compress it again, it is possible to reduce the size to about 3.5 KB. I do not intend to continue development of this tool, if you like to take it over, please let me know. regards, -- Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Received on Wednesday, 1 November 2006 14:33:10 UTC