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 2: Create the XSL File

We now create the xsl file we specified in our sitemap. To begin with we will create a simple un-styled map which will convert the listed nodes into a list of hyperlinks.

<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="/">
<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">
<xsl:if test="position() mod 2 != 1">
       <xsl:attribute name="class">even</xsl:attribute>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
<a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a>
            <xsl:value-of select="concat(sitemap:priority*100,'%')"/>
            <xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),
             concat($lower, $upper),concat($upper, $lower)),
             substring(sitemap:changefreq, 2))"

            <xsl:value-of select="concat(substring(sitemap:lastmod,0,11),
concat(' ',substring(sitemap:lastmod,12,5)))"


There is alot going on here so lets break it down. If you want to skip the breakdown you can continue onto page 5.

Note: At this stage you should test if the xsl is working by visiting your sitemap. If it is working you should see a table of hyperlinks.

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