构建完整的DrawIO XML结构
(self,
canvas_width: int,
canvas_height: int,
sorted_fragments: List[XMLFragment])
| 351 | ) |
| 352 | |
| 353 | def _build_xml_structure(self, |
| 354 | canvas_width: int, |
| 355 | canvas_height: int, |
| 356 | sorted_fragments: List[XMLFragment]) -> ET.Element: |
| 357 | """ |
| 358 | 构建完整的DrawIO XML结构 |
| 359 | """ |
| 360 | # 创建基础结构 |
| 361 | mxfile = self._create_base_xml(canvas_width, canvas_height) |
| 362 | root_elem = mxfile.find(".//root") |
| 363 | |
| 364 | # 添加各个片段,重新分配ID |
| 365 | current_id = 2 # 0和1已被基础cell占用 |
| 366 | |
| 367 | for fragment in sorted_fragments: |
| 368 | cell = self._parse_and_update_cell(fragment.xml_content, current_id) |
| 369 | if cell is not None: |
| 370 | root_elem.append(cell) |
| 371 | current_id += 1 |
| 372 | |
| 373 | return mxfile |
| 374 | |
| 375 | def _parse_and_update_cell(self, xml_content: str, new_id: int) -> Optional[ET.Element]: |
| 376 | """ |
no test coverage detected