<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
	<html>
		<head>		
			<link href="style.css" rel="stylesheet" type="text/css" />
		</head>
		<body>
			<xsl:apply-templates />
		</body>
	</html>
</xsl:template>

<!-- The <article> tag -->
<xsl:template match="article">
	<div class="article-container">
		<!-- Show a standard header -->
		<div class="article-header">
			Here is the article header.
		</div>
		
		<!-- Apply templates to article content -->
		<xsl:apply-templates />
		
		<!-- Show a standard footer -->
		<div class="footer">
			Here is the page footer.
		</div>		
	</div>
</xsl:template>

<!-- The <section> tag -->
<xsl:template match="section">

	<div class="section">

		<xsl:choose>
			<!-- Use title=, if given -->
			<xsl:when test="string-length(@title)">
				<div class="section-title"><xsl:value-of select="@title"/></div>
			</xsl:when>
			<xsl:otherwise>
				<!-- If no title, make empty title so I still get the border -->
				<div class="section-title"></div>
			</xsl:otherwise>
		</xsl:choose>
		
		<xsl:apply-templates />
	</div>
	
</xsl:template>

<!-- <text> container -->
<xsl:template match="text">
	<div class="text">
		<xsl:apply-templates />
	</div>
</xsl:template>

<!-- <code> container -->
<xsl:template match="code">

	<!-- Put title+content in a parent container -->
	<div class="code-container">
		<!-- Add title, if user provided one -->
		<xsl:if test="string-length(@title)">
			<div class="code-title">
				<xsl:value-of select="@title" />
			</div>
		</xsl:if>	   

		<!-- Include code as preformatted block -->
		<div class="code-content">
			<!-- ugh - substring() hack is to remove leading \n at start
				of code block. Without this hack, it looks okay when
				run through xsltproc, but has a gap when viewing the XML
				directly in Firefox.
			-->
			<pre><xsl:value-of select="substring(.,2)" /></pre></div>		
			
	</div>
</xsl:template>

<!-- <c>, for inline code samples -->
<xsl:template match="c">
	<span class="inline-code">
		<xsl:value-of select="." />
	</span>
</xsl:template>

<!-- Pass along the <p>, <i>, <b>, and <tt> tags -->
<xsl:template match="p|i|b|tt">
	<xsl:copy>
		<xsl:apply-templates />
	</xsl:copy>
</xsl:template>

</xsl:stylesheet>



