Creating a Resume From XML

John New

Structured using DocBook XML, edited using XMLmind XML editor, parsed using Saxon, tidied using HTML Tidy.

Revision History
This document was created by John New, an adjunct IT lecturer at Charles Sturt University, Australia.

1. Copyright
2. Introduction
3. What To Do
3.1. Obtain and Install Java
3.2. Create an XML Publishing Environment
3.3. Obtain and Install the XML Resume Library
3.3.1. Read the Documentation
3.3.2. Look At the XML Example Resumes
3.3.3. Display the XML Example Resumes
3.4. Obtain and Install the XML Processing Software
3.5. Edit an XML Example Resume
3.6. Create a Batch File to Process an XML Source File
3.7. Run the Batch File to Process XML
3.7.1. Create HTML Output
3.7.2. Create PDF Output
3.7.3. Create RTF Output
3.8. Create Your Own Resume
4. Conclusion
5. Resources

1. Copyright

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the GNU FDL is available from http://www.gnu.org/licenses/fdl.html.

2. Introduction

Creating a resume from XML has numerous benefits.

You can single-source, that is, produce a variety of other formats from a single XML source file. Common formats include HTML, plain text, rich-text format (RTF), and portable document format (PDF).

You can use filters, which enable you to produce a variety of resumes, each with a subset of relevant content, from a single XML source file. For example, you could create a master resume with your complete work history but create a version with your work history only from the last five years.

While you could create your own resume DTD or schema (many people do), it is often more productive to use an existing well-known DTD or schema.

3. What To Do

In this practical, you will set up your own XML publishing environment, create an XML resume based on the XML Resume Library DTD, and then produce versions in HTML, TXT, PDF, and RTF.

Various resources are available to help you complete this practical.

We will assume that you are setting up the environment on a Windows platform.

The following steps explain how to complete this practical. If there is no need to complete a step (for example, you already have an existing Java runtime environment), simply skip the step.

3.1. Obtain and Install Java

The XML publishing software you will be using requires a Java runtime environment. If you do not have an existing Java runtime environment, you must create one.

Currently, you can obtain a Java distribution from http://java.sun.com/javase/index.jsp. You can choose either the J2SE Development Kit (JDK) or the J2SE Runtime Environment (JRE). Run the installer and follow the instructions. When finished, restart your computer if required.

To check that Java is installed correctly, start a Command Prompt, and then type:

java

If correct, you will see a syntax listing.

3.2. Create an XML Publishing Environment

Now you need to create an XML publishing environment. This is a hierarchy of folders to publish XML documents. In this case, we are publishing XML resumes but you can easily adapt the hierarchy to publish other documents.

We will assume that you have created a hierarchy of folders as shown:

c:\xmlpub                             1
         \xmlresume                   2
                   README             3
                   \css               4
                   \doc               4
                   \dtd               4
                   \examples          4
                   \java              4
                   \myresumes         5
                             \fop     6
                             \xalan   7
                             \xerces  8
                             \xfc     9
                   \xsl               4
         \zip                         10
1

XML publishing environment top-level folder.

2

XML Resume Library publishing environment top-level folder.

3

XML Resume Library README file.

4

XML Resume Library subfolder.

5

Working folder for all data files, including XML source files and HTML, TXT, FO, PDF, and RTF output files. The working folder will also contain a batch file that runs XML processing software. The subfolders are for the XML processing software.

6

Fomatting Objects Processor (FOP) transforms formatting object (FO) documents to PDF documents.

7

Xalan transforms XML documents to HTML, TXT, and FO documents.

8

Xerces parses XML documents.

9

XMLmind FO Converter (XFC) transforms FO documents to RTF documents.

10

Working folder for the XML processing software zip files.

3.3. Obtain and Install the XML Resume Library

Currently, you can obtain the XML Resume Library from http://xmlresume.sourceforge.net/. Unzip the XML Resume Library so that files and folders correspond to the XML publishing environment hierarchy.

3.3.1. Read the Documentation

When you obtain new resources, it is very sensible to read its documentation. This takes time initially but it can save time in the long run. When you read documentation, there is often a Getting Started section. There may also be a tutorial that explains how to use the resources. These are good places to start with any new resource.

In the case of the XML Resume Library, browse around the folders and files from the zip file. Start off by reading the documentation. This will tell you the prerequisites required to use the XML Resume Library (Java and an understanding of XML), how to get the software you need to convert XML resumes to other formats (XML Resume Library, Xerces, and Xalan, and FOP), and how to install and configure the software.

3.3.2. Look At the XML Example Resumes

Also look at the examples. Looking at XML examples is very useful because examples can show you the best way to structure a document. Currently, the XML Resume Library has two examples, example1.xml and example1.xml, which show you two different ways to structure an XML resume.

Use a text editor, such as Notepad or Wordpad, to open the XML examples. Now look at the tags that are available to mark up an XML resume. Start thinking about how you can create your own resume from the examples.

3.3.3. Display the XML Example Resumes

There are two example resumes included with the XML Resume Library - example1.xml and example2.xml. Display the XML example resumes in a browser, such as Internet Explorer. Look at the structure of the document. Click the + and - signs to open and close different parts of the XML file.

Tip

If you encounter an error when attempting to display the XML files in a browser, see if you can work out what the error means.

One error message that may be displayed is:

Use of default namespace declaration attribute in DTD not supported. Error processing resource

See if you can work out what this problem means and how to solve it. You will have to understand namespaces and how they are used.

If you can't work it out, use a text editor to open the XML file and replace the <resume> tag with:

<resume xmlns="http://xmlresume.sourceforge.net/resume/0.0">

For example, after you have changed example1.xml, it should look like:

<resume xmlns="http://xmlresume.sourceforge.net/resume/0.0">
  <header>
    <name>
      <firstname>Jo</firstname>
      <surname>Doe</surname>
    </name>
...
</resume>

3.4. Obtain and Install the XML Processing Software

To process XML documents, you need to use XML processing software. We will use open-source or freely available software, in particular FOP, Xalan, Xerces, and XFC. Currently, you can obtain the software from:

At this stage you don't need to know what the software does, just that it is required.

Place all software in the zip folder of the XML publishing environment. Unzip each distribution in turn. Search through the subfolders, find all jar files, and place them in the appropriate XML processing subfolder.

For example, place all FOP jar files in:

c:\xmlpub\xmlresume\myresumes\fop\

Currently, this includes files such as:

avalon-framework-4.2.0.jar
batik-all-1.6.jar
commons-io-1.1.jar
commons-logging-1.0.4.jar
fop.jar
fop-hyph.jar
jai_codec.jar
jai_core.jar
jimi-1.0.jar
serializer-2.7.0.jar
xalan-2.7.0.jar
xercesImpl-2.7.1.jar
xml-apis-1.3.02.jar
xmlgraphics-commons-1.0.jar

Of course, the files are likely to be different in earlier or later versions of the software, or they may be in a variety of subfolders. You should find all files.

3.5. Edit an XML Example Resume

At this point, one of the easiest ways to work out how to produce a resume is to edit an example and replace some of the existing information with your own details. That way, you will be using XML tags that you know are correct but XML content that is different from the original. This is one step toward developing a complete resume of your own.

Copy the two XML Resume Library examples from:

c:\xmlpub\xmlresume\examples\example1.xml
c:\xmlpub\xmlresume\examples\example2.xml

to:

c:\xmlpub\xmlresume\myresumes\myexample1.xml
c:\xmlpub\xmlresume\myresumes\myexample2.xml

Now edit the <name> tag in each myexample and insert your own name. For example, if your name is Snow White, insert your name like this:

    <name>
      <firstname>Snow</firstname>
      <surname>White</surname>
    </name>

Now you have two new resumes.

3.6. Create a Batch File to Process an XML Source File

When the time comes to process the XML source file and produce various types of output, arguably the easiest way to do so is by running commands from a batch file. A batch file can accept parameters (such as the name of an XML file), set up environment variables (that point to the location of the XML processing software), and run a Java command (to produce the desired output).

We will assume that you create a batch file called cv.bat (it is a good idea to use a short name for a batch file to reduce the typing you have to do). Create the batch file in the same location as the myexample resumes:

c:\xmlpub\xmlresume\myresumes\cv.bat

For convenience, copy and paste the following code to cv.bat:

@ECHO OFF

set LOCAL_RESUME_HOME=
if "%OS%"=="Windows_NT" set LOCAL_RESUME_HOME=%~dp0
set LIBDIR=%LOCAL_RESUME_HOME%

rem **********************************************************************
rem Xalan-J 2.7.0
rem http://xml.apache.org/xalan-j/
rem **********************************************************************
 set LOCALCLASSPATH=%LOCAL_RESUME_HOME%\xalan\bsf.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\serializer.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\xalan.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\xalansamples.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\xercesImpl.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\xml-apis.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\xsltc.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\xsltcapplet.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\xsltcbrazil.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\xsltcejb.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan\xsltcservlet.jar

rem **********************************************************************
rem XercesJ 2.8.0
rem http://xerces.apache.org/xerces2-j/
rem **********************************************************************
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xerces\resolver.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xerces\xercesImpl.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xerces\xercesSamples.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xerces\xml-apis.jar

