opc.rels module#
- class opc.rels.Relationships(part)[source]#
Class for object that represents the xml of
RelsPartof the package. Inherits XmlTypeobjBase class. Xml of rels part is available as self.e- add_relation(type, target, target_mode=None)[source]#
Adds Relationships element to the xml. Assigns new Id and sets the Type, Target, TargetMode attributes to the element.
- Parameters:
type – str value of reltype
target – relative uri str value of the part target wrt to part of this relspart object
target_mode – optional param. Default value is None. No attribute TargetMode sets to the Relationships element if it is None. The value passed must be str type
- Returns:
str value of the new id assigned to the element
- get_lst_target_rel_uri_str(reltype)[source]#
Gets the list of relative uri of the target related by the given reltype
- Parameters:
reltype – str value
- Returns:
list of Target attribute values of parts related by reltype
- get_next_id()[source]#
Returns the new available id for the new relationship element :returns: str value of the new available id
- get_target_rel_uri_str(rid)[source]#
Method to get the target value of a relation given by rid
- Parameters:
rid – relation id string value
- Returns:
string value of relationship’s target value in xml
Example:
presentation_relspart = presentation_part.get_rels_part() relationships = presentation_relspart.typeobj # say the relationship xml is as below # <Relationship Id="rId2" Target="slides/slide1.xml" Type="..." /> print(relationships.get_target_rel_uri_str('rId2')) # slides/slide1.xml
- xmlns = 'http://schemas.openxmlformats.org/package/2006/relationships'#