<xsl:stylesheet extension-element-prefixes="saxon" version="1.0">
   <xsl:output method="xml" indent="yes"/>

   <xsl:template match="//book">
     <html>
       <body>
         <h2>
           <xsl:value-of select="title"/>
         </h2>
         <xsl:apply-templates select="//chapter/title" mode="contents"/>
         <xsl:apply-templates select="chapter"/>
       </body>
     </html>
   </xsl:template>

   <xsl:template match="title" mode="contents">
     <xsl:value-of select="position()"/>
     <xsl:text>. </xsl:text>
     <xsl:value-of select="."/>
     <br/>
   </xsl:template>

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

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

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