Modeling a Contact List
by Ivan Gibbs
2014-05-14

I was experimenting with MDE many moons ago while working as a systems programmer. At the time XML and XSL were quite new. This led to an attempt to create a contact list with XML. The basic experiment had good results and I have expanded it since then. Here, I am going to talk about that project.

The project started with defining a model of a contact (Figure 1). An actual instance of that model is shown in Figure 2. That was the extent of the XML.

Since I wanted to have an HTML contact list, I mapped the XML into an HTML document to allow me to access my contacts list from anywhere via a browser. The mapping of the XML to HTML was done with XSL. The XSL mapping for a Name is shown in Figure 3.

Now that I had created the XML and XSL files, I used a UNIX command line utility xsltproc to process these two files to create the final HTML file.


1 <Person active='true'>
2 <Name>
3 <First/>
4 <Middle/>
5 <Last/>
6 <Nick>
7 </Name>
8 <Phone/>
9 <Address>
10 <Address1/>
11 <Address2/>
12 <City/>
13 <State/>
14 <Zip/>
15 <Email/>
16 <Website/>
17 </Address>
18 <Information/>
19 </Person>

Figure 1: A Person model

1 <Person active='true'>
2 <Name>
3 <First>Sergiu</First>
4 <Last>Dascalu</Last>
5 </Name>
6 <Address>
7 <Email>dascalus@cse.unr.edu</Email>
8 </Address>
9 <Information>Phd advisor.</Information>
10 </Person>

Figure 2: A Person instance for Sergiu Dascalu

1 <xsl:template name='displayName'>
2 <b><xsl:value-of select='Name/First'/></b>
3 <xsl:text> </xsl:text>
4 <b><xsl:value-of select='Name/Last'/></b>
5 <xsl:text> </xsl:text>
6 <xsl:if test='Name/Nick'>
7 <xsl:text/>
8 <b>(<xsl:value-of select='Name/Nick'/>)</b>
9 </xsl:if>
10 </xsl:template>

Figure 3: XSL mapping to HTML

After the HTML mapping, I proceeded to map that contact list into LDIF for Mozilla Thunderbird, to vCard for Apple's address book, and to an Alias file for the Mutt email reader, I also create a personal and work version for contact list to help keep my mind on work when I am at work and off of work when at home. Actually, the current workflow for creation is shown in Figure 4.

people.xml -(toWork.xsl)-> work.xml -(toLdif.xsl)-> work.ldif -(import into)-> Gmail

people.xml -(toWork.xsl)-> work.xml -(toAlias.xsl)-> work.alias -(import into)-> Mutt email client
people.xml -(toHome.xsl)-> home.xml -(toVcard.xsl)-> home.vcard -(import into)-> Apple address book
people.xml -(toHome.xsl)-> home.xml -(toHtml.xsl)-> home.html -(deploy to)-> website
Figure 4: Workflow of contact list creation

This project began as a simple way to keep track of contacts without depending upon some vendor supplied method. It has also provided some entertainment during my Christmas vacations-which is the only time that I actually work on this project.