<!-- Convert homepage.xsl to individual webpages.  -->
<!-- run as xsltproc [2 hyphens]xinclude noprobcss.xsl homepage.xml -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:exsl="http://exslt.org/common"
		xmlns:h="http://www.w3.org/1999/xhtml"
		extension-element-prefixes="exsl"
		xmlns:a="http://www.w3.org/2005/Atom"
		exclude-result-prefixes="a h"
		version="1.0">

  <xsl:strip-space elements="*"/>

  <!-- IE needs DOCTYPE decl for CSS to work correctly.  -->
  <xsl:output />

  <xsl:template match="pages">
    <!-- title and footer grabbed as needed -->
    <xsl:apply-templates select="page"/>
  </xsl:template>

  <xsl:template match="page">
    <!-- omit adnd decls because of IE -->
    <exsl:document href="/usr/www/users/bobd/bob/{@filename}" indent="yes"
		   omit-xml-declaration="yes"
		   doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
		   doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <xsl:variable name="thisPgFilename" select="@filename"/>

      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

	<head>
	  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
	  <meta name="author" content="Bob DuCharme" />
          <meta name="description" content="Bob DuCharme's home page."/>


	  <link rel="stylesheet" type="text/css" href="noprobmod.css" media="screen"/> 

	  <xsl:if test="@filename='index.html'">
                <link rel="meta" type="application/rdf+xml" title="FOAF"
                href="http://semantictweet.com/bobdc" />
	  </xsl:if>
	  <title><xsl:value-of select="/pages/title"/>: <xsl:value-of select="@title"/></title>
	</head>
	<body>



	  <div id="MainWrapper">
	    <div id="Header"><a href="index.html"><xsl:value-of select="/pages/title"/></a></div>

	    <div id="HeaderMenus">
	      <ul>
		<xsl:for-each select="/pages/page[@getsMenuItem='t']">
		  <xsl:choose>
		    <xsl:when test="@filename = $thisPgFilename">
		      <!-- not a link -->
		      <li><xsl:value-of select="@title"/></li>
		    </xsl:when>
		    <xsl:otherwise>
		      <li>
			<a href="{@filename}">
			  <xsl:value-of select="@title"/>
			</a>
		      </li>
		    </xsl:otherwise>
		  </xsl:choose>
		</xsl:for-each>
	      </ul>
	    </div>


	    <xsl:apply-templates select="h:div[@class='side']"/>
	    <xsl:apply-templates select="h:div[@class='main']"/>
	    <xsl:apply-templates select="/pages/h:div[@class='footer']"/>

	  </div>

	</body>
      </html>
    </exsl:document>
  </xsl:template>


  <xsl:template match="h:div[@class='side']">
    <div id="SideContents" xmlns="http://www.w3.org/1999/xhtml">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template match="h:div[@class='main']">
    <div id="MainContent" xmlns="http://www.w3.org/1999/xhtml">
      <xsl:apply-templates/>
    </div>
  </xsl:template>

  <xsl:template match="h:div[@class='footer']">
    <div id="Footer" xmlns="http://www.w3.org/1999/xhtml">
      <xsl:apply-templates/>
    </div>
  </xsl:template>


  <xsl:template match="h:*|a:*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:param name="maxEntries">5</xsl:param>

  <xsl:template match="a:feed">
    <xsl:apply-templates select="a:entry[position() &lt;= $maxEntries]"/>
  </xsl:template>

  <xsl:template match="a:entry">
    <p xmlns="http://www.w3.org/1999/xhtml" ><a href="{a:link/@href}"><xsl:value-of select="a:title"/></a>
    (<xsl:value-of select="substring(a:updated,1,10)"/>) 
    <!-- Don't bother with summary while summary/@type = 'html' (escaped ) -->
    <xsl:value-of select="a:summary"/>

    </p>
  </xsl:template>

  <xsl:template match="a:feed//text()"/>


  <xsl:template match="h:atSign">
    <!-- A hack to ensure that &#64; shows up in HTML version of email address and not  @ -->
    <xsl:text disable-output-escaping="yes">&amp;#64;</xsl:text>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="*">
    <xsl:message>WARNING: missed element <xsl:value-of select="name(.)"/>
    </xsl:message>
  </xsl:template>


  <xsl:template match="comment()">
    <!-- JavaScript for Google ads are inside of comments that we 
         want to copy -->
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
