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: Request for help with XSL: how to produce unique numbers for all id's

I'm customizing htmlhelp-common.xsl to generate context.h header file for 
HTML Help. 

By default, the stylesheet generates a #define entry for each <?dbhh>
processing instruction. I want to modify it so that we create a #define 
entry for each element that has its @id attribute value set. 

I want to assign unique (and sequential, if possible) number to each 
unless the source is a <?dbhh> processing instruction. <?dbhh> PIs
come with @topicid attribute that supply the needed value.

For example, I want to produce context.h file that looks like:

#define mybook  0
#define para1   1
#define chap0   2
#define foo     3
#define bar     1069542

The #define comes from a <?dbhh ?> processing instruction 
with its @topicid value set to 1069542:

  <?dbhh topicname="bar" topicid="1069542"?>

All other #define's come from block level elements with @id attributes:

  <book id="mybook">
    <para id="para1">

I have tried:

<xsl:template match="*" mode="hh-map">
  <xsl:if test="@id">
    <xsl:text>#define </xsl:text>
    <xsl:value-of select="@id"/>
    <xsl:variable name="topicid">
      <xsl:call-template name="pi-attribute">
        <xsl:with-param name="pis" select="."/>
        <xsl:with-param name="attribute" select="'topicid'"/>
    <xsl:value-of select="$incrementalcount"/>
  <xsl:apply-templates mode="hh-map"> 
    <xsl:with-param name="incrementalcount" select="$incrementalcount + 

with initial call to it modified slightly:

<xsl:call-template name="hh-map">
  <xsl:with-param name="incrementalcount">1</xsl:with-param>

Because of the way XSLT recurses, this ends up assigning the 
depth of each element within the XML document, relative to root,
instead of a sequence number to call.

XSL does not provide for a global variable that changes. 

How can I assign a unique number to each of my block elements with @id's?

-Taro Ikai

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