<?xml version="1.0" encoding="ISO-8859-1" ?> 

<!--
  -  XSL stylesheet used to transform a component's toc.xml file into a
  -  "main" toc.xml.  Usually, multiple toc.xml files from multiple components
  -  are merged into a toc-master.xml file to produce a complete table
  -  of contents. But some components want to be able to both serve as
  -  as a component in a merged TOC *and* be able to produce a standalone
  -  doc set.
  -
  -  The component toc.xml file should be set up as though is were going to
  -  be merged.  I.e. it should contain <toc-reference> elements that in turn
  -  contain hierarchies of <toc-node> elements. This style sheet is used for
  -  the standalone doc set case.  It removes the <toc-reference> elements
  -  and promotes all top-level <toc-node> elements to be direct children
  -  of the <toc-root>. Otherwise the final TOC would contain books (often
  -  a single book) for the entire component, which isn't very welcoming
  -  when a user opens the doc set.
  -->

<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:toc="http://www.bea.com/help/toc.xsd"
      xmlns="http://www.bea.com/help/toc.xsd">

  <xsl:template match="/">
<xsl:apply-templates />
  </xsl:template>

  <xsl:template match="/toc:toc-root">
<xsl:copy use-attribute-sets="root-attributes">
<xsl:apply-templates />
</xsl:copy>
  </xsl:template>

  <xsl:template match="/toc:toc-root/toc:toc-reference/toc:toc-node">
<xsl:copy-of select="." />
  </xsl:template>
  
  <xsl:attribute-set name="root-attributes">
    <xsl:attribute name="component">
      <xsl:value-of select="@component"/>
    </xsl:attribute>
  </xsl:attribute-set>

</xsl:stylesheet>
