<xsl:stylesheet xmlns:its="http://www.w3.org/2005/11/its"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

  <xsl:output method="html" indent="yes" encoding="utf-8"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@its-transval-elem | @*[starts-with(name(),'transval-attr')] | @translate"/>

  <xsl:template match="h:head | head" xmlns:h="http://www.w3.org/1999/xhtml" exclude-result-prefixes="its h">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
    <style xmlns="http://www.w3.org/1999/xhtml">
      <xsl:apply-templates select="/" mode="generateCSSSelectors"/>
    </style>
  </xsl:template>

  <xsl:template mode="generateCSSSelectors" match="*[@its-transval-elem='no']">
    <xsl:apply-templates mode="get-full-path" select="."/>
    <xsl:text> { color: red; }&#xA;</xsl:text>
    <xsl:apply-templates mode="generateCSSSelectors"/>
  </xsl:template>

  <xsl:template match="*|@*" mode="get-full-path">
    <xsl:apply-templates select="parent::*" mode="get-full-path"/>
    <xsl:if test="parent::*">
      <xsl:text disable-output-escaping="yes"> &gt; </xsl:text>
    </xsl:if>
      <xsl:for-each select="preceding-sibling::*">
        <xsl:value-of select="local-name()"/>
	<xsl:if test="parent::* and not(preceding-sibling::*)"><xsl:text>:first-child</xsl:text></xsl:if>
        <xsl:text> + </xsl:text>
      </xsl:for-each>
    <xsl:value-of select="local-name()"/>
  </xsl:template>

  <xsl:template match="text()" mode="generateCSSSelectors"/>
  
</xsl:stylesheet>
