This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [docbook-apps] JavaHelp Index & ENTITIES


-----Original Message-----
> From: Lars Bjerges 
> Sent: den 11 augusti 2004 13:59
> o Since DocBook supports three levels of index it would be 
> nice to have that
>   reflected in JavaHelp (i.e. expand- collaps-able JavaHelp view.

Sorry for the delay in replying. 
I have created some experimental modifications for JavaHelp, including
nested index terms. If you want to test them, add these templates to your
customization layer:

<!-- Added JavaHelp 2.0 "presentation" element -->
<!-- Several presentation features could be parameterized -->
<!-- I haven't removed all references to JavaHelp 1.0, since it works anyway
--> 
<xsl:template name="helpset.content">
  <xsl:variable name="title">
    <xsl:apply-templates select="." mode="title.markup"/>
  </xsl:variable>

  <helpset version="1.0">
    <title>
      <xsl:value-of select="$title"/>
    </title>

    <!-- maps -->
    <maps>
      <homeID>top</homeID>
      <mapref location="jhelpmap.jhm"/>
    </maps>

    <!-- views -->
    <view>
      <name>TOC</name>
      <label>Table Of Contents</label>
      <type>javax.help.TOCView</type>
      <data>jhelptoc.xml</data>
    </view>

    <view>
      <name>Index</name>
      <label>Index</label>
      <type>javax.help.IndexView</type>
      <data>jhelpidx.xml</data>
    </view>

    <view>
      <name>Search</name>
      <label>Search</label>
      <type>javax.help.SearchView</type>
      <data
engine="com.sun.java.help.search.DefaultSearchEngine">JavaHelpSearch</data>
    </view>

    <presentation default="true">
      <name>default</name>
      <size width="600" height="500"/> 
      <location x="100" y="100"/>
      <title><xsl:value-of select="$title"/></title>
      <toolbar>
        <helpaction>javax.help.BackAction</helpaction>
        <helpaction>javax.help.ForwardAction</helpaction>
        <helpaction>javax.help.HomeAction</helpaction>
      </toolbar>
    </presentation>

  </helpset>
</xsl:template>

<!-- Sorted primary indexterms -->
<xsl:template name="helpidx.content">
  <index version="1.0">
    <xsl:choose>
      <xsl:when test="$rootid != ''">
        <xsl:apply-templates select="key('id',$rootid)//indexterm"
mode="idx"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="//indexterm" mode="idx">
          <xsl:sort select="primary"/>
        </xsl:apply-templates>
      </xsl:otherwise>
    </xsl:choose>
  </index>
</xsl:template>

<!-- Nested secondary and tertiary index terms -->
<!-- Use normalize-space() to work around problems with linebreaks 
     that make JavaHelp choke --> 
<!-- JavaHelp 2.0 "expand" attribute added -->
<!-- Assume that "see" always appears with "primary" -->

<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="{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:variable>
  
  <indexitem text="{normalize-space(.)}" target="{$id}" expand="false">
    <xsl:apply-templates
select="following-sibling::secondary|following-sibling::seealso"
mode="idx"/>
  </indexitem>
</xsl:template>

<xsl:template match="secondary" mode="idx">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>
  
  <indexitem text="{normalize-space(.)}" target="{$id}">
    <xsl:apply-templates select="../tertiary" mode="idx"/>
  </indexitem>
</xsl:template>

<xsl:template match="tertiary" mode="idx">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>
  <indexitem text="{normalize-space(.)}" target="{$id}"/>
</xsl:template>

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

<!-- Normalize space on recursive section titles in TOC file. 
     TBD for other components -->
<xsl:template match="section" mode="jhtoc">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>
  <xsl:variable name="title">
    <xsl:apply-templates select="." mode="title.markup"/>
  </xsl:variable>

  <tocitem target="{$id}">
    <xsl:attribute name="text">
      <xsl:value-of select="normalize-space($title)"/>
    </xsl:attribute>
    <xsl:apply-templates select="section" mode="jhtoc"/>
  </tocitem>
</xsl:template>

<!-- Primary, secondary, tertiary items in map file -->
<xsl:template name="helpmap.content">
  <map version="1.0">
    <xsl:choose>
      <xsl:when test="$rootid != ''">
        <xsl:apply-templates select="key('id',$rootid)//set
                                     | key('id',$rootid)//book
                                     | key('id',$rootid)//part
                                     | key('id',$rootid)//reference
                                     | key('id',$rootid)//preface
                                     | key('id',$rootid)//chapter
                                     | key('id',$rootid)//appendix
                                     | key('id',$rootid)//article
                                     | key('id',$rootid)//colophon
                                     | key('id',$rootid)//refentry
                                     | key('id',$rootid)//section
                                     | key('id',$rootid)//sect1
                                     | key('id',$rootid)//sect2
                                     | key('id',$rootid)//sect3
                                     | key('id',$rootid)//sect4
                                     | key('id',$rootid)//sect5
                                     | key('id',$rootid)//indexterm |
//primary | //secondary | //tertiary"
                             mode="map"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="//set
                                     | //book
                                     | //part
                                     | //reference
                                     | //preface
                                     | //chapter
                                     | //appendix
                                     | //article
                                     | //colophon
                                     | //refentry
                                     | //section
                                     | //sect1
                                     | //sect2
                                     | //sect3
                                     | //sect4
                                     | //sect5
                                     | //indexterm | //primary | //secondary
| //tertiary"
                             mode="map"/>
      </xsl:otherwise>
    </xsl:choose>
  </map>
</xsl:template>

<xsl:template match="indexterm|primary|secondary|tertiary" mode="map">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>

  <mapID target="{$id}">
    <xsl:attribute name="url">
      <xsl:call-template name="href.target.uri"/>
    </xsl:attribute>
  </mapID>
</xsl:template>


> o If an index entry consists of more than one word I have 
> noted that there are a number of
>   blanks inserted somehow inbetween the words (E.g. Wordix1, 
> word2ix2       word2ix2).
>   Does anyone know of a way to get rid of those?

I haven't seen this behaviour and cannot reproduce it. 


> o Another problem I have found is that the generated 
> *.xml-files have entities for "foreign" characters, e.g
>   &aulm;, &aring and so on. Since I am looking at writing a 
> (java) utility to fix collapsible indexes I have
>   had some problem to get a java-parser to read these files 
> since xml does not know these entities by itself.
>   One way to fix this, I think, would be to encode the *.xml 
> files as UTF-8 and have the characters generated
>   as hex instead.  

I am not sure what you mean by "as hex". With character references, you
would have well-formed XML. With UTF-8, you can do without character
references entirely.


/MJ



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]