$ show w3c/epubcheck
EPUBCheck is the official W3C conformance checker for EPUB publications. It validates EPUB 2 and EPUB 3 files against the respective specifications, including OCF packaging, OPF metadata, XHTML/SVG content, CSS, media overlays, navigation documents, and accessibility metadata. The tool operates as a Java command-line application and library, using a modular checker architecture where dedicated handlers validate specific resource types (e.g., OCFChecker, OPFChecker, OPSChecker, CSSChecker). Validation is driven by a combination of RelaxNG schemas for structural rules and Schematron for cross-cutting constraints. The project includes an extensive test suite using Cucumber/BDD features and thousands of test EPUB packages covering error and valid scenarios across all profile extensions (ePub 3, EDUPUB, dictionaries, indexes, multiple renditions, previews, and region-based navigation).
The LLM identified 3 files worth highlighting for reuse:
A standalone, forgiving CSS parser (grammar-level) that tokenizes and parses CSS content with error recovery. It uses a callback-based architecture (CssContentHandler, CssErrorHandler) similar to SAX, supports style attributes, @rules, selectors, and declarations. It includes localized error codes and can be extracted for non-EPUB CSS validation projects.
Utility class for URL encoding, decoding, and normalization per the URL Standard. Provides methods like encodeURIComponent, isAbsoluteURL, and percent-encoding validation. Isolated from internal dependencies, it can be reused in any Java project needing robust URL processing.
A generic framework for defining controlled vocabularies as enums with property status (allowed, deprecated, disallowed). It provides methods for case-insensitive lookup and aggregate vocabularies. This pattern is reusable for any application that needs to manage a set of known string values with lifecycle states.