This project converts an Ampla Project XML export into an ISA‑95 B2MML Equipment model. It replaces the original XSLT‑only approach with a Python implementation that provides a command‑line interface, a FastAPI service, and JSON output.
Ampla Project XML files contain equipment definitions, hierarchy, classes, and properties. This tool reads that XML, normalizes it to match the behavior of the original XSLT, and produces either:
- B2MML Equipment XML
- a structured JSON model
The transformer is fully tested and suitable for automation, integration, and comparison of Ampla project configurations.
This project is a modern re‑implementation of the original XSLT stylesheet published here:
https://github.com/Ampla/Project-To-B2MML
The Python version reproduces the transformation logic, adds normalization, and provides a complete API, CLI, and test suite.
git clone https://github.com/<your-username>/amplab2mml.git
cd amplab2mml
python -m venv .venv
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
pip install -r requirements.txt
b2mml convert tests/data/sample_ampla.xml output.xml
b2mml json tests/data/sample_ampla.xml output.json
If no output file is provided, JSON is written to stdout:
b2mml json tests/data/sample_ampla.xml
Start the FastAPI server:
uvicorn app.main:app --reload
GET /health— basic health checkPOST /convert/json— upload an Ampla XML file, receive JSONPOST /convert/xml— upload an Ampla XML file, receive B2MML XML
Example using curl:
curl -X POST -F "file=@tests/data/sample_ampla.xml" http://localhost:8000/convert/json
app/parsers— reads Ampla XMLapp/transformers— converts to internal model and applies normalizationapp/builders— generates B2MML XMLapp/cli.py— command‑line interfaceapp/api.py— FastAPI applicationtests/— full test suite
This project is licensed under the BSD 3‑Clause License.
It includes third‑party material derived from the original Ampla_to_Equipment_B2MML.xslt by Oleg Tkachenko (2005), also under the BSD 3‑Clause License.