<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rss="http://purl.org/rss/1.0/"
  xmlns:Atom="http://www.w3.org/2005/Atom" xmlns:atom="http://purl.org/atom/ns#">
<xsl:namespace-alias stylesheet-prefix="rss" result-prefix="#default"/>
<xsl:namespace-alias stylesheet-prefix="rdf" result-prefix="#default"/>
<xsl:namespace-alias stylesheet-prefix="Atom" result-prefix="#default"/>
<xsl:namespace-alias stylesheet-prefix="atom" result-prefix="#default"/>
<xsl:output method="html" version="4.01" standalone="yes" omit-xml-declaration="yes" 
  encoding="utf-8" media-type="text/html" indent="no"/>
<xsl:param name="subtitle" select="''" />

<xsl:template match="rss|rdf:RDF">
  <xsl:apply-templates select="channel|rss:channel" />
</xsl:template>

<xsl:template match="channel">
  <div class="card">
    <div class="card-control">
      <a title="move this card up" href="cfg.asp?cmd=up&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;uarr;</xsl:text>
      </a>
      <a title="move this card down" href="cfg.asp?cmd=down&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;darr;</xsl:text>
      </a>
      <a title="remove this card" href="cfg.asp?cmd=del&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;times;</xsl:text>
      </a>
    </div>
    <h2><a href="{link}" title="{normalize-space(description)}">
      <xsl:value-of select="title" />
      <xsl:if test="title='Meerkat: An Open Wire Service'"> (<xsl:value-of select="$subtitle" />)</xsl:if>
    </a></h2>
    <xsl:choose>
    	<xsl:when test="//item"><ul><xsl:apply-templates select="//item" /></ul></xsl:when>
    	<xsl:otherwise><div class="card-notice">(no items)</div></xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates select="textInput" />
  </div>
</xsl:template>

<xsl:template match="rss:channel">
  <div class="card">
    <div class="card-control">
      <a title="move this card up" href="cfg.asp?cmd=up&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;uarr;</xsl:text>
      </a>
      <a title="move this card down" href="cfg.asp?cmd=down&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;darr;</xsl:text>
      </a>
      <a title="remove this card" href="cfg.asp?cmd=del&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;times;</xsl:text>
      </a>
    </div>
    <h2><a href="{rss:link}" title="{normalize-space(rss:description)}">
      <xsl:value-of select="rss:title" />
      <xsl:if test="title='Meerkat: An Open Wire Service'"> (<xsl:value-of select="$subtitle" />)</xsl:if>
    </a></h2>
    <xsl:choose>
    	<xsl:when test="//rss:item"><ul><xsl:apply-templates select="//rss:item" /></ul></xsl:when>
    	<xsl:otherwise><div class="card-notice">(no items)</div></xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates select="rss:textInput" />
  </div>
</xsl:template>

<xsl:template match="Atom:feed">
  <div class="card">
    <div class="card-control">
      <a title="move this card up" href="cfg.asp?cmd=up&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;uarr;</xsl:text>
      </a>
      <a title="move this card down" href="cfg.asp?cmd=down&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;darr;</xsl:text>
      </a>
      <a title="remove this card" href="cfg.asp?cmd=del&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;times;</xsl:text>
      </a>
    </div>
    <h2><a href="{Atom:link[@rel='alternate']/@href}" title="{normalize-space(Atom:tagline//text())}">
      <xsl:value-of select="Atom:title" disable-output-escaping="yes" />
    </a></h2>
    <xsl:choose>
    	<xsl:when test="Atom:entry"><ul><xsl:apply-templates select="Atom:entry" /></ul></xsl:when>
    	<xsl:otherwise><div class="card-notice">(no items)</div></xsl:otherwise>
    </xsl:choose>
  </div>
</xsl:template>

<xsl:template match="atom:feed">
  <div class="card">
    <div class="card-control">
      <a title="move this card up" href="cfg.asp?cmd=up&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;uarr;</xsl:text>
      </a>
      <a title="move this card down" href="cfg.asp?cmd=down&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;darr;</xsl:text>
      </a>
      <a title="remove this card" href="cfg.asp?cmd=del&amp;col=$col&amp;row=$row">
        <xsl:text disable-output-escaping="yes">&amp;times;</xsl:text>
      </a>
    </div>
    <h2><a href="{atom:link[@rel='alternate']/@href}" title="{normalize-space(atom:tagline//text())}">
      <xsl:value-of select="atom:title" disable-output-escaping="yes" />
    </a></h2>
    <xsl:choose>
    	<xsl:when test="atom:entry"><ul><xsl:apply-templates select="atom:entry" /></ul></xsl:when>
    	<xsl:otherwise><div class="card-notice">(no items)</div></xsl:otherwise>
    </xsl:choose>
  </div>
</xsl:template>

<xsl:template match="item">
	<li><a href="{link}"><xsl:value-of select="title" /></a>
    <div><xsl:value-of select="description" disable-output-escaping="yes" /></div></li>
</xsl:template>

<xsl:template match="rss:item">
	<li><a href="{rss:link}"><xsl:value-of select="rss:title" /></a>
    <div><xsl:value-of select="rss:description" disable-output-escaping="yes" /></div></li>
</xsl:template>

<xsl:template match="Atom:entry[Atom:content/@type='html' or Atom:content/@type='xhtml']">
	<li><a href="{Atom:link[@rel='alternate']/@href}"><xsl:value-of select="Atom:title" disable-output-escaping="yes" /></a>
    <div><xsl:value-of select="Atom:content" disable-output-escaping="yes"/></div></li>
</xsl:template>

<xsl:template match="Atom:entry">
	<li><a href="{Atom:link[@rel='alternate']/@href}"><xsl:value-of select="Atom:title" disable-output-escaping="yes" /></a>
    <div><xsl:copy-of select="Atom:content/node()"/></div></li>
</xsl:template>

<xsl:template match="atom:entry[atom:content/@mode='escaped']">
	<li><a href="{atom:link[@rel='alternate']/@href}"><xsl:value-of select="atom:title" disable-output-escaping="yes" /></a>
    <div><xsl:value-of select="atom:content" disable-output-escaping="yes"/></div></li>
</xsl:template>

<xsl:template match="atom:entry">
	<li><a href="{atom:link[@rel='alternate']/@href}"><xsl:value-of select="atom:title" disable-output-escaping="yes" /></a>
    <div><xsl:copy-of select="atom:content/node()"/></div></li>
</xsl:template>

<xsl:template match="textInput">
  <form method="get" action="{link}" class="textInput">
    <h3><xsl:value-of select="title" /></h3>
    <div align="center">
      <input type="text" name="{name}" size="16" />
      <input type="submit" value="OK" />
    </div>
    <p><xsl:value-of select="description" /></p>
  </form>
</xsl:template>

<xsl:template match="rss:textInput">
  <form method="get" action="{rss:link}" class="textInput">
    <h3><xsl:value-of select="rss:title" /></h3>
    <div align="center">
      <input type="text" name="{rss:name}" size="16" />
      <input type="submit" value="OK" />
    </div>
    <p><xsl:value-of select="rss:description" /></p>
  </form>
</xsl:template>

</xsl:stylesheet>
