EPUB 2 OPF 2.0.1
EPUB 2 package (content.opf)
The content.opf of an EPUB 2 book, checked with the grammar and rules epubcheck uses.
About
EPUB 2 books, still common in back catalogues and some stores, describe their metadata, files and reading order in an OPF 2.0.1 package file.
Two layers are checked: the RELAX NG grammar (which also accepts the older OEB 1.2 package), then epubcheck's Schematron rules for OPF 2.
Good to know
- Drop the whole .epub on the validator's Upload tab to check the book file by file (container, package, NCX, content documents for well-formedness, missing files). CSS, fonts, links, media types and content rules are checked by epubcheck, not here.
- The example is by xmlvalid.com.
Files
3 files · 22.4 KB-
opf.rng main
-
opf20.rng
-
opf12.rng
The validator loads all of these with their folder structure, so includes and imports resolve as published.
Business rules
Schematron · run in this order-
EPUB 2 OPF rules (epubcheck) epubcheck 5
W3C EPUB 3 Community Group (epubcheck) · BSD 3-Clause (epubcheck)
The rules run after the schema check, only when the document matches the schema, and in your browser like the schema check (with SaxonJS by Saxonica). Each finding gives the line it points at.
Example document
content.opf · 1.2 KB · passes the schema and the rules
In CI and from code
The same schema by its name, epub-2-opf, through the API.
npx @xmlvalid/cli validate "**/*.xml" --schema epub-2-opf
- uses: xmlvalid/validate-action@v1
with:
files: "**/*.xml"
schema: epub-2-opf
api-key: ${{ secrets.XMLVALID_API_KEY }}
curl https://xmlvalid.com/api/v1/validations \
-H "Authorization: Bearer $XMLVALID_API_KEY" \
-F document={{ $schema->example ?? 'document.xml' }} -F schema=epub-2-opf
Free accounts get 100 API validations a month. On Pro, a URL monitor can check a published document against this schema every hour and email you when it breaks. More CI setups