This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
[docbook-apps] Request for help with XSL: how to produce unique numbers for all id's
- From: Taro Ikai <tikai at ABINITIO dot COM>
- To: docbook-apps at lists dot oasis-open dot org
- Date: Wed, 8 Oct 2003 18:09:37 -0400
- Subject: [docbook-apps] 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
#define
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:call-template>
</xsl:variable>
<xsl:text>	</xsl:text>
<xsl:value-of select="$incrementalcount"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:apply-templates mode="hh-map">
<xsl:with-param name="incrementalcount" select="$incrementalcount +
1"/>
</xsl:apply-templates>
</xsl:template>
with initial call to it modified slightly:
<xsl:call-template name="hh-map">
<xsl:with-param name="incrementalcount">1</xsl:with-param>
</xsl:call-template>
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
To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.