` ` element, the root element in a .rels file.
| 121 | |
| 122 | |
| 123 | class CT_Relationships(BaseOxmlElement): |
| 124 | """`<Relationships>` element, the root element in a .rels file.""" |
| 125 | |
| 126 | relationship_lst: list[CT_Relationship] |
| 127 | _insert_relationship: Callable[[CT_Relationship], CT_Relationship] |
| 128 | |
| 129 | relationship = ZeroOrMore("pr:Relationship") |
| 130 | |
| 131 | def add_rel( |
| 132 | self, rId: str, reltype: str, target: str, is_external: bool = False |
| 133 | ) -> CT_Relationship: |
| 134 | """Add a child `<Relationship>` element with attributes set as specified.""" |
| 135 | target_mode = RTM.EXTERNAL if is_external else RTM.INTERNAL |
| 136 | relationship = CT_Relationship.new(rId, reltype, target, target_mode) |
| 137 | return self._insert_relationship(relationship) |
| 138 | |
| 139 | @classmethod |
| 140 | def new(cls) -> CT_Relationships: |
| 141 | """Return a new `<Relationships>` element.""" |
| 142 | return cast(CT_Relationships, parse_xml(f'<Relationships xmlns="{nsmap["pr"]}"/>')) |
| 143 | |
| 144 | @property |
| 145 | def xml_file_bytes(self) -> bytes: |
| 146 | """Return XML bytes, with XML-declaration, for this `<Relationships>` element. |
| 147 | |
| 148 | Suitable for saving in a .rels stream, not pretty printed and with an XML declaration at |
| 149 | the top. |
| 150 | """ |
| 151 | return oxml_to_encoded_bytes(self, encoding="UTF-8", standalone=True) |
| 152 | |
| 153 | |
| 154 | class CT_Types(BaseOxmlElement): |
nothing calls this directly
no test coverage detected
searching dependent graphs…