<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:eat="http://msqr.us/xsd/ieat"
	xmlns:xweb="http://msqr.us/xsd/jaxb-web"
	exclude-result-prefixes="eat xweb">

    <!-- imports -->
	<xsl:import href="display-recipe.xsl"/>
    <xsl:import href="global.xsl"/>
	
	<xsl:output method="xml" omit-xml-declaration="no" 
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" 
		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/>
    
	<!-- 
		Layout Stylesheet
		
		This stylesheet is not designed to be used directly, rather it should be 
		imported or included into another stylesheet. That stylesheet must define
		the following variables:
		
		layout.global.nav.page: the current global nav page
		
		The layout of this template is as roughly as follows:
		
		+============================================================+
		| PAGE-TITLE                                 PAGE-GLOBAL-NAV |
		| - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  |
		| RETURN-NAV                                    ACTION-LINKS |
		|                                             ACTION-LINKS-2 |
		| PAGE-BODY                                                  |
		|                                                            |
		| PAGE-FOOTER                                                |
		+============================================================+
		
		Thus implementing stylesheets should define templates that match 
		the xweb:x-data element for the mode of the elements outlined 
		above (the modes should be lower-case). This stylesheet does 
		provide defaults for some of these elements, so to override 
		those defaults you must import this stylesheet rather than 
		include it.
	-->
	<xsl:template match="xweb:x-data">
		<xsl:variable name="layout.page.title">
			<xsl:apply-templates select="." mode="page-title"/>
		</xsl:variable>
		<html>
			<head profile="{$web-context}/profile.txt?lang={$ctx/xweb:user-locale}">
				<title><xsl:value-of select="$layout.page.title"/></title>
				<link rel="stylesheet" type="text/css" href="{$web-context}/css/global.css" media="screen,print"/>
				<link rel="stylesheet" type="text/css" href="{$web-context}/css/print.css" media="print"/>
				<xsl:apply-templates select="." mode="page-head-content"/>
			</head>
			<body>
				<xsl:apply-templates select="." mode="page-global-nav"/>
				
				<h1><xsl:value-of select="$layout.page.title"/></h1>
                
                <!-- Only output the edit-banner <div> if some content is generated for it -->
				<xsl:variable name="layout.action.links">
					<xsl:apply-templates select="." mode="action-links"/>
				</xsl:variable>
				<xsl:if test="string($layout.action.links)">
					<div class="edit-banner">
						<xsl:copy-of select="$layout.action.links"/>
					</div>
				</xsl:if>
				
                <!-- Only output the edit-banner-2 <div> if some content is generated for it -->
				<xsl:variable name="layout.action.links.2">
					<xsl:apply-templates select="." mode="action-links-2"/>
				</xsl:variable>
				<xsl:if test="string($layout.action.links.2)">
					<div class="edit-banner-2">
						<xsl:copy-of select="$layout.action.links.2"/>
					</div>
				</xsl:if>
				
				<xsl:call-template name="error-intro">
					<xsl:with-param name="errors-node" select="xweb:x-errors"/>
				</xsl:call-template>

                <xsl:apply-templates select="." mode="page-body"/>
                
                <xsl:apply-templates select="." mode="page-footer"/>
                
			</body>
		</html>
	</xsl:template>

	<!-- Layout Template: page-title
		
		Render the browser page title as well as the main heading. This should 
		return a simple string, without any markup.
	-->
	<xsl:template match="xweb:x-data" mode="page-title">
		<xsl:value-of select="key('i18n','title')"/>
	</xsl:template>
	
	<xsl:template match="xweb:x-data" mode="page-global-nav">
		<xsl:call-template name="global-nav">
			<xsl:with-param name="page" select="$layout.global.nav.page"/>
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template match="xweb:x-data" mode="page-head-content"/>
	
	<xsl:template match="xweb:x-data" mode="action-links"/>
	
	<xsl:template match="xweb:x-data" mode="action-links-2"/>
	
	<xsl:template match="xweb:x-data" mode="page-body"/>
	
	<xsl:template match="xweb:x-data" mode="page-footer"/>

</xsl:stylesheet>