I'm always interested in seeing things done differently than I would approach them. Not only do I learn from the experience, but often I find a simpler way of doing things.
For instance, on a recent project, some other Interknowlogy developers and I created a navigation bar using XML and Extensible Style Language (XSL). Let's look at some of the elements we used to implement this design and some of the advantages of this approach.
First, we created an XML page named navigation.xml that contained all the data for the navigation bar. For each link or button that we wanted the navigation bar to include, we created a category within the navigation tree. We then assigned each category a display name and a link that defines the path, as the following code shows:
To interpret the data, we created a corresponding XSL page named nav.xsl. This page uses the
If you prefer to display each row of the navigation bar in a different color, you simply add another attribute to the category in the navigation.xml page:
Then apply the attribute in the nav.xsl page:
The possibilities are endless. You can define anything you want associated with the navigation bar in the XML page and then you do the formatting only once on the XSL page.
Our XML/XSL navigation bars offer two advantages. First, they let us separate the data from the layout. With this separation, the pages are easier to design and modify. The second advantage stems from the use of the
Try this approach the next time you build a navigation bar. It's a great way to familiarize yourself with this new technology, and—with a little practice—you could save yourself a lot of time.