Representing Relationships
Relationships are represented in XML in a Relationships part. Each part in the package that is the source of one or more relationships can have an associated Relationships part. This part holds the list of relationships for the source part. For more information on the Relationships namespace and relationship types, see Annex F, “Standard Namespaces and Content Types.”
A special naming convention is used for the Relationships part. First, the Relationships part for a part in a given folder in the name hierarchy is stored in a sub-folder called “_rels”. Second, the name of the Relationships part is formed by appending “.rels” to the name of the original part. Package relationships are found in the package relationships part named “/_rels/.rels”.
The package implementer shall name relationship parts according to the special relationships part naming convention and require that parts with names that conform to this naming convention have the content type for a Relationships part. [M1.30]
Example 8–4. Sample relationships and associated markup
The figure below shows a Digital Signature Origin part and a Digital Signature XML Signature part. The Digital Signature Origin part is targeted by a package relationship. The connection from the Digital Signature Origin to the Digital Signature XML Signature part is represented by a relationship.
The relationship targeting the Digital Signature Origin part is stored in /_rels/.rels and the relationship for the Digital Signature XML Signature part is stored in /_rels/origin.rels.
The Relationships part associated with the Digital Signature Origin contains a relationship that connects the Digital Signature Origin part to the Digital Signature XML Signature part. This relationship is expressed as follows:
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Target="./Signature.xml" Id="A5FFC797514BC" Type="http://schemas.openxmlformats.org/package/2006/relationships/ digital-signature/signature"/> </Relationships>
Example 8–5. Targeting resources
Relationships can target resources outside of the package at an absolute location and resources located relative to the current location of the package. The following Relationships part specifies relationships that connect a part to pic1.jpg at an external absolute location, and to my_house.jpg at an external location relative to the location of the package:
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships" <Relationship TargetMode="External" Id="A9EFC627517BC" Target="http://www.custom.com/images/pic1.jpg" Type="http://www.custom.com/external-resource"/> <Relationship TargetMode="External" Id="A5EFC797514BC" Target="./images/my_house.jpg" Type="http://www.custom.com/external-resource"/> </Relationships>
Example 8–6. Re-using attribute values
The following Relationships part contains two relationships, each using unique Id values. The relationships share the same Target, but have different relationship types.
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Target="./Signature.xml" Id="A5FFC797514BC" Type="http://schemas.openxmlformats.org/package/2006/ relationships/digital-signature/signature"/> <Relationship Target="./Signature.xml" Id="B5F32797CC4B7" Type="http://www.custom.com/internal-resource"/> </Relationships>