﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:import href="FeedData.xslt"/>
    <xsl:import href="ChannelFeedData.xslt"/>

    <xsl:output omit-xml-declaration ="yes"/>

    <xsl:template match="/">

        <xsl:variable name="HostName" select="normalize-space(LinkedPublications/HostName)"></xsl:variable>
        <xsl:variable name="TemplateURL" select="normalize-space(LinkedPublications/TemplateURL)"/>
        <xsl:variable name="PromoteKey" select="normalize-space(LinkedPublications/PromoteKey)"/>
        <xsl:variable name="Source" select="normalize-space(LinkedPublications/Source)"/>
        <xsl:variable name="ItemName" select="normalize-space(LinkedPublications/Community)"/>

        <rss version="2.0" 	xmlns:content="http://purl.org/rss/1.0/modules/content/"
             xmlns:wfw="http://wellformedweb.org/CommentAPI/"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
             xmlns:georss="http://www.georss.org/georss"
             xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
             xmlns:media="http://search.yahoo.com/mrss/">

            <channel>
                <xsl:call-template name="ChannelFeedData">
                    <xsl:with-param name="Title">
                        <xsl:choose>
                            <xsl:when test="$Source = 'Community'">
                                LifeSpace <xsl:value-of select="$ItemName"/> Community
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$ItemName"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                    <xsl:with-param name="Link">
                        <xsl:text>http://</xsl:text>
                        <xsl:value-of select="$HostName" />
                        <xsl:text>/</xsl:text>
                        <xsl:value-of select="$PromoteKey" />
                        <xsl:text>/Feed</xsl:text>
                    </xsl:with-param>
                    <xsl:with-param name="Description">
                        <xsl:choose>
                            <xsl:when test="$Source = 'Community'">
                                List of LifeSpace <xsl:value-of select="$ItemName" /> community publications
                            </xsl:when>
                            <xsl:otherwise>
                                List of <xsl:value-of select="$ItemName" /> publications
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                    <xsl:with-param name="ImageUrl">
                        <xsl:text>http://</xsl:text>
                        <xsl:value-of select="$HostName"></xsl:value-of>
                        <xsl:text>/DesktopModules/LifeSpaceTemplates/Web/Images/LifeSpaceLogo.jpg</xsl:text>
                    </xsl:with-param>
                    <xsl:with-param name="ImageLink">
                        <xsl:text>http://</xsl:text>
                        <xsl:value-of select="$HostName"></xsl:value-of>
                        <xsl:text>/Home.aspx</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>

                <xsl:for-each select="LinkedPublications/Publication">
                    <xsl:call-template name="FeedData">
                        <xsl:with-param name="Title" select="Title"></xsl:with-param>
                        <xsl:with-param name="Link">
                            <xsl:text>http://</xsl:text>
                            <xsl:value-of select="$HostName"></xsl:value-of>
                            <xsl:text>/Publication.aspx?ID=</xsl:text>
                            <xsl:value-of select="normalize-space(ItemID)"/>
                        </xsl:with-param>
                        <xsl:with-param name="Description" select="Summary"></xsl:with-param>
                    </xsl:call-template>
                </xsl:for-each>
            </channel>
        </rss>
    </xsl:template>
</xsl:stylesheet>