rem **********************************************************************
rem FOP 0.92beta
rem http://xmlgraphics.apache.org/fop/0.92/index.html
rem **********************************************************************
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\fop.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\avalon-framework-4.2.0.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\batik-all-1.6.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\commons-io-1.1.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\commons-logging-1.0.4.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\fop-hyph.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\jai_codec.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\jai_core.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\jimi-1.0.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\serializer-2.7.0.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\xalan-2.7.0.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\xercesImpl-2.7.1.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\xml-apis-1.3.02.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop\xmlgraphics-commons-1.0.jar

rem **********************************************************************
rem XMLmind FO Converter v2.3p1
rem http://www.xmlmind.com/foconverter/
rem **********************************************************************
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xfc\xfc.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xfc\jaxp.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xfc\regexp.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xfc\sax.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xfc\xp.jar

rem ********************** 
rem SYNTAX
rem **********************
rem command line params 
rem %1: Name of resume file without extension: myresume
rem %2: Language code:                         [ br | de | fr | it | nl | uk | us ]
rem %3: paper format:                          [ letter | a4 ]
rem Example: 
rem cv myresume de a4 
rem cv myresume us html 
rem will compile resume.xml for German language and paper size a4 

rem **********************
rem To generate html
rem **********************
rem java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -in %1.xml -xsl ..\xsl\output\%2-html.xsl -out %1.html

rem **********************
rem To generate text
rem **********************
rem java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -in %1.xml -xsl ..\xsl\output\%2-text.xsl -out %1.txt

rem **********************
rem To generate pdf
rem **********************
rem java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -in %1.xml -xsl ..\xsl\output\%2-%3.xsl -out %1.fo
rem java -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %1.fo %1.pdf

rem **********************
rem To generate RTF
rem **********************
rem java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -in %1.xml -xsl ..\xsl\output\%2-%3.xsl -out %1.fo
rem java -cp "%LOCALCLASSPATH%" com.xmlmind.fo.converter.Driver %1.fo %1.rtf

3.7. Run the Batch File to Process XML

Look at the example syntax in the batch file. This shows you the structure of the command you must type in from a Command Prompt to pass parameters to the batch, to run the batch file, and to process the XML.

Let's try some examples.

3.7.1. Create HTML Output

To generate HTML from XML, look for these lines in the batch file:

rem **********************
rem To generate html
rem **********************
rem java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -in %1.xml -xsl ..\xsl\output\%2-html.xsl -out %1.html

and remove the rem statement from before the Java command so that it looks like this:

java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -in %1.xml -xsl ..\xsl\output\%2-html.xsl -out %1.html

Now start a Command Prompt, navigate to the location of the batch file, and then type a command such as the following:

cv myexample1 us

If everything is set up correctly, this will produce an HTML file called:

myexample1.html

If it doesn't work, it's debugging time. Go back through all steps again and see if you can work out what's going on.

If it does work, well done. Now try out some other commands to produce other types of HTML output.

If you are really brave, look at the \xmlresume\xsl\params.xsl file. This has a series of changeable settings that you can use to customise the HTML output.

3.7.2. Create PDF Output

Unlike HTML, creating PDF output is a two-step process.

The first step is to convert XML input to formatting objects (FO) output. The FO output becomes the input for the second step. In other words, the second step is to convert FO input to PDF output.

To generate PDF from XML, look for these lines in the batch file:

rem **********************
rem To generate pdf
rem **********************
rem java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -in %1.xml -xsl ..\xsl\output\%2-%3.xsl -out %1.fo
rem java -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %1.fo %1.pdf

and remove the rem statement from before each Java command so that they look like this:

java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -in %1.xml -xsl ..\xsl\output\%2-%3.xsl -out %1.fo
java -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %1.fo %1.pdf

Now start a Command Prompt, navigate to the location of the batch file, and then type a command such as the following:

cv myexample1 us letter

If everything is set up correctly, this will produce an HTML file called:

myexample1.pdf

If it doesn't work, it's debugging time. Go back through all steps again and see if you can work out what's going on.

If it does work, well done.

3.7.3. Create RTF Output

Now see if you put together everything you have learnt so far to create RTF output.

3.8. Create Your Own Resume

Your final task, now that you understand how to use the XML Resume Library and how to create different types of output, is to create your own resume.

You can either modify an existing resume or create a new resume with your own information.

Experiment by creating different formats.

Experiment by using filters to target your resume to various audiences.

Have fun!

4. Conclusion

If you have successfully completed all steps in this practical, you should now have a good understanding of the tasks required to set up an XML publishing environment, create an XML document (a resume), and then produce versions in HTML, TXT, PDF, and RTF.

5. Resources

Use the following resources, which are available from the Internet and/or locally, to help you complete the tasks in this practical: