Sign inSign up

openstax/xhtml-validator

By openstax

Updated over 4 years ago

Image
0

10K+

openstax/xhtml-validator repository overview

About xhtml5-validator

This repository provides several validation checks on both the structure of the XHTML files and the data inside the files. This is more than just a schema validator.

It checks the correctness of values in the XHTML file: e.g. id="..." attributes are unique, internal links actually point to somewhere in the document.

It will also check that the structure of the XHTML is correct. Self-closing tags are a problem for HTML parsers so we aim to generate XHTML that can also be parsed by HTML parsers. Self-closing spans, links, headings are particular culprits.

Details

This performs the following validations:

  • xhtml schema validation using validator/validator (just disabled for now)
  • unique id attributes
  • internal links point to an existing element

How to Use

Mount a volume and specify the path to the XHTML file as the argument.

# Clone this repo and run:
docker run --volume $(pwd):/data --rm -it $(docker build -q .) /data/test/resources/fail-duplicate.xhtml
docker run --volume $(pwd):/data --rm -it $(docker build -q .) /data/test/resources/fail-no-link-target.xhtml
docker run --volume $(pwd):/data --rm -it $(docker build -q .) /data/test/resources/pass.xhtml

docker run --volume $(pwd):/data --rm -it $(docker build -q .) /data/test/resources/fail-link-to-duplicate-id.xhtml link-to-duplicate-id

An additional optional argument specifies which test to run:

  • none: all the validation checks
  • "duplicate-id": check for duplicate id attributes
  • "broken-link": check for internal broken links
  • "link-to-duplicate-id": duplicate ids are ok (not strictly valid XHTML) but links to duplicates is an error

Build and run tests

A full build (including generation of .jar and running unit tests) can be invoked using the build gradle task:

./gradlew build

Build artifacts will be generated in ./build, and xhtml-validator.jar can be found in ./build/libs/.

The unit tests can be run using the test task:

./gradlew test

The environment can be cleaned up using the clean task:

./gradlew clean

Tag summary

Content type

Image

Digest

Size

64.6 MB

Last updated

over 4 years ago

docker pull openstax/xhtml-validator:20220118.185647