|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Creating and Applying an XML Resume Template in Microsoft Office Word 2003
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
Summary: Use XML in Microsoft Office Word 2003 to create user-friendly templates. In this article, learn how to mark up a template to create a resume template from which users can create resume documents. (9 printed pages)
The information set out in this topic is presented exclusively for the benefit and use of individuals and organizations outside the United States and its territories or whose products were distributed by Microsoft before January 2010, when Microsoft removed an implementation of particular functionality related to custom XML from Word. This information may not be read or used by individuals or organizations in the United States or its territories whose products were licensed by Microsoft after January 10, 2010; those products will not behave the same as products licensed before that date or licenses for use outside the United States.
Frank Rice, Microsoft Corporation
Applies to: Microsoft Office Word 2003
The goal of the demonstration in this article is to develop a resume template in Word taking advantage of a resume schema in XML and then have end users (who have no knowledge of XML) use the template to create resume documents. Resume documents look like traditional Word documents to the end user, who is familiar with the user-friendly editing environment of Word. But under the hood, each resume document created by the users contains XML that allows a computer to process the resume automatically and extract interesting pieces of information.
There are two stages of the scenario:
The goal is to create a Word template for resumes taking advantage of a sample XSD schema for resumes. The download included with this article includes the resume.xsd file, the sample XSD schema to use when creating the template. The schema is an example of a customer-defined XML schema that follows the XSD standard:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="resume-schema" targetNamespace="resume-schema" elementFormDefault="qualified"> <xsd:element name="Resume" type="ResumeType"/> <xsd:complexType name="ResumeType" mixed="true"> <xsd:all> <xsd:element name="Name" type="NameType" minOccurs="0"/> <xsd:element name="Objective" type="xsd:string" minOccurs="0"/> <xsd:element name="Experience" type="Experience" minOccurs="0"/> <xsd:element name="Education" type="Education" minOccurs="0"/> <xsd:element name="InterestSection" type="xsd:string" minOccurs="0"/> </xsd:all> </xsd:complexType> <xsd:complexType name="Experience" mixed="true"> <xsd:sequence> <xsd:element name="YearFrom" type="xsd:int"/> <xsd:element name="YearTo" type="xsd:int"/> <xsd:element name="Description" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="Education" mixed="true"> <xsd:sequence> <xsd:element name="YearFrom" type="xsd:int"/> <xsd:element name="YearTo" type="xsd:int"/> <xsd:element name="Description" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="NameType" mixed="true"> <xsd:all> <xsd:element name="FirstName" type="xsd:string"/> <xsd:element name="LastName" type="xsd:string"/> </xsd:all> </xsd:complexType> </xsd:schema>
To get started, we just use a traditional resume template included with Word (initially containing no customer-defined XML). We add XML from the resume schema to the template by marking up appropriate sections of the template with appropriate XML elements from the schema.
To get started, let's take advantage of a pre-made Word template, the resume.dot a sample file included in the download. This template is a simplified version of the elegant resume template in Word. Currently it is just a traditional Word template file and contains no XML yet.
On the File menu, click Open.
Go to the resume.dot file and click Open. The file is located wherever you saved the files from the download.
Now we attach the resume.xsd schema to it. This schema is just a simple XSD schema defining the structure of a resume. To do so, on the Tools menu, click Templates and Addins and then click the XML Schema tab.
This dialog is the main entry point to XML schema management in Word. It shows a list of XSD schemas added to Word. Since we've never used the resume schema with this document in Word before, the resume schema does not show up yet. When we attach the schema, Word automatically remember its location and include it in that list:
Click Add Schema.
Navigate to the resume.xsd file included in the download file and click Open.
Typically, corporations prefer to keep their schemas in a public location accessible to all users, rather than on someone's local computer, but for simplicity, we're just using the schema file from the computer.
Under Schema Settings, in the Alias text box, type Resume as the name for the schema.
Clear the Changes affect current user only box and then click OK.
Notice that Word added the schema to its schema library. The namespace of the schema now shows up in the Available XML Schemas list as Resume. Now attach the schema to the document itself:
In the Checked schemas are currently attached list verify the Resume check box is selected, and then click OK.
After Word attaches the schema to the template, we notice that the XML Structure task pane appears when we go back to the document.
This is for the XML developer's convenience. The task pane plays two major roles:
To show the existing customer-defined XML structure in the document in the upper portion of the task pane, in the Elements in the document section.
To allow the user to markup the document with other elements from the schema displayed in the lower portion of the task pane, in the Choose an element to apply to your current selection section.
Now we can apply XML markup from the resume schema to the resume template:
Click the RESUME element in the list of schema elements in the lower portion of the task pane.
When prompted, click Apply to Entire Document.
We just applied the top level RESUME element to the document. Now we see the list of elements available to apply inside of RESUME, as defined by the schema. Walk through the contents of the resume template and apply appropriate markup to it. Note that for increased editing simplicity, the contents of the resume are laid out as a table. This helps both the developer applying the XML markup, as well as the end user editing the document.
Select the first row of the resume containing the name Nancy Davolio.
Click the NAME element in the list of schema elements in the task pane.
Select the cell containing "Nancy".
Apply the FIRSTNAME element.
Notice that the list of available elements from the schema is context-sensitive and driven by the schema. Based on where you are in the document relative to other elements, you see child elements that according to the schema are available in the current context.
Select the cell containing "Davolio".
Apply the LASTNAME element.
Notice that as we apply markup from the schema to the document, all elements we've inserted into the document start showing up in the top part of the task pane, as a tree. This is to help the developer navigate the document, in addition to the visible tags.
In the Objective section, select the cell containing the replacement text (which displays: "Click here and type your objective").
Apply the Objective element to it from the task pane.
In the Experience section, select the entire row containing the simple boilerplate experience and apply the EXPERIENCE element to it.
Inside of that row, select cell containing the year "1990" and apply the YEARFROM element.
Select the cell containing "1994" and apply the YEARTO element.
Select the cell containing the sample experience description and apply the DESCRIPTION element.
Now that we're finished with the Experience section, repeat the same process for the Education section.
As you apply XML markup to the document, various yellow icons are displayed over the different nodes of the tree in the task pane. These represent validation errors. They show up whenever the structure or the content of the mapped document do not adhere to the rules set by the attached schema. When you hover over the icon, a ToolTip briefly describes the violation. Schema violations are also highlighted in the text of the document using purple squiggly lines (vertical or horizontal, depending on whether the element applies to an entire block of text or to a line of text). Right-click text containing validation errors and Word displays a brief description of the error.
Now we're ready to save the template and make it available to users:
On the File menu, click Save As.
Type a new file name for it, e.g. resume_xml.dot.
Thus far, we've seen the XML tags (purplish, rounded) in the document as we were applying the markup. This is for the developer's convenience. Select or clear the Show XML tags in the document check box in the task pane or simply by pressing CTRL+SHIFT+X to control the visibility of the tags.
Press CTRL+SHIFT+X to hide the XML tags and close Word.
For this part of the demonstration, assume that you are an end user creating a resume. We have no idea what XML is and don't need to understand any of it.
Double-click the resume_xml.dot file created earlier. You have just created a document based on the resume template.
Replace "Nancy" with your first name
Replace "Davolio" with your last name
Replace the Objective placeholder text with some text, e.g. To learn how to use computers.
Note we can edit the text the same way we always do in Word. Now let's look at some simple schema-driven content validation:
Replace the year, 1990, with the word year.
Notice that there is a purple squiggle beside the text.
Right-click on the squiggle.
The context menu gives a simple description of what is wrong.
Change "year" back to a valid year and the schema violation disappears. Now let us say that we are finished editing the resume and ready to save.
On the File menu click Save As.
In the Save as type list, choose XML Document as the file format.
Type a file name such as resume sample, and then click Save.
Now the XML file is ready for use. By default, the Word XML markup that represents all document features as well as the customer-defined XML is saved in a single XML file. You can look at the rich XML markup of the file in Internet Explorer.
If you prefer to save just the customer-defined XML without any Word-specific information, then you can save as data only:
On the File menu, click Save As.
Select the Save Data Only check box and click Save.
If you examine the XML file in Microsoft Internet Explorer, you notice only the data in the resume XML schema.
In this article we looked at the steps to create a resume template from a Word document. Creating a template in this way is an easy and efficient way to build a library of documents that you can repurpose as needed. Using a schema file to create the template gives you the added advantage of validating the data as you add tags. Creating templates using the techniques discussed in this article is straight-forward and speeds up the process.