﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output omit-xml-declaration ="yes"/>

    <xsl:template match="/">
        <xsl:variable name="HostName" select="normalize-space(BrandSiteMap/HostName)"></xsl:variable>
        <xsl:variable name="TemplateURL" select="normalize-space(BrandSiteMap/TemplateURL)"/>
        <xsl:variable name="BrandKey" select="normalize-space(BrandSiteMap/BrandKey)"/>
        <urlset
     xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
            <url>
                <loc>
                    http://<xsl:value-of select ="$HostName"></xsl:value-of>/
                </loc>
                <changefreq>hourly</changefreq>
                <priority>1.00</priority>
            </url>
            <xsl:for-each select ="BrandSiteMap/Tabs/Tab[TabKey != 'Settings' and TabKey != 'UserSettings']">
                <url>
                    <loc>
                        <xsl:choose>
                            <xsl:when test ="$HostName != 'www.LifeSpace.com' and $HostName != 'www.lifespace.com'">
                                http://<xsl:value-of select ="$HostName"/>/<xsl:value-of select ="TabKey"/>
                            </xsl:when>
                            <xsl:otherwise>
                                http://<xsl:value-of select ="$HostName"/>/<xsl:value-of select ="$BrandKey"/>/<xsl:value-of select ="TabKey"/>        
                            </xsl:otherwise>
                        </xsl:choose>
                    </loc>
                    <changefreq>hourly</changefreq>
                    <priority>1.00</priority>
                </url>
            </xsl:for-each>
            <xsl:for-each select ="BrandSiteMap/Templates/Template">
                <url>
                    <loc>
                        <xsl:text>http://</xsl:text>
                        <xsl:value-of select ="$HostName"/>
                        <xsl:text>/</xsl:text>
                        <xsl:value-of select="PromoteKey"/>
                        <!--<xsl:text>/Template.aspx?ID=</xsl:text>
                        <xsl:value-of select ="TemplateID"/>-->
                    </loc>
                    <changefreq>monthly</changefreq>
                    <priority>0.60</priority>
                </url>
            </xsl:for-each>
            <xsl:for-each select ="BrandSiteMap/Publications/Publication">
                <url>
                    <loc>
                        <xsl:text>http://</xsl:text>
                        <xsl:value-of select ="$HostName"/>
                        <xsl:text>/Publication.aspx?ID=</xsl:text>
                        <xsl:value-of select ="ItemID"/>
                    </loc>
                    <changefreq>monthly</changefreq>
                    <priority>0.65</priority>
                </url>
            </xsl:for-each>
        </urlset>
    </xsl:template>
</xsl:stylesheet>
