<?xml version="1.0" encoding="utf-8"?>
<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="text">
    <text>
      <xsl:apply-templates select="@*"/>
    </text>
  </xsl:template>
  <xsl:template match="styles"/>
  <xsl:template match="attribute[@name='Name']">
    <xsl:choose>
      <xsl:when test="../attribute[@name='IsPrototype']/text() = 'true'">
        <attribute name='Name'><xsl:value-of select="text()"/></attribute>
      </xsl:when>
      <xsl:otherwise>
        <attribute name='Name'>Item <xsl:value-of select="../@ID"/></attribute>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
   <xsl:template match="*|text()|@*">
     <xsl:copy>
       <xsl:apply-templates select="@*"/>
       <xsl:apply-templates/> 
     </xsl:copy>
   </xsl:template>
</xsl:stylesheet>
