<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="utf-8" indent="yes" method="xml"/>


<xsl:template match="/">
  <pages>
  <xsl:apply-templates select="//system-page[not(ancestor::system-page)]"/>
  </pages>
</xsl:template>


<xsl:template match="//system-page/*">
<xsl:copy>
  <xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>


<xsl:template match="//system-page[ancestor::system-page]" priority="5">
  <xsl:text></xsl:text>
</xsl:template>

<xsl:template match="//system-page[not(ancestor::system-page)]" priority="10">
  <xsl:copy>
    <xsl:apply-templates select="./*"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="//path">
  <path>
<xsl:text>[system-asset:page]</xsl:text>
  <xsl:value-of select="."/>
<xsl:text>[/system-asset:page]</xsl:text>
  </path>
</xsl:template>

</xsl:stylesheet>

