<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet SYSTEM "http://commons.omniupdate.com/dtd/standard.dtd">
<xsl:stylesheet version="3.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ou="http://omniupdate.com/XSL/Variables" 
	exclude-result-prefixes="ou"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:media="http://search.yahoo.com/mrss/"
    xpath-default-namespace="http://www.w3.org/1999/xhtml">

<!--

 This XSL structure can be used to create a subset rss feed based on page properties
 
 I would use it as an alternate publish on a news inedx/archive page.


-->

<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="no"  />

<!-- Initialize OU Variables -->
<xsl:param name="ou:action" />
<xsl:param name="ou:path" />
<xsl:param name="ou:filename" /> 
<xsl:param name="ou:dirname" />
<xsl:param name="ou:site" />
<xsl:param name="ou:title" />
<xsl:param name="ou:modified" />
<!--
   RECURSIVE COPY TEMPLATE
-->
<xsl:template match="attribute() | node() | comment() | text() | processing-instruction()" mode="copy">
	<xsl:if test="not(node())">
  		<xsl:copy>
        	<xsl:apply-templates select="attribute() | node() | comment() | text() | processing-instruction()" mode="copy"/>
 		 </xsl:copy>
	</xsl:if>
	<xsl:if test="node()">
 		<xsl:element name="{local-name()}">
    		 <xsl:apply-templates select="attribute() | node() | comment() | text() | processing-instruction()" mode="copy"/>
 		</xsl:element>
	</xsl:if>
</xsl:template>
<!--
     CATCH MEDIA ELEMENTS
-->
 <xsl:template match="media:*" mode="copy">
   <xsl:copy>
        <xsl:apply-templates select="attribute() | node() | comment() | text() | processing-instruction()" mode="copy"/>
   </xsl:copy>
 </xsl:template>

 <xsl:template match="/">
 <!-- 
      GET PCF PARAMS - year, department, feed
 -->
        <xsl:variable name="year" select="document/config/parameter[@name='year']"/>
        <xsl:variable name="department" select="document/config/parameter[@name='department']"/>
        <xsl:variable name="newsfeed" select="document/config/parameter[@name='newsfeed']"/>
<!-- 
 
      START Of OUTPUT
-->
        <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
            <channel>
                <title> NEWS ARCHIVE - <xsl:value-of select="$year"/> - <xsl:value-of select="$department"/></title>
                <link>http:/www.domain.edu</link>
                <description>RSS  archive feed of News in the year <xsl:value-of select="$year"/> and the <xsl:value-of select="$department"/> department</description>
                <language>en-us</language>
                <lastBuildDate><xsl:value-of select="$ou:modified"/></lastBuildDate>
                <docs>http://blogs.law.harvard.edu/tech/rss</docs>
                <generator>OmniUpdate (OU Publish)</generator>       
<!-- 
     APPLY TEMPLATES ON ITEMS FROM $newsfeed PARAM, 
     $year and $department used in XPATH to filter items
-->       
                  <xsl:apply-templates select="document(concat('http://www.spsu.edu',$newsfeed))/*:rss/*:channel/*:item[contains(./*:pubDate,$year) and contains(./*:department,$department)]" mode="copy"/>
                            
            </channel>
            
        </rss>
        
    </xsl:template>


</xsl:stylesheet>
