OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: RE: [docbook-apps] JavaHelp index


|  -----Original Message-----
|  From: Laitinen Joni 
|  
|  I'm trying to generate a JavaHelp index from my DocBook 
|  document, but I'm having trouble creating a tree-like 
|  hierarchy of the indexterms. I'd like the index to be like:
|  
|  -Term1
|   --Term2
|   --Term3
|  +Term4
|  
|  With Terms2 and 3 nested inside Term1. So far I've only 
|  managed to make a plain list of the terms without hierarchy. 


Currently, the stock javahelp.xsl stylesheet only outputs a plain, flat
index.

Below is an attempt at generating an index with nested secondary/tertiary
items. The code is intended as a replacement for the template with
match="indexterm" and mode="idx" in javahelp.xsl. Maybe you'll find it
useful.

By the way, my impression is that interest in JavaHelp is waning. Nothing
much seems to happen with the technology and discussion forum activity is
low. But perhaps you have another opinion?

Mauritz


----------
<xsl:key name="prim" match="primary[following-sibling::secondary]"
use="normalize-space(.)"/>
<xsl:key name="second" match="secondary[following-sibling::tertiary]"
use="normalize-space(.)"/>

<xsl:template match="indexterm" mode="idx">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="see">
      <indexitem text="{normalize-space(primary)}, see
'{normalize-space(see)}'"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates select="primary" mode="idx"/>
    </xsl:otherwise>
  </xsl:choose>
  
</xsl:template>

<xsl:template match="primary" mode="idx">
  <xsl:variable name="id">
    <xsl:call-template name="object.id">
      <xsl:with-param name="object" select="ancestor::indexterm"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:if test="not(following-sibling::secondary)">
    <indexitem text="{normalize-space(.)}" target="{$id}" expand="true">
      <xsl:apply-templates select="following-sibling::seealso" mode="idx"/>
    </indexitem>
  </xsl:if>

   <xsl:for-each select="self::node()[generate-id() =
generate-id(key('prim', normalize-space(.))[1])]">
    <indexitem text="{normalize-space(.)}" target="{$id}" expand="true">
      <xsl:for-each select="key('prim', normalize-space(.))">
	  <xsl:apply-templates select="following-sibling::secondary"
mode="idx">
	</xsl:apply-templates>
      </xsl:for-each>
    </indexitem>
  </xsl:for-each>  
  
</xsl:template>

<xsl:template match="secondary" mode="idx">
  <xsl:variable name="id">
    <xsl:call-template name="object.id">
      <xsl:with-param name="object" select="ancestor::indexterm"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:if test="not(following-sibling::tertiary)">
    <indexitem text="{normalize-space(.)}" target="{$id}" expand="true">
      <xsl:apply-templates select="following-sibling::seealso" mode="idx"/>
    </indexitem>
  </xsl:if>

  <xsl:for-each select="self::node()[generate-id() =
generate-id(key('second', normalize-space(.))[1])]">
    <indexitem text="{normalize-space(.)}" target="{$id}" expand="true">
      <xsl:for-each select="key('second', normalize-space(.))">
        <xsl:apply-templates select="following-sibling::tertiary"
mode="idx">
	</xsl:apply-templates>
      </xsl:for-each>
    </indexitem>
  </xsl:for-each>
    
</xsl:template>

<xsl:template match="tertiary" mode="idx">
  <xsl:variable name="id">
    <xsl:call-template name="object.id">
      <xsl:with-param name="object" select="ancestor::indexterm"/>
    </xsl:call-template>
  </xsl:variable>

  <indexitem text="{normalize-space(.)}" target="{$id}">
    <xsl:apply-templates select="following-sibling::seealso" mode="idx"/>
  </indexitem>
</xsl:template>

<xsl:template match="seealso" mode="idx">
  <indexitem text="See also '{normalize-space(.)}'"/>
</xsl:template>
----------






[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]