WordprocessingML document by hand


  • You will have to have Word 2007 or sth that opens up *.docx file, or else don’t read this!
  • If you put a space inside the XML codes, I’m going to personally come down to kill you.. 😀
  • Extremly geeky post, so proceed with caution!

Ever wanted to manually modify a base WordprocessingML file using Zip tool and Notepad ? This will make u a novice geek about ‘how package parts and relationships are stored in the XML files inside an Office Open XML Package’.

You’ll start by creating the entire package in a folder. Once you’re done creating the package, you’ll put them all in to a Zip file. After you rename the zip file to end in .docx you’ll have a complete WordprocessingML package. 😉

Create a new folder for the package:

  • Create folder named Package.
  • Create a new file named [Content_Types].xml in it. Add content type for rels files.

<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes” ?>
<Types xmlns=”http://schemas.openxmlformats.org/package/2006/content-types”&gt; <Default Extension=”rels” ContentType=”application/vnd.openxmlformats-package.relationships+xml” />

  • Save the [Content_Types].xml file.

Add the core.xml package part:

  • Create new folder named docProps inside package folder. Create core.xml file and put it this folder. Put this code in it!

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?>
<coreProperties xmlns=”http://schemas.openxmlformats.org/package/2006/metadata/core-properties”><title xmlns=”http://purl.org/dc/elements/1.1/”>The file that I made on my own </title><description xmlns=”http://purl.org/dc/elements/1.1/”>This is a good example of how difficult things get inside word file.</description></coreProperties>

  • Open [Content_Types].xml and add add the code. This is to notify the new content type for the core.xml package part.

<Override PartName=”/docProps/core.xml” ContentType=”application/vnd.openxmlformats-package.core-properties+xml” />

Relate the document properties to the package:

  • Create a new folder named _rels in the package folder. Create a new file named .rels (Just save *.txt file with Save As . Rename doesn’t work).
  • Add this code to .rels file. This is to create relationship to the new /docProps/core.xml package part.

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes”?>
<Relationships xmlns=”http://schemas.openxmlformats.org/package/2006/relationships”&gt;
<Relationship Id=”rId1″ Type=”http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties&#8221; Target=”/docProps/core.xml”/>

  • Save & close.

Add the document.xml package part:

  • Create a new folder named word inside the package folder.
  • Copy document.xml file attached with the post. Please copy the content of document.doc to a notepad file and rename it to document.xml.
  • Open the [Content_Types].xml file and add the code. This is to notify new content type for the document.xml package part.

<Override PartName=”/word/document.xml” ContentType=”application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml” />

  • Save the [Content_Types].xml file.

Relate the document.xml file to the package:

  • Open the _rels/.rels file and add this code to notify the relationship to the new document.xml package part.

<Relationship Id=”rId2″
Type=”http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument&#8221; Target=”/word/document.xml”/>

  • Save and close the .rels file.

Add a image to the package part:

  • Open package folder, create a new folder inside the word folder named media. place any image and name it as image1.gif file.
  • Open [Content_Types].xml and add a new Default content type for all gif files. Map gif files to the image/gif content type.

<Default Extension=”gif” ContentType=”image/gif”/>

  • Save and close the [Content_Types].xml file

Add a relationship between document.xml and image1.gif:

  • Open package folder >words > create another new folder named _rels. Create a new file named document.xml.rels (do it by Save As) in the new _rels folder.
  • Add a new relationship to this file that references media/image1.gif. Use the next valid Id which is rId1.

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes”?>
<Relationships xmlns=”http://schemas.openxmlformats.org/package/2006/relationships”&gt;
<Relationship Id=”rId1″ Type=”http://schemas.openxmlformats.org/officeDocument/2006/relationships/image&#8221; Target=”media/image1.gif”/>

Add an external relationship to a website:

  • In document.xml.rels add another relationship that references http://myhomepage.com (or to any URL you like) as an external resource. Use the next valid Id which is rId2.

<Relationship Id=”rId2″ Type=”http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink&#8221; Target=”http://myhomepage.com&#8221; TargetMode=”External” />

  • The Id specified in this line is critical. The new document.xml file explicitly references this Id. The document will not load correctly if this Id is not correct. The TargetMode of External specifies that this resource cannot be found in the package (heheheee.. did I scare you?).
  • Save the file and close it.

Repackage the new document:

  • Select all the files in the package folder, right click them, and select Send To -> Compressed (zipped) Folder. (Note, target the .zip file inside the package folder)
  • Rename the new Zip file aWordFileImadeByHand.docx.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s