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.
<Person active="true"> <Name> <First> <Last> </Name> <Phone/> <Address> <Address1/> <Address2/> <City/> <State/> <Zip/> <Email/> <Website/> </Address> <Picture/> <Information/> </Person>
And, from there, I can fill in as many people as I like for my contacts. An example contact is shown below.
<Person> <Name> <First>Diane</First> <Last>Dunn</Last> </Name> <Phone>1-775-888-8888</Phone> </Person>
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.
<xsl:template name="displayPhone"> <xsl:if test="Phone"> Phone: <xsl:for-each select="Phone"> <a> <xsl:attribute name="href"> callto://+<xsl:value-of select="text()"/> </xsl:attribute> <xsl:value-of select="text()"/> </a> <xsl:value-of select="@type"/>, </xsl:for-each> <br/> <br/> </xsl:if> </xsl:template>
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:
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.
Davis, SherryWow, 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.