<?xml version="1.0" encoding="UTF-16"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>

	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="text()"/>

	<xsl:template match="*">
		<xsl:if test="descendant-or-self::*[string-length(normalize-space()) and not(*)]">
			<xsl:copy>
				<xsl:choose>
					<xsl:when test="@*[name()='xsi_type']">
					<xsl:for-each select="@*">
						<xsl:variable name="sdc">
							<xsl:choose>
								<xsl:when test="name()='xsi_type'">xsi:type</xsl:when>
								<xsl:otherwise><xsl:value-of select="name()"/></xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
   						<xsl:attribute name="{$sdc}"><xsl:value-of select="."/></xsl:attribute>
					</xsl:for-each>
				</xsl:when>
				<xsl:otherwise>
					<xsl:copy-of select="@*"/>
				</xsl:otherwise>
				</xsl:choose>
				<xsl:if test="not(*)">
					<xsl:value-of select="."/>
				</xsl:if>

				<xsl:if test="descendant::*[string-length(normalize-space()) and not(*)]">
					<xsl:apply-templates/>
				</xsl:if>
			</xsl:copy>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>