MerrimanInd/drawpyo
View on GitHubload_mxlibrary: support multi-cell stencil icons (e.g. OCI Library.xml)
Open
#126 opened on Mar 16, 2026
extended objecthelp wanted
Repository metrics
- Stars
- (410 stars)
- PR merge metrics
- (PR metrics pending)
Description
Problem
`load_mxlibrary()` fails to parse icons from Oracle's official **OCI Architecture Diagram Toolkit** (`OCI Library.xml`,
224 icons). All 224 items return `"No valid mxCell found in XML"`.
The issue is that OCI icons are **multi-cell Visio stencils** — each icon is an `mxGraphModel` containing 4-15 nested
`mxCell` elements with `shape=stencil(...)` data. The current parser expects a single `mxCell` per library item.
## Reproduction
```python
import drawpyo
# This works (Azure icons are single-cell):
drawpyo.register_mxlibrary(
"azure",
"https://raw.githubusercontent.com/dwarfered/azure-architecture-icons-for-drawio/main/azure-public-service-icons/004%2
0azure%20ecosystem.xml"
)
# This fails (OCI icons are multi-cell):
shapes = drawpyo.load_mxlibrary("OCI Library.xml") # 0 shapes found
# WARNING: No valid mxCell found in XML (224 errors)
```
## Root Cause
Each OCI library item's decoded XML contains multiple mxCells with parent hierarchy:
```xml
<!-- Azure icon (works): single mxCell -->
<mxGraphModel><root>
<mxCell id="0"/><mxCell id="1" parent="0"/>
<mxCell id="2" style="shape=mxgraph.azure..." vertex="1" parent="1">
<mxGeometry width="50" height="50"/>
</mxCell>
</root></mxGraphModel>
<!-- OCI icon (fails): 5 mxCells with parent-child nesting -->
<mxGraphModel><root>
<mxCell id="0"/><mxCell id="1" parent="0"/>
<mxCell id="2" style="fillColor=none;strokeColor=none;" parent="1">
<mxGeometry x="10" width="84" height="73"/>
</mxCell>
<mxCell id="3" style="fillColor=#FFFFFF;shape=stencil(lVbb...);" parent="2">
<mxGeometry width="82" height="71"/>
</mxCell>
<mxCell id="4" style="fillColor=#FFFFFF;shape=stencil(pVnJ...);" parent="2">
<mxGeometry width="84" height="73"/>
</mxCell>
<mxCell id="5" style="fillColor=#2d5967;shape=stencil(nZRB...);" parent="2">
<mxGeometry x="1" y="1" width="80" height="69"/>
</mxCell>
<mxCell id="6" style="verticalAlign=middle;shape=stencil(nZBL...);" parent="1">
<mxGeometry y="77" width="104" height="40"/>
</mxCell>
</root></mxGraphModel>
```
## Expected Behavior
`load_mxlibrary()` should handle multi-cell items — return all cells as a group/composite, or at minimum not silently
discard them.
## Impact
OCI Library is Oracle's official draw.io icon set (224 icons), downloaded from:
https://docs.oracle.com/en-us/iaas/Content/General/Reference/graphicsfordiagrams.htm
Other vendor libraries may have similar multi-cell structures.