> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
$schema: https://holocron.so/frontmatter.json
title: PLCopen XML
description: Import and export graphical PLC projects as PLCopen XML 2.01 with bounds-checked parsing.
icon: lucide:file-code
---

RoboC++ implements **PLCopen XML 2.01** import and export in `iec_plcopen`. XML is parsed and canonicalized through **`roxmltree`** before project lowering. Use PLCopen for **graphical** LD, FBD, and SFC from external editors. For **native textual** LD and FBD, see [Native LD and FBD](/native-ld-fbd).

## CLI

```bash
cargo run -p rbcpp_cli -- import-plcopen project.xml --json
cargo run -p rbcpp_cli -- export-plcopen examples/counter.st -o build/counter.xml
```

**`import-plcopen`** reports discovered POUs. **`export-plcopen`** serializes a parsed textual project.

The CLI also accepts `.xml` inputs for **`check`**, **`run`**, and **`build-c`** (import runs inside `load_project`).

**`export-plcopen`** serializes the parsed IR back to XML without running semantic checking. Only parse/import errors block export.

**`import-plcopen`** always exits successfully; inspect diagnostics manually or use **`--json`**.

Example graphical projects ship in **`examples/plcopen_ld.xml`**, **`plcopen_fbd.xml`**, and **`plcopen_sfc.xml`**. See [Examples](/examples).

<Aside>
  <Note>
    **`iec_plcopen`** depends on **`roxmltree`** for XML parsing. Import rejects DTDs and entity expansion, enforces node-count, depth, text, and attribute bounds, canonicalizes XML, and lowers through the validated DOM (not raw string scraping). Hostile fixtures live under **`validation/corpus/plcopen/hostile/`** in the compiler repo.
  </Note>
</Aside>

## XML import limits

Default **implementation parameters** bound PLCopen input size and shape. Violations emit **`RBCPP-COMPLIANCE`** diagnostics before lowering:

| Parameter                         | Default              |
| --------------------------------- | -------------------- |
| `max_plcopen_xml_bytes`           | 1 MiB                |
| `max_plcopen_xml_nodes`           | 150,000              |
| `max_plcopen_xml_depth`           | 256                  |
| `max_plcopen_xml_text_bytes`      | 65,535 per text node |
| `max_plcopen_xml_attribute_bytes` | 65,535 per attribute |

Print all limits with **`rbcpp parameters --json`**. See [Language support](/language-support#implementation-limits).

## What round-trips well

* Project and POU structure
* Structured Text and IL bodies where mapped
* Textual and graphical SFC topology (steps, transitions, macro steps, branches, jumps)
* Project-level **`fileHeader`**, **`contentHeader`**, and **`addData`** vendor metadata
* LD and FBD network structure in the IR
* Configuration **`pouInstance`** input/output actuals in RoboC++ vendor **`addData`** (round-trip for program bindings)

## Ladder Diagram lowering

PLCopen LD import preserves networks in the IR and lowers executable power-flow networks into normalized assignment IR. The **`language.ld.power_flow`** compliance row is **`implemented`**, including:

* Left rails, series and parallel contacts, multiple coils
* Negated contacts and coils, set/reset coils
* Rising/falling edge contacts via hidden **`R_TRIG`** / **`F_TRIG`** helper instances
* Connector and continuation forwarding with deterministic coil order
* Interpreter and generated-C parity for imported networks

Verify your specific editor export with **`check`** and **`run`** before production use.

## FBD lowering

FBD import lowers acyclic data-flow graphs into calls and assignments. The **`language.fbd.data_flow`** row is **`implemented`**, including:

* Multi-output acyclic graphs and nested block calls
* Formal input wiring and connector forwarding with deterministic output order
* Feedback-path diagnostics when a cycle cannot be lowered safely
* Interpreter and generated-C parity for imported networks

<Aside>
  <Warning>
    Graphical POUs from third-party tools can still fail lowering if the network uses unsupported topology. Treat interchange as validated only after `check` and `run` on your file.
  </Warning>
</Aside>

## Related

* [CLI reference](/cli)
* [Architecture](/architecture): `iec_plcopen` crate
* [Language support](/language-support): language surface overview
* [Compliance](/compliance): `plcopen.xml`, `language.ld`, `language.fbd` rows


---

*Powered by [holocron.so](https://holocron.so)*
