---
license: other
license_name: snapkitty-tri-license
license_link: https://huggingface.co/Snapkitty/sovereign-xml-compiler/blob/main/LICENSE.tri
library_name: custom
tags:
- code
- sovereign-compute
- snapkitty
- compilers
- python
---
```
███████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗██╗ ██████╗ ███╗ ██╗
██╔════╝██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝██║██╔════╝ ████╗ ██║
███████╗██║ ██║██║ ██║█████╗ ██████╔╝█████╗ ██║██║ ███╗██╔██╗ ██║
╚════██║██║ ██║╚██╗ ██╔╝██╔══╝ ██╔══██╗██╔══╝ ██║██║ ██║██║╚██╗██║
███████║╚██████╔╝ ╚████╔╝ ███████╗██║ ██║███████╗██║╚██████╔╝██║ ╚████║
╚══════╝ ╚═════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝
██╗ ██╗███╗ ███╗██╗ ██████╗ ██████╗ ███╗ ███╗██████╗
╚██╗██╔╝████╗ ████║██║ ██╔════╝██╔═══██╗████╗ ████║██╔══██╗
╚███╔╝ ██╔████╔██║██║ ██║ ██║ ██║██╔████╔██║██████╔╝
██╔██╗ ██║╚██╔╝██║██║ ██║ ██║ ██║██║╚██╔╝██║██╔═══╝
██╔╝ ██╗██║ ╚═╝ ██║███████╗ ╚██████╗╚██████╔╝██║ ╚═╝ ██║██║
╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝
```
XML in. SVG out. Zero dependencies.
---
## What Is This?
Two compilers that turn XML into visual output:
1. **XMLToSVG** — takes a scene description in XML, outputs a standalone SVG image
2. **ConstraintGraphCompiler** — takes a directed graph in XML, outputs both an SVG visualization AND a runtime execution pipeline (topological order via Kahn's algorithm)
Both run server-side (Python), client-side (XSLT in any browser), and as a CLI. No lxml. No numpy. No external packages. Pure Python stdlib.
```
╔══════════════════════════════════════════════════════════════════╗
║ ║
║ YOUR XML OUTPUT ║
║ ──────── ────── ║
║ ║
║ ┌─────────────────────────┐ ║
║ │ │ ║
║ ──────> │ Beautiful SVG image │ ║
║ │ (dark theme, styled) │ ║
║ └─────────────────────────┘ ║
║ ║
║ ┌─────────────────────────┐ ║
║ │ SVG graph diagram │ ║
║ ──────> │ + execution pipeline │ ║
║ │ ["A", "B", "C"] │ ║
║ └─────────────────────────┘ ║
║ ║
╚══════════════════════════════════════════════════════════════════╝
```
---
## Quick Start
```bash
# From source
git clone https://github.com/SNAPKITTYWEST/sovereign-xml-compiler
cd sovereign-xml-compiler
# Scene to SVG
python xml2svg.py examples/scene.xml > output.svg
# Constraint graph to SVG
python constraint_graph_svg.py examples/constraint_graph.xml > graph.svg
# Run in browser (no server-side code needed)
python -m http.server 8000
# open http://localhost:8000/browser/graph_browser.html
```
---
## Install
```bash
# pip (installs CLI commands: xml2svg, constraint-graph)
pip install sovereign-xml-compiler
# from source (editable)
pip install -e .
# docker
docker run -p 8000:8000 ghcr.io/snapkittywest/sovereign-xml-compiler
# open http://localhost:8000/browser/graph_browser.html
```
Requires Python 3.9+. Zero external dependencies.
---
## User Guide
### Compiler 1: XML Scene to SVG
Write a scene in XML using simple shape primitives:
```xml
Hello, Sovereign
```
Compile it:
```bash
# CLI
xml2svg scene.xml output.svg
# Python
from xml2svg import XMLToSVG
svg_string = XMLToSVG().compile(open("scene.xml").read())
```
Supported elements: `rect`, `circle`, `line`, `path`, `text`, `group`
### Compiler 2: Constraint Graph to SVG + Runtime
Define a processing pipeline as a directed graph:
```xml
```
Get both a visualization AND an execution order:
```python
from constraint_graph_svg import ConstraintGraphCompiler
compiler = ConstraintGraphCompiler()
# Dark-themed SVG visualization of the graph
svg = compiler.compile_to_svg(xml_string)
# Executable runtime dict with topological pipeline
runtime = compiler.compile_to_runtime(xml_string)
# runtime = {
# "nodes": [...],
# "edges": [...],
# "pipeline": ["input", "validate", "transform", "output"]
# }
```
The `pipeline` field is computed via **Kahn's algorithm** — guaranteed topological order. Cycles are detected and rejected.
### Browser Mode (XSLT, No Server)
Open `browser/graph_browser.html` in any modern browser. It uses the browser's native `XSLTProcessor` to transform XML into SVG client-side. No JavaScript frameworks. No build step.
```
╔══════════════════════════════════════════════════════════════╗
║ browser/graph_browser.html ║
║ │ ║
║ ├── fetches constraint_graph.xml ║
║ ├── fetches constraint_graph.xsl ║
║ ├── applies XSLTProcessor (browser-native) ║
║ └── renders SVG in sandboxed