XML / XSL Contacts List: HTML

So, this started out as a project to create a contacts list that was platform independent. That would allow me to use it at home on my Macintosh computer and at work on my Microsoft Windows PC. There are some very nice tools for creating XML documents and XSL documents. Originally, I used these tools, but recently, a normal text editor such as vim has provided me enough control to add names and update information.

The XML document provides the following structure to store a contact.

Basic person entry

And, from there, I can fill in as many people as I like for my contacts. An example contact is shown below.

Basic person entry

Now, we have an XML document, but what use is that? You could make a software interface to read from the document and display the contacts, such as the Apple Address Book or Microsoft’s ‘Contacts.’ However, it would be difficult to get cross platform capabilities that way.

XSL is a language that allows you to format an XML document. So, you can use XSL to create an HTML document from an XML document! Below is an example of how to test if a specific person has a <Phone> tag and if so, then show it in the HTML document. The 'callto' element allows a browser to recognize this as a phone number, which is hyperlinked to invoke whatever phone software you have on your computer--I use Skype.

Basic person xsl for phone number

There are some other aspects to this stuff, but I won’t go into details here. In fact, I started out with one simple XSL document to transform all of my stuff, but now I have many XSL documents that are combined to create the output I want; abook, html, vCard, etc. See my blog article on modeling a contact list in XML for more information about that part of the project.

So, the HTML created shows up as illustrated below:

Basic person html representation

Now, I would just have a long HTML page of contacts, and that is not as useful as having an indexed list of names which are linked to their information. Interestingly enough, with XML, I can do that as well. The picture shown below shows the top of my contacts HTML document. These names are all hyperlinked to their contact information further down in the document.

List of people

Wow, so now I have an XML / XSL address list that is as platform independent as HTML is.

Now, today we don't think this is so neat, but back in 2001 when XML and XSL were new it was quite an achievement. Since then, this project has grown to accommodate different address book formats such as the Apple address book, the mutt emailer address book, and Microsoft contacts. See my blog article on modeling a contact list in XML for more details.