This directory contains small browser-based XML validator examples that run
Python through Pyodide. The pages load Python in the
browser, install the python-package xmlschema, and validate XML text against an XSD
schema without requiring a backend service.
xml_validator_01.html- self-contained example with the Python validation code embedded in the page.xml_validator_02.html- example that loads validation logic fromvalidator.py.validator.py- Python helper used byxml_validator_02.html.
(Assumes uv is installed.)
git clone git@github.com:Brown-University-Library/pyodide_example.git
cd ./pyodide_example
Start a local static file server from this directory:
uv run --python 3.12 -m http.server 8000Then open one of these pages in a browser:
Wait for the page to finish loading Pyodide and installing xmlschema. When the
status says Ready., edit the XML or XSD text if needed and click
Validate XML or Validate.
- The first load may take a little while because Pyodide and Python packages are downloaded in the browser.
- An internet connection is required unless the Pyodide runtime and Python packages are already cached by the browser.
- Use the local server rather than opening the HTML files directly from disk.
xml_validator_02.htmlfetchesvalidator.py, which browsers commonly block fromfile://pages.