tags:

views:

51

answers:

3

I need to generate a Sequence id for TOC part and idref for the referenced places using the content first three letters.

Input:

<tocentry><title>List of Boxed Readings</title></tocentry>
<tocentry><title>Foreword</title></tocentry>
<tocentry><title>About the Author</title></tocentry>
<tocentry><title>Preface</title></tocentry>
<tocentry><title>A Dinosaur Dictionary</title></tocentry>
<tocentry><title>GLOSSARY</title></tocentry>
<tocentry><title>INDEX</title></tocentry>

Required OUtput:

<p class="Toc-part"><a href="#LOBRSec1">List of Boxed Readings</a></p>
<p class="Toc-part"><a href="#ForeSec2">Foreword</a></p>
<p class="Toc-part"><a href="#AtASec3">About the Author</a></p>
<p class="Toc-part"><a href="#PrefSec4">Preface</a></p>
<p class="Toc-part"><a href="#ADDSec5">A Dinosaur Dictionary</a></p>
<p class="Toc-part"><a href="#GLOSSec6">GLOSSARY</a></p>
<p class="Toc-part"><a href="#INDXSec7">INDEX</a></p>

Please help me to generate ID from the content first letters...

Best regards, Antony

+1  A: 

Since I can't see why you would want some arbitrary letter combination in an ID that already is unique, I dis-recommend that and say you go with this instead:

<xsl:template match="tocentry">
  <p class="Toc-part">
    <xsl:apply-templates select="title" />
  </p>
</xsl:template>

<xsl:template match="title">
  <a href="#Sec{count(preceding-sibling::title) + 1}">
    <xsl:value-of select="." />
  </a>
</xsl:template>
Tomalak
+1  A: 

This problem will never be solved, because it is not formulated correctly. You do not present strict rules for producing the Ids -- for example, why INDX but not INDE ? Why ATA and not ATAU?

This problem has an ellegant solution, put into XSLT by the designers of the language. Do read about the generate-id() function and use it to generate your ids.

Dimitre Novatchev
A: 

You can use standard word instead of the content in the id

for example if it is frontmatter use "FMSec1, FMSec2, FMSec3..... FMSecN.."

"FM" will be the difference than others...