Author: Steven Neiland

Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

Step 3: Insert Site Formatting

So far we have covered how to parse our xml sitemap using xsl. However we still want to make the sitemap's appearance consistent with out website.

To do this we could take our layout html and insert it inside our xsl:template tags but around our xsl for-each code like thus.

<xsl:stylesheet version="2.0"xmlns:html=""xmlns:sitemap=""xmlns:xsl="">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<title>My Sitemap</title>
<div id="wrapper">
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>

<table cellpadding="5">
<tr style="border-bottom:1px black solid;">
       <th>Change Frequency</th>
<xsl:for-each select="sitemap:urlset/sitemap:url">


While this would work its not really a great solution. This approach basically means you have to maintain two identical templates for the same site.

Fortunately we can leverage the technique I outlined for building a dynamic sitemap the same way here to dynamically build our XSL file.

1 2 3 4 5 6 7

What Do You Think?

Reader Comments

Post a Comment

Comment Etiquette:

  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain or appear to be advertisments, will not be published.
  • Comments that appear to be created for the purpose of linkbuilding to commercial sites will be removed.

We are all adults here so play nice.


Archives Blog Listing

Tag Listing

Learn CF In A Week


Fork me on GitHub