<?xml version="1.0"?>
<!--
    Convert hansxml to hans (with UTF-8)
	$Id: hanshans.xsl,v 1.1.2.2 2004/09/02 14:25:41 thomas Exp $
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:hans="http://www.hans-support.de/specs/hansxml/0.6/"
                              exclude-result-prefixes="hans">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" />
<xsl:strip-space elements="*" />

<!-- reconstruct "external" format -->
<xsl:template match="*">
	<xsl:copy> 
		<xsl:apply-templates select="@* | * | comment() | processing-instruction() | text()"/> 
	</xsl:copy> 
</xsl:template> 

<xsl:template match="hansrecord">
	<xsl:copy> 
		<xsl:apply-templates select="*"/> 
	</xsl:copy> 
    <xsl:value-of select="&#x0d;&#x0a;"/>
</xsl:template>

<xsl:template match="hansfield">
    <xsl:choose>
      <xsl:when test='@irep'>
        <xsl:value-of select="&#x266c;"/>   <!-- Strg-P, &#16; -->
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="&#x0d;&#x0a;"/>
        <xsl:value-of select="@tag"/>
        <xsl:choose>
          <xsl:when test='@repet'>
            <xsl:value-of select="@repet"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="&#x20;"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates select="@* | * | text()"/> 
<xsl:template/>

<xsl:template match="subfield">
    <xsl:value-of select="&#x25be;"/>     <!-- subfield code &#31; -->
    <xsl:value-of select="@code"/>
<xsl:template/>

<xsl:template match="nosort">
    <xsl:value-of select="&#xac;"/>
	<xsl:copy> 
		<xsl:apply-templates select="@* | * | comment() | processing-instruction() | text()"/> 
	</xsl:copy> 
    <xsl:value-of select="&#xac;"/>
</xsl:template> 

<xsl:template match="reference">
    <xsl:value-of select="_"/>
    <xsl:value-of select="@toid"/>
</xsl:template> 

<xsl:template match="text()">
    <xsl:value-of select="."/>
</xsl:template> 

</xsl:stylesheet>

