Export (0) Print
Expand All
Expand Minimize

Creating and Applying an XML Resume Template in Microsoft Office Word 2003

Office 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)

Important noteImportant

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

November 2003

Applies to: Microsoft Office Word 2003

Download odc_wdxmlresumetempsample.EXE.

Contents

Attaching an XML schema and marking up a Microsoft Office Word 2003 document provides a quick way for developers to create user-friendly templates. You can easily modify templates created in this manner to adjust to changing requirements.

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:

Resume template development:

An XML developer creates a resume template for use by end-users.

Resume template consumption:

An end user uses the template to create a resume.

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.

  1. Start Word.

    Figure 1. The resume.dot template file

    The resume.dot template file
  2. On the File menu, click Open.

  3. Go to the resume.dot file and click Open. The file is located wherever you saved the files from the download.

  4. 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:

  5. Click Add Schema.

  6. 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.

  7. Under Schema Settings, in the Alias text box, type Resume as the name for the schema.

  8. Clear the Changes affect current user only box and then click OK.

    Figure 2. The Templates and Add-ins dialog box

    The Templates and Add-ins dialog box

    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:

  9. 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.

    Figure 3. XML Structure task pane

    XML Structure task pane

    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:

  10. Click the RESUME element in the list of schema elements in the lower portion of the task pane.

  11. 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.

  12. Select the first row of the resume containing the name Nancy Davolio.

  13. Click the NAME element in the list of schema elements in the task pane.

  14. Select the cell containing "Nancy".

  15. 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.

  16. Select the cell containing "Davolio".

  17. 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.

    Figure 4. Mapped elements in resume template

    Mapped elements in resume template

    In the Objective section, select the cell containing the replacement text (which displays: "Click here and type your objective").

  18. Apply the Objective element to it from the task pane.

  19. In the Experience section, select the entire row containing the simple boilerplate experience and apply the EXPERIENCE element to it.

  20. Inside of that row, select cell containing the year "1990" and apply the YEARFROM element.

  21. Select the cell containing "1994" and apply the YEARTO element.

  22. Select the cell containing the sample experience description and apply the DESCRIPTION element.

  23. 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:

  24. On the File menu, click Save As.

  25. Type a new file name for it, e.g. resume_xml.dot.

    NoteNote

    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.

  26. 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.

  1. Double-click the resume_xml.dot file created earlier. You have just created a document based on the resume template.

  2. Replace "Nancy" with your first name

  3. Replace "Davolio" with your last name

  4. Replace the Objective placeholder text with some text, e.g. To learn how to use computers.

  5. 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:

  6. Replace the year, 1990, with the word year.

  7. Notice that there is a purple squiggle beside the text.

  8. Right-click on the squiggle.

  9. The context menu gives a simple description of what is wrong.

    Figure 5. Validation error

    Validation error
  10. 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.

  11. On the File menu click Save As.

  12. In the Save as type list, choose XML Document as the file format.

  13. 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:

  1. On the File menu, click Save As.

  2. 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.

Show:
© 2014 Microsoft