<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" 
	xmlns		= "http://www.w3.org/1999/xhtml"
	xmlns:h		= "http://www.w3.org/1999/xhtml"
	xmlns:xsl	= "http://www.w3.org/1999/XSL/Transform"
	exclude-result-prefixes="xsl">

<xsl:template name="METADATA">
<!-- meta keywords -->
	<xsl:element name="meta" namespace="http://www.w3.org/1999/xhtml">
		<xsl:attribute name="name"><xsl:text>keywords</xsl:text></xsl:attribute>
		<xsl:attribute name="content">
			<xsl:apply-templates select="/h:html/h:body[@lang=$LANG]//h:*[@id='DC.title'] |
				/h:html/h:body[@lang=$LANG]//h:*[@class='DC.subject']" mode="SUBJECT"/>
		</xsl:attribute>
	</xsl:element>
<!-- viewport for mobile devices -->
	<xsl:element name="meta">
		<xsl:attribute name="name">
			<xsl:text>viewport</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="content">
			<xsl:text>user-scalable=yes, width=device-width, initial-scale=1</xsl:text>
		</xsl:attribute>
	</xsl:element>
<!-- link rel="schema.DC" -->
	<xsl:element name="link" namespace="http://www.w3.org/1999/xhtml">
		<xsl:attribute name="rel">
			<xsl:text>schema.DC</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="href">
			<xsl:text>http://purl.org/dc/elements/1.1/</xsl:text>
		</xsl:attribute>
	</xsl:element>
<!-- link rel="schema.DCTERMS" -->
	<xsl:element name="link" namespace="http://www.w3.org/1999/xhtml">
		<xsl:attribute name="rel">
			<xsl:text>schema.DCTERMS</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="href">
			<xsl:text>http://purl.org/dc/terms/</xsl:text>
		</xsl:attribute>
	</xsl:element>
<!-- GRDDL -->
	<xsl:if test="$DSTTYPE='xhtml'">
		<xsl:element name="link">
			<xsl:attribute name="rel">
				<xsl:text>transformation</xsl:text>
			</xsl:attribute>
			<xsl:attribute name="href">
				<xsl:value-of select="$DIR"/>
				<xsl:text>mex.xsl</xsl:text>
			</xsl:attribute>
			<xsl:attribute name="type">
				<xsl:text>application/xsl+xml</xsl:text>
			</xsl:attribute>
		</xsl:element>
	</xsl:if>
<!-- Microsummary -->
<!--
	<xsl:element name="link" namespace="http://www.w3.org/1999/xhtml">
		<xsl:attribute name="rel"><xsl:text>microsummary</xsl:text></xsl:attribute>
		<xsl:attribute name="href">
			<xsl:text>http://www.rorkvell.de/</xsl:text>
			<xsl:text>news</xsl:text>
			<xsl:text>.txt.</xsl:text>
			<xsl:value-of select="$LANG"/>
		</xsl:attribute>
	</xsl:element>
-->
<!-- meta nema="DC.creator" -->
<!--
	<xsl:element name="meta" namespace="http://www.w3.org/1999/xhtml">
		<xsl:attribute name="name">
			<xsl:text>DC.creator</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="content">
			<xsl:text>Siegfried Gipp</xsl:text>
		</xsl:attribute>
	</xsl:element>
-->
<!-- link rel="DC.creator" -->
<!--
	<xsl:element name="link" namespace="http://www.w3.org/1999/xhtml">
		<xsl:attribute name="rel">
			<xsl:text>DC.creator</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="title">
			<xsl:text>Author</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="href">
			<xsl:value-of select="$DIR"/>
			<xsl:text>impressum.xhtml.</xsl:text>
			<xsl:value-of select="$LANG"/>
		</xsl:attribute>
		<xsl:attribute name="type">
			<xsl:text>application/xhtml+xml</xsl:text>
		</xsl:attribute>
	</xsl:element>
-->
<!-- link rel="license" -->
	<xsl:element name="link">
		<xsl:attribute name="rel">
			<xsl:text>DC.rights</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="title">
			<xsl:text>license</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="href">
			<xsl:text>http://creativecommons.org/licenses/by/3.0/de/</xsl:text>
		</xsl:attribute>
	</xsl:element>
<!--
	<xsl:element name="link" namespace="http://www.w3.org/1999/xhtml">
		<xsl:attribute name="rel"><xsl:text>license</xsl:text></xsl:attribute>
		<xsl:attribute name="href">
			<xsl:text>http://creativecommons.org/licenses/by-sa/3.0/</xsl:text>
		</xsl:attribute>
	</xsl:element>
-->
<!--
	<xsl:element name="link" namespace="http://www.w3.org/1999/xhtml">
		<xsl:attribute name="rel">
			<xsl:text>DC.rights</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="href">
			<xsl:text>http://creativecommons.org/licenses/by-sa/3.0/</xsl:text>
		</xsl:attribute>
	</xsl:element> 
-->
<!--	<xsl:element name="meta">
		<xsl:attribute name="name">
			<xsl:text>DC.title</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="content">
			<xsl:value-of select="/html/head[@lang=$LANG]/title"/>
		</xsl:attribute>
	</xsl:element> -->
<!--	<xsl:element name="meta">
		<xsl:attribute name="name">
			<xsl:text>DC.description</xsl:text>
		</xsl:attribute>
		<xsl:attribute name="content">
			<xsl:value-of select="/html/head[@lang=$LANG]/meta[@name='description']/@content"/>
		</xsl:attribute>
	</xsl:element>-->
</xsl:template>

<xsl:template match="h:img[@class='DC.subject']" mode="SUBJECT">
	<xsl:if test="position()>1">
		<xsl:text>, </xsl:text>
	</xsl:if>
	<xsl:value-of select="normalize-space(@alt)"/>
</xsl:template>


<!--<xsl:template match="h:*[@class='DC.subject']|h:*[@id='DC.title']|h:a[@rel='tag']" mode="SUBJECT">-->
<xsl:template match="h:*[@class='DC.subject']|h:*[@id='DC.title']" mode="SUBJECT">
	<xsl:if test="position()>1">
		<xsl:text>, </xsl:text>
	</xsl:if>
	<xsl:value-of select="."/>
</xsl:template>

<xsl:template match="h:link[@rel='this']" mode="ALT_HEADER">
	<xsl:copy>
		<xsl:attribute name="rel">
			<xsl:text>alternate</xsl:text>
		</xsl:attribute>
		<xsl:apply-templates select="@title|@lang"/>
		<xsl:choose>
			<xsl:when test="../@lang=$LANG">	<!-- alternate format -->
				<xsl:choose>
					<xsl:when test="$DSTTYPE='html'">
						<xsl:attribute name="type">
							<xsl:text>application/xhtml+xml</xsl:text>
						</xsl:attribute>
						<xsl:attribute name="href">
							<xsl:value-of select="@href"/>
							<xsl:text>.xhtml.</xsl:text>
							<xsl:value-of select="$LANG"/>
							<xsl:value-of select="$ENCODING"/>
						</xsl:attribute>
					</xsl:when>
					<xsl:when test="$DSTTYPE='xhtml'">
						<xsl:attribute name="type">
							<xsl:text>text/html</xsl:text>
						</xsl:attribute>
						<xsl:attribute name="href">
							<xsl:value-of select="@href"/>
							<xsl:text>.html.</xsl:text>
							<xsl:value-of select="$LANG"/>
							<xsl:value-of select="$ENCODING"/>
						</xsl:attribute>
					</xsl:when>
				</xsl:choose>
			</xsl:when> <!-- alternate format -->
			<xsl:otherwise>	<!-- alternate language, same format -->
				<xsl:choose>
					<xsl:when test="$DSTTYPE='html'">
						<xsl:attribute name="type">
							<xsl:text>text/html</xsl:text>
						</xsl:attribute>
						<xsl:attribute name="href">
							<xsl:value-of select="@href"/>
							<xsl:text>.html.</xsl:text>
							<xsl:value-of select="../@lang"/>
							<xsl:value-of select="$ENCODING"/>
						</xsl:attribute>
					</xsl:when>
					<xsl:when test="$DSTTYPE='xhtml'">
						<xsl:attribute name="type">
							<xsl:text>application/xhtml+xml</xsl:text>
						</xsl:attribute>
						<xsl:attribute name="href">
							<xsl:value-of select="@href"/>
							<xsl:text>.xhtml.</xsl:text>
							<xsl:value-of select="../@lang"/>
							<xsl:value-of select="$ENCODING"/>
						</xsl:attribute>
						<xsl:attribute name="hreflang">
							<xsl:value-of select="../@lang"/>
						</xsl:attribute>
					</xsl:when>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:copy>
</xsl:template>

<xsl:template match="h:h1" mode="HEAD">
	<xsl:element name="title">
		<xsl:value-of select="."/>
	</xsl:element>
</xsl:template>

</xsl:stylesheet>

