Author: Steven Neiland
Published:

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.

XSL Breakdown

As there is so much going on in the previous code I have broken it down by the key components. I have done this by working inwards by tag pair.

XSL Declaration & Stylesheet Wrapper

The first components of our xsl sheet are the xsl version namespace declarations and the desired output format of html using utf-8 encoding.

<xsl:stylesheet version="2.0"xmlns:html="http://www.w3.org/TR/REC-html40"xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
--snip--

--snip--
</xsl:stylesheet>

Template Wrapper

Inside the stylesheet wrapper we have a template wrapper

<xsl:template match="/">
--snip--

--snip--
</xsl:template>

Variable Declarations

Inside the template wrapper are two variable declarations. These variables named upper and lower will be used further down the code.

    <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>

Standard HTML

You will notice that there is standard html mixed in with the xsl code. This is no different to the way you have standard code mixed in with cfml.

For-Each Loop

This is where we start to see the power of xsl. This statement selects the urlset wrapper from our sitemap and loops through each url node in it.

   <xsl:for-each select="sitemap:urlset/sitemap:url">
--snip--

--snip--
</xsl:for-each>
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

Treehouse

 
Fork me on GitHub