<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes"/>
	
<xsl:template match="report">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='reportValue')]|node()"/>	
		<xsl:if test="@reportValue">
			<xsl:value-of select="@reportValue"/>					
		</xsl:if>
	</xsl:copy>
</xsl:template>
		
<xsl:template match="ct">
	<xsl:copy>
		<xsl:attribute name="ts">
			<xsl:for-each select="tm">			
				<!--xsl:text>t</xsl:text--><xsl:value-of select="@idref"/><xsl:text> </xsl:text>
			</xsl:for-each>		
		</xsl:attribute>
		<xsl:if test="@id">
			<xsl:attribute name="id">
				<xsl:text>c</xsl:text><xsl:value-of select="@id"/>
			</xsl:attribute>							
		</xsl:if>		
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='tm')]"/>	
	</xsl:copy>
</xsl:template>	

<xsl:template match="cv">
	<xsl:copy>
		<xsl:attribute name="cs">
			<xsl:for-each select="ct">			
				<xsl:text>c</xsl:text><xsl:value-of select="@idref"/><xsl:text> </xsl:text>
			</xsl:for-each>		
		</xsl:attribute>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='ct')]"/>	
	</xsl:copy>
</xsl:template>	

<xsl:template match="catv">
	<xsl:copy>
		<xsl:attribute name="cats">
			<xsl:for-each select="category">			
				<xsl:text>cat</xsl:text><xsl:value-of select="@idref"/><xsl:text> </xsl:text>
			</xsl:for-each>		
		</xsl:attribute>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='category')]"/>	
	</xsl:copy>
</xsl:template>	

<xsl:template match="tv">
	<xsl:copy>
		<xsl:if test="tm">
		<xsl:attribute name="ts">
			<xsl:for-each select="tm">			
				<!--xsl:text>t</xsl:text--><xsl:value-of select="@idref"/><xsl:text> </xsl:text>
			</xsl:for-each>		
		</xsl:attribute>			
		</xsl:if>
		<xsl:if test="@id">
			<xsl:attribute name="id">
				<xsl:text>tv</xsl:text><xsl:value-of select="@id"/>
			</xsl:attribute>							
		</xsl:if>				
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='tm')]"/>	
	</xsl:copy>
</xsl:template>	
			
<xsl:template match="defGroup">
	<xsl:copy>
		<xsl:if test="type">
		<xsl:attribute name="types">
			<xsl:for-each select="type">			
				<!--xsl:text>y</xsl:text--><xsl:value-of select="@idref"/><xsl:text> </xsl:text>
			</xsl:for-each>		
		</xsl:attribute>			
		</xsl:if>
		<xsl:apply-templates select="@*|node()[not(name()='type')]"/>	
	</xsl:copy>	
</xsl:template>	
	
<xsl:template match="lexGroup">
	<xsl:copy>
		<xsl:if test="type">
			<xsl:attribute name="type">
				<!--xsl:text>y</xsl:text--><xsl:value-of select="type/@idref"/>
			</xsl:attribute>							
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='type')]"/>
	</xsl:copy>
</xsl:template>	

<xsl:template match="r">
	<xsl:copy>
		<xsl:if test="tv">
			<xsl:attribute name="tv">
				<xsl:text>tv</xsl:text><xsl:value-of select="tv/@idref"/>
			</xsl:attribute>							
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='tv')]"/>		
	</xsl:copy>
</xsl:template>
		
<xsl:template match="tm">
	<xsl:copy>
		<xsl:if test="l">
			<xsl:attribute name="l">
				<!--xsl:text>t</xsl:text--><xsl:value-of select="l/@idref"/>
			</xsl:attribute>							
		</xsl:if>
		<xsl:if test="@id">
			<xsl:attribute name="id">
				<!--xsl:text>t</xsl:text--><xsl:value-of select="@id"/>
			</xsl:attribute>							
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id') and not(name()='serverId') and not(name()='serverIdref')]|node()[not(name()='l')]"/>
	</xsl:copy>
</xsl:template>	

<xsl:template match="c">
	<xsl:copy>
		<xsl:if test="ct">
			<xsl:attribute name="c">
				<xsl:text>c</xsl:text><xsl:value-of select="ct/@idref"/>
			</xsl:attribute>							
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='ct')]"/>
	</xsl:copy>
</xsl:template>	
	
<xsl:template match="t">
	<xsl:copy>
		<xsl:if test="tm">
			<xsl:attribute name="t">
				<!--xsl:text>t</xsl:text--><xsl:value-of select="tm/@idref"/>
			</xsl:attribute>							
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='tm')]"/>
	</xsl:copy>
</xsl:template>	
		
<xsl:template match="cd">
	<xsl:copy>
		<xsl:if test="c">
			<xsl:attribute name="c">
				<xsl:text>c</xsl:text><xsl:value-of select="c/@idref"/>
			</xsl:attribute>						
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='c')]"/>	
	</xsl:copy>
</xsl:template>			

<xsl:template match="yd">
	<xsl:copy>
		<xsl:if test="y">
			<xsl:attribute name="y">
				<!--xsl:text>y</xsl:text--><xsl:value-of select="y/@idref"/>
			</xsl:attribute>						
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='y')]"/>	
	</xsl:copy>
</xsl:template>			

<xsl:template match="td">
	<xsl:copy>
		<xsl:if test="t">
			<xsl:attribute name="t">
				<!--xsl:text>t</xsl:text--><xsl:value-of select="t/@idref"/>
			</xsl:attribute>						
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='t')]"/>	
	</xsl:copy>
</xsl:template>			
		
<xsl:template match="type">
	<xsl:copy>
		<xsl:if test="@id">
			<xsl:attribute name="id">
				<!--xsl:text>y</xsl:text--><xsl:value-of select="@id"/>
			</xsl:attribute>					
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id') and not(name()='serverId') and not(name()='serverIdref')]|node()"/>			
	</xsl:copy>
</xsl:template>

<xsl:template match="category">
	<xsl:copy>
		<xsl:if test="@id">
			<xsl:attribute name="id">
				<xsl:text>cat</xsl:text><xsl:value-of select="@id"/>
			</xsl:attribute>					
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>

<xsl:template match="cluster">
	<xsl:copy>
		<xsl:if test="@id">
			<xsl:attribute name="id">
				<xsl:text>clr</xsl:text><xsl:value-of select="@id"/>
			</xsl:attribute>					
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>
							
<xsl:template match="@*|*">
  <xsl:copy>
    <!--xsl:apply-templates select="@*|node()"/-->
    <xsl:apply-templates select="@*"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="spssml">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	
	
<xsl:template match="types">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="textModel">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="descriptors">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="textService">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="parameters">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="report">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="val">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="param">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="doc">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="view">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="file">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="index">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="seg">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="defGroup">
	<xsl:copy>
		<xsl:if test="type">
		<xsl:attribute name="types">
			<xsl:for-each select="type">			
				<!--xsl:text>y</xsl:text--><xsl:value-of select="@idref"/><xsl:text> </xsl:text>
			</xsl:for-each>		
		</xsl:attribute>			
		</xsl:if>
		<xsl:apply-templates select="@*[not(name()='id')]|node()[not(name()='type')]"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="def">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="textScore">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	

<xsl:template match="match">
	<xsl:copy>
		<xsl:apply-templates select="@*[not(name()='id')]|node()"/>			
	</xsl:copy>
</xsl:template>	
																									
</xsl:stylesheet>