<!-- 
XSL stylesheet to format TEI XML documents to HTML

Many basic ideas and many details taken from the stylesheets
written by Sebastian Rahtz. I gratefully reproduce his copyright statement:

 Copyright 1999 Sebastian Rahtz/Oxford University  <sebastian.rahtz@oucs.ox.ac.uk>

 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and any associated documentation files (the
 ``Software''), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
--> 
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  version="1.0">

<xsl:template match='figure'>
	<xsl:element name="img">
		<xsl:attribute name="src">
			<xsl:call-template name="filename">
				<xsl:with-param name="x" select="unparsed-entity-uri(@entity)"/>
			</xsl:call-template>
		</xsl:attribute>
		<xsl:attribute name="align">
			<xsl:value-of select="@rend"/>
		</xsl:attribute>
	</xsl:element>
</xsl:template>

<xsl:template name="filename">
	<xsl:param name="x"/>
	<xsl:choose>
		<xsl:when test="contains($x,'/')">
			<xsl:call-template name="filename">
				<xsl:with-param name="x" select="substring-after($x,'/')"/>
			</xsl:call-template>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$x"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

</xsl:stylesheet>

