Search code examples
xsltditadita-ot

Number format needed as prefix for the xhtml files of dita ot epub output


I have used the Dita OT 1.8.5 for epub conversion: but i need the number sequence format 01, 02, 03 .. prefix for the xhtml files names in the epub output.

I have changed the code in html-generation-utils.xsl function as below for the number sequence for file names:

<xsl:function name="htmlutil:constructHtmlResultTopicFilename" as="xs:string">
    <xsl:param name="topic" as="document-node()"/>
    <xsl:variable name="topicFilename"
      select="concat(htmlutil:getResultTopicBaseName($topic), $OUTEXT)"
      as="xs:string"/>
    <xsl:for-each select="$topic">
<xsl:variable name="number"><xsl:value-of select="format-number(position(),'00')"/></xsl:variable>
<xsl:sequence select="concat($number, $topicFilename)"/>
</xsl:for-each>
  </xsl:function>

I am getting the output of the file names for all prefix as '01' only.

But i need prefix as 01, 02, 03, ...

Please suggest.

Thanks in Advance


Solution

  • <xsl:template name="get-result-topic-base-name-single-dir">
        <xsl:param name="topicUri" as="xs:string"/>
        <xsl:variable name="topicID" select="/*[contains(@class, ' topic/topic ')]/@id" />     
        <xsl:variable name="topic_count">
          <xsl:for-each select="$collected-data-global">
            <xsl:for-each select="mapdriven:collected-data/enum:enumerables/enum:topicref[@topicID=$topicID]">
              <xsl:number count="enum:topicref" format="01" />
            </xsl:for-each>
          </xsl:for-each>
        </xsl:variable>
        <xsl:variable name="maintitle"><xsl:apply-templates select="/*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]" mode="text-only"/></xsl:variable>
        <xsl:variable name="filename_characters_to_remove">~!@#$%^*()_+`-={}|[]\:";'?,./&#160;&lt;&gt;&amp;&#x2018;&#x2019;&#x201C;&#x201D;&#x2013;&#x2014;</xsl:variable>
        <xsl:variable name="puncremoved" select="translate($maintitle, $filename_characters_to_remove,'')"/>
        <xsl:variable name="baseName" select="translate($puncremoved, ' ','_')" as="xs:string"/>
        <xsl:sequence select="concat($topic_count, '_', $baseName)"/>
      </xsl:template>