Page 18 of 29PREVNEXT

Open XML II: Editing Documents in the XML

Edit file extension in references

When editing the file extension in the references such as those shown here, notice that the file extension appears twice in a single reference.
Callout 1 A relationship reference for an image file, as shown in a document.xml.rels file.
Callout 2 A Default Extension reference for an image file type, as it appears in [Content_Types].xml

If your replacement image file type is different from the file type of the original image, you must also update applicable .rels files and the default extension definitions in [Content_Types].xml.

First, follow the steps on the screen titled “Replacing an image file in the ZIP package” to replace the image file. When changing the filename of the new image, do not change the file extension. Then, take just two additional steps.

  1. If a default extension reference does not already exist for the replacement image file type in the file [Content_Types].xml, add one. To do this easily, copy an existing reference for an image file type (as shown in the image) and change the extension throughout that reference.
  2. Edit all relationship references for the replaced image file (such as the one shown in the image) to use the new file extension. For example, if the image appears in the body of a Word document, find the relationship reference in document.xml.rels.

Be sure to edit the .rels file for each document part in which the image appears. For example, if the image also appears in the first header of the document, edit the appropriate relationship in header1.xml.rels.


  • Remember that you can always find the applicable .rels file in the _rels subfolder located in the same folder as the referenced document part.
  • Excel ZIP packages also include a drawings folder with additional information about images that appear in the file. When editing relationships in step 2 above, remember to also edit applicable relationships in the _rels subfolder that appears inside the drawings folder.
Page 18 of 29PREVNEXT