creating index XSLT

Hello professionals,

I have the attached XSLT code. I have tried to create an index to show only the initials attributes and the result document should be like:

A B C D E F G H..... all in hyper link

but unfortunately my code gives me all data in translation element without the initials :(

please help me to show the index by the initials . please see the XSLT code and the source document.

Cheers,
------ XSLT 
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
	<xsl:template match="Dictionary">
		<html>
		<head>
		<title> Bilingual Lexicon <xsl:value-of select="/Dictionary/from" />-<xsl:value-of select="/Dictionary/to" /></title>
		</head>
		<body>
		<h3>Browse by letter</h3>
		<xsl:apply-templates select="/Dictionary/translation" mode="TOC" />
		</body>
		</html>
	</xsl:template>
	<xsl:template match="Dictionary" mode="TOC">
		<a href="{concat('#Dictionary', position())}">
			<p><b><xsl:value-of select="@initial" /></b></p>
		</a>
	</xsl:template>
</xsl:stylesheet>

------ Source document translation.xml

<?xml version="1.0" encoding="UTF-8"?>
<Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="translation.xsd">
   <from>EN</from>
   <to>ES</to>
   <total>150</total>
   <translation initial="A">
      <search>A Clockwork Orange</search>
      <counter>1</counter>
      <replace>La naranja mecánica</replace>
   </translation>
   <translation initial="A">
      <search>A Few Good Men</search>
      <counter>1</counter>
      <replace>A Few Good Men</replace>
   </translation>
   <translation initial="A">
      <search>A Star Is Born</search>
      <counter>1</counter>
      <replace>Ha nacido una estrella</replace>
   </translation>
   <translation initial="A">
      <search>Ab Urbe condita</search>
      <counter>1</counter>
      <replace>Ab Urbe condita libri</replace>
   </translation>
   <translation initial="A">
      <search>Ab urbe condita</search>
      <counter>1</counter>
      <replace>Ab urbe condita</replace>
   </translation>
   <translation initial="A">
      <search>Abel</search>
      <counter>2</counter>
      <replace>Abel</replace>
      <replace>Caín</replace>
   </translation>
   <translation initial="A">
      <search>Alyosha Karamazov</search>
      <counter>1</counter>
      <replace>Los hermanos Karamazov</replace>
   </translation>
   <translation initial="A">
      <search>And Then There Were None</search>
      <counter>1</counter>
      <replace>Diez negritos</replace>
   </translation>
   <translation initial="A">
      <search>Angst</search>
      <counter>1</counter>
      <replace>Gaslight</replace>
   </translation>
   <translation initial="G">
      <search>Gaslight</search>
      <counter>1</counter>
      <replace>Gaslight</replace>
   </translation>
   <translation initial="A">
      <search>Around The World In 80 Days</search>
      <counter>1</counter>
      <replace>La vuelta al mundo en ochenta días</replace>
   </translation>
   <translation initial="A">
      <search>Around the World in Eighty Days</search>
      <counter>1</counter>
      <replace>La vuelta al mundo en ochenta días</replace>
   </translation>
   <translation initial="B">
      <search>Batman &amp; Robin</search>
      <counter>1</counter>
      <replace>Batman y Robin</replace>
   </translation>
   <translation initial="B">
      <search>Bomarzo</search>
      <counter>1</counter>
      <replace>Bomarzo</replace>
   </translation>
   <translation initial="B">
      <search>Brave New World</search>
      <counter>1</counter>
      <replace>Un mundo feliz</replace>
   </translation>
   <translation initial="C">
      <search>Casino Royale</search>
      <counter>1</counter>
      <replace>Casino Royale</replace>
   </translation>
   <translation initial="C">
      <search>Cheaper by the Dozen</search>
      <counter>1</counter>
      <replace>Más barato por docena</replace>
   </translation>
   <translation initial="C">
      <search>Cinderella</search>
      <counter>1</counter>
      <replace>La Cenicienta</replace>
   </translation>
   <translation initial="D">
      <search>Da Vinci Code</search>
      <counter>1</counter>
      <replace>El código Da Vinci</replace>
   </translation>
   <translation initial="D">
      <search>Dawn of the Dead</search>
      <counter>1</counter>
      <replace>El amanecer de los muertos</replace>
   </translation>
   <translation initial="D">
      <search>Diary of a Chambermaid</search>
      <counter>1</counter>
      <replace>Diario de una camarera</replace>
   </translation>
   <translation initial="D">
      <search>Dune</search>
      <counter>1</counter>
      <replace>Dune</replace>
   </translation>
   <translation initial="E">
      <search>Evil Dead</search>
      <counter>1</counter>
      <replace>Posesión infernal</replace>
   </translation>
   <translation initial="F">
      <search>Frankenstein</search>
      <counter>1</counter>
      <replace>Frankenstein</replace>
   </translation>
   <translation initial="F">
      <search>Fyodor Karamazov</search>
      <counter>1</counter>
      <replace>Los hermanos Karamazov</replace>
   </translation>
   <translation initial="G">
      <search>General San Martín Park</search>
      <counter>1</counter>
      <replace>Parque General San Martín</replace>
   </translation>
   <translation initial="G">
      <search>Gentlemen Prefer Blondes</search>
      <counter>1</counter>
      <replace>Los caballeros las prefieren rubias</replace>
   </translation>
   <translation initial="G">
      <search>Goldfinger</search>
      <counter>1</counter>
      <replace>Goldfinger</replace>
   </translation>
   <translation initial="H">
      <search>Haitian Creole</search>
      <counter>1</counter>
      <replace>Criollo haitiano</replace>
   </translation>
   <translation initial="H">
      <search>Haitian language</search>
      <counter>1</counter>
      <replace>Criollo haitiano</replace>
   </translation>
   <translation initial="H">
      <search>Hamlet</search>
      <counter>1</counter>
      <replace>Hamlet</replace>
   </translation>
   <translation initial="H">
      <search>House of Wax</search>
      <counter>1</counter>
      <replace>La casa de cera</replace>
   </translation>
   <translation initial="I">
      <search>I, Robot</search>
      <counter>1</counter>
      <replace>Yo, Robot</replace>
   </translation>
   <translation initial="I">
      <search>Il Gattopardo</search>
      <counter>1</counter>
      <replace>El gatopardo</replace>
   </translation>
   <translation initial="I">
      <search>In Cold Blood</search>
      <counter>1</counter>
      <replace>A sangre fría</replace>
   </translation>
   <translation initial="I">
      <search>Interview with the Vampire</search>
      <counter>1</counter>
      <replace>Entrevista con el Vampiro</replace>
   </translation>
   <translation initial="I">
      <search>Ivan Karamazov</search>
      <counter>1</counter>
      <replace>Los hermanos Karamazov</replace>
   </translation>
   <translation initial="J">
      <search>John Robert Schrieffer</search>
      <counter>1</counter>
      <replace>John Robert Schrieffer</replace>
   </translation>
   <translation initial="J">
      <search>J Robert Schrieffer</search>
      <counter>1</counter>
      <replace>John Robert Schrieffer</replace>
   </translation>
   <translation initial="J">
      <search>Joseph K</search>
      <counter>1</counter>
      <replace>El proceso</replace>
   </translation>
   <translation initial="J">
      <search>Journey to the Center of the Earth</search>
      <counter>1</counter>
      <replace>Viaje al centro de la Tierra</replace>
   </translation>
   <translation initial="L">
      <search>La Boheme</search>
      <counter>1</counter>
      <replace>La Bohème</replace>
   </translation>
   <translation initial="L">
      <search>La bohème</search>
      <counter>1</counter>
      <replace>La Bohème</replace>
   </translation>
   <translation initial="L">
      <search>Les Miserables</search>
      <counter>1</counter>
      <replace>Los miserables</replace>
   </translation>
   <translation initial="L">
      <search>Les Misérables</search>
      <counter>1</counter>
      <replace>Los miserables</replace>
   </translation>
   <translation initial="L">
      <search>Librarians in the Name of the Rose</search>
      <counter>1</counter>
      <replace>El nombre de la rosa</replace>
   </translation>
   <translation initial="L">
      <search>Lolita</search>
      <counter>1</counter>
      <replace>Lolita</replace>
   </translation>
   <translation initial="L">
      <search>Lord of the Flies</search>
      <counter>1</counter>
      <replace>El señor de las moscas</replace>
   </translation>
   <translation initial="L">
      <search>Lord of the Flies in popular culture</search>
      <counter>1</counter>
      <replace>El señor de las moscas</replace>
   </translation>
   <translation initial="M">
      <search>M</search>
      <counter>1</counter>
      <replace>M, el vampiro de Düsseldorf</replace>
   </translation>
   <translation initial="M">
      <search>Macbeth</search>
      <counter>1</counter>
      <replace>Macbeth</replace>
   </translation>
   <translation initial="M">
      <search>Madame Bovary</search>
      <counter>1</counter>
      <replace>Madame Bovary</replace>
   </translation>
   <translation initial="M">
      <search>Materialism</search>
      <counter>1</counter>
      <replace>Materialismo</replace>
   </translation>
   <translation initial="M">
      <search>Materialist</search>
      <counter>1</counter>
      <replace>Materialismo</replace>
   </translation>
   <translation initial="M">
      <search>Mathematica</search>
      <counter>1</counter>
      <replace>Mathematica</replace>
   </translation>
   <translation initial="M">
      <search>Midsummer Night's Dream</search>
      <counter>1</counter>
      <replace>El sueño de una noche de verano</replace>
   </translation>
   <translation initial="M">
      <search>Mountaineering</search>
      <counter>1</counter>
      <replace>Montañismo</replace>
   </translation>
   <translation initial="M">
      <search>Mountain climbing</search>
      <counter>1</counter>
      <replace>Montañismo</replace>
   </translation>
   <translation initial="A">
      <search>Alpinism</search>
      <counter>1</counter>
      <replace>Montañismo</replace>
   </translation>
   <translation initial="M">
      <search>Murder on the Orient Express</search>
      <counter>1</counter>
      <replace>Asesinato en el Orient Express</replace>
   </translation>
   <translation initial="M">
      <search>Musketeers</search>
      <counter>1</counter>
      <replace>Los tres mosqueteros</replace>
   </translation>
   <translation initial="M">
      <search>Myocardial infarction</search>
      <counter>2</counter>
      <replace>Infarto</replace>
      <replace>Infarto de miocardio</replace>
   </translation>
   <translation initial="N">
      <search>Name of the Rose</search>
      <counter>1</counter>
      <replace>El nombre de la rosa</replace>
   </translation>
   <translation initial="N">
      <search>Neverending Story</search>
      <counter>1</counter>
      <replace>La historia interminable</replace>
   </translation>
   <translation initial="N">
      <search>Night Watch</search>
      <counter>1</counter>
      <replace>La ronda de noche</replace>
   </translation>
   <translation initial="N">
      <search>Night Watch painting</search>
      <counter>1</counter>
      <replace>La ronda de noche</replace>
   </translation>
   <translation initial="N">
      <search>Night of the Living Dead</search>
      <counter>1</counter>
      <replace>La noche de los muertos vivientes</replace>
   </translation>
   <translation initial="N">
      <search>Nineteen Eighty-Four</search>
      <counter>1</counter>
      <replace>Mil novecientos ochenta y cuatro</replace>
   </translation>
   <translation initial="N">
      <search>Northern Savonia</search>
      <counter>1</counter>
      <replace>Savonia del Norte</replace>
   </translation>
   <translation initial="O">
      <search>Oath of the Horatii</search>
      <counter>1</counter>
      <replace>Juramento de los Horacios</replace>
   </translation>
   <translation initial="O">
      <search>Ocean's Eleven</search>
      <counter>2</counter>
      <replace>Cuadrilla de los once</replace>
      <replace>Ocean's Eleven</replace>
   </translation>
   <translation initial="O">
      <search>Oliver Twist</search>
      <counter>1</counter>
      <replace>Oliver Twist</replace>
   </translation>
   <translation initial="O">
      <search>On Her Majesty's Secret Service</search>
      <counter>1</counter>
      <replace>al servicio secreto de su majestad</replace>
   </translation>
   <translation initial="P">
      <search>Parque Central Complex</search>
      <counter>2</counter>
      <replace>Torres de Parque Central</replace>
      <replace>Torres de Parque Central Caracas</replace>
   </translation>
   <translation initial="P">
      <search>Parque San Martin</search>
      <counter>2</counter>
      <replace>Parque General San Martín</replace>
      <replace>Parque General San Martín Mendoza</replace>
   </translation>
   <translation initial="P">
      <search>Persimmon</search>
      <counter>1</counter>
      <replace>Diospyros kaki</replace>
   </translation>
   <translation initial="P">
      <search>Persimmons</search>
      <counter>1</counter>
      <replace>Diospyros kaki</replace>
   </translation>
   <translation initial="P">
      <search>Peter Pan</search>
      <counter>1</counter>
      <replace>Peter Pan</replace>
   </translation>
   <translation initial="P">
      <search>Phantom of the Opera</search>
      <counter>1</counter>
      <replace>El Fantasma de la Ópera</replace>
   </translation>
   <translation initial="P">
      <search>Planet of the Apes</search>
      <counter>1</counter>
      <replace>El planeta de los simios</replace>
   </translation>
   <translation initial="P">
      <search>Pride and Prejudice</search>
      <counter>1</counter>
      <replace>Orgullo y prejuicio</replace>
   </translation>
   <translation initial="Q">
      <search>Quality control</search>
      <counter>1</counter>
      <replace>Control de calidad</replace>
   </translation>
   <translation initial="Q">
      <search>Quebec city</search>
      <counter>1</counter>
      <replace>Ciudad de Quebec</replace>
   </translation>
   <translation initial="Q">
      <search>Quirinal</search>
      <counter>1</counter>
      <replace>Quirinal</replace>
   </translation>
   <translation initial="Q">
      <search>Quirinale</search>
      <counter>1</counter>
      <replace>Quirinal</replace>
   </translation>
   <translation initial="Q">
      <search>Québec City</search>
      <counter>1</counter>
      <replace>Ciudad de Quebec</replace>
   </translation>
   <translation initial="R">
      <search>Reductionism</search>
      <counter>1</counter>
      <replace>Reduccionismo</replace>
   </translation>
   <translation initial="R">
      <search>Reductionist</search>
      <counter>1</counter>
      <replace>Reduccionismo</replace>
   </translation>
   <translation initial="R">
      <search>Reductionistic</search>
      <counter>1</counter>
      <replace>Reduccionismo</replace>
   </translation>
   <translation initial="R">
      <search>Roman Holiday</search>
      <counter>1</counter>
      <replace>Vacaciones en Roma</replace>
   </translation>
   <translation initial="R">
      <search>Romeo and Juliet</search>
      <counter>1</counter>
      <replace>Romeo y Julieta</replace>
   </translation>
   <translation initial="S">
      <search>Sense and Sensibility</search>
      <counter>1</counter>
      <replace>Sensatez y sentimientos</replace>
   </translation>
   <translation initial="S">
      <search>Smerdyakov</search>
      <counter>1</counter>
      <replace>Los hermanos Karamazov</replace>
   </translation>
   <translation initial="S">
      <search>Solaris</search>
      <counter>1</counter>
      <replace>Solaris</replace>
   </translation>
   <translation initial="S">
      <search>St Mark's Cathedral</search>
      <counter>1</counter>
      <replace>Basílica de San Marcos</replace>
   </translation>
   <translation initial="T">
      <search>The Brothers Karamazov</search>
      <counter>1</counter>
      <replace>Los hermanos Karamazov</replace>
   </translation>
   <translation initial="T">
      <search>The Da Vinci Code</search>
      <counter>1</counter>
      <replace>El código Da Vinci</replace>
   </translation>
   <translation initial="T">
      <search>The Evil Dead</search>
      <counter>1</counter>
      <replace>Posesión infernal</replace>
   </translation>
   <translation initial="T">
      <search>The Exorcist</search>
      <counter>1</counter>
      <replace>El Exorcista</replace>
   </translation>
   <translation initial="T">
      <search>The Fast and the Furious</search>
      <counter>1</counter>
      <replace>The Fast and the Furious</replace>
   </translation>
   <translation initial="T">
      <search>The Fugitive</search>
      <counter>1</counter>
      <replace>El fugitivo</replace>
   </translation>
   <translation initial="T">
      <search>The Great Gatsby</search>
      <counter>1</counter>
      <replace>El gran Gatsby</replace>
   </translation>
   <translation initial="G">
      <search>Gatsby</search>
      <counter>1</counter>
      <replace>El gran Gatsby</replace>
   </translation>
   <translation initial="T">
      <search>The Idiot</search>
      <counter>1</counter>
      <replace>El idiota</replace>
   </translation>
   <translation initial="T">
      <search>The Island</search>
      <counter>1</counter>
      <replace>La isla</replace>
   </translation>
   <translation initial="T">
      <search>The Italian Job</search>
      <counter>1</counter>
      <replace>The Italian Job</replace>
   </translation>
   <translation initial="T">
      <search>The Jazz Singer</search>
      <counter>1</counter>
      <replace>El cantante de jazz</replace>
   </translation>
   <translation initial="T">
      <search>The Leopard</search>
      <counter>1</counter>
      <replace>El gatopardo</replace>
   </translation>
   <translation initial="T">
      <search>The Maltese Falcon</search>
      <counter>1</counter>
      <replace>El halcón maltés</replace>
   </translation>
   <translation initial="T">
      <search>The Mummy</search>
      <counter>1</counter>
      <replace>La Momia</replace>
   </translation>
   <translation initial="T">
      <search>The Name of the Rose</search>
      <counter>1</counter>
      <replace>El nombre de la rosa</replace>
   </translation>
   <translation initial="T">
      <search>The Neverending Story</search>
      <counter>1</counter>
      <replace>La historia interminable</replace>
   </translation>
   <translation initial="T">
      <search>The Old Man and the Sea</search>
      <counter>1</counter>
      <replace>El viejo y el mar</replace>
   </translation>
   <translation initial="T">
      <search>The Phantom of the Opera</search>
      <counter>1</counter>
      <replace>El Fantasma de la Ópera</replace>
   </translation>
   <translation initial="T">
      <search>The Picture of Dorian Gray</search>
      <counter>1</counter>
      <replace>El retrato de Dorian Gray</replace>
   </translation>
   <translation initial="T">
      <search>The Ring</search>
      <counter>1</counter>
      <replace>La señal</replace>
   </translation>
   <translation initial="T">
      <search>The Spy Who Loved Me</search>
      <counter>1</counter>
      <replace>El espía que me amó</replace>
   </translation>
   <translation initial="T">
      <search>The Stranger</search>
      <counter>1</counter>
      <replace>El extranjero</replace>
   </translation>
   <translation initial="T">
      <search>The Ten Commandments</search>
      <counter>1</counter>
      <replace>Los diez mandamientos</replace>
   </translation>
   <translation initial="T">
      <search>The Texas Chainsaw Massacre</search>
      <counter>1</counter>
      <replace>La matanza de Texas</replace>
   </translation>
   <translation initial="T">
      <search>The Three Musketeers</search>
      <counter>1</counter>
      <replace>Los tres mosqueteros</replace>
   </translation>
   <translation initial="T">
      <search>The Trial</search>
      <counter>1</counter>
      <replace>El proceso</replace>
   </translation>
   <translation initial="T">
      <search>The Untouchables</search>
      <counter>1</counter>
      <replace>The Untouchables</replace>
   </translation>
   <translation initial="T">
      <search>Titanic</search>
      <counter>1</counter>
      <replace>Titanic</replace>
   </translation>
   <translation initial="T">
      <search>To Kill a Mockingbird</search>
      <counter>1</counter>
      <replace>Matar un ruiseñor</replace>
   </translation>
   <translation initial="T">
      <search>Treasure Island</search>
      <counter>1</counter>
      <replace>La isla del tesoro</replace>
   </translation>
   <translation initial="U">
      <search>Ulysses</search>
      <counter>1</counter>
      <replace>Ulises</replace>
   </translation>
   <translation initial="U">
      <search>Universalism</search>
      <counter>1</counter>
      <replace>Universalismo</replace>
   </translation>
   <translation initial="U">
      <search>Universalist</search>
      <counter>1</counter>
      <replace>Universalismo</replace>
   </translation>
   <translation initial="U">
      <search>Universalists</search>
      <counter>1</counter>
      <replace>Universalismo</replace>
   </translation>
   <translation initial="V">
      <search>Valais</search>
      <counter>1</counter>
      <replace>Cantón del Valais</replace>
   </translation>
   <translation initial="V">
      <search>Valencia</search>
      <counter>4</counter>
      <replace>Comunidad Valenciana</replace>
      <replace>Provincia de Valencia</replace>
      <replace>Reino de Valencia</replace>
      <replace>Valencia</replace>
   </translation>
   <translation initial="V">
      <search>València</search>
      <counter>1</counter>
      <replace>Valencia</replace>
   </translation>
   <translation initial="V">
      <search>Vaudevillian</search>
      <counter>1</counter>
      <replace>Vodevil</replace>
   </translation>
   <translation initial="V">
      <search>Vaudevillians</search>
      <counter>1</counter>
      <replace>Vodevil</replace>
   </translation>
   <translation initial="V">
      <search>Volcano</search>
      <counter>1</counter>
      <replace>Volcán</replace>
   </translation>
   <translation initial="W">
      <search>War and Peace</search>
      <counter>1</counter>
      <replace>Guerra y paz</replace>
   </translation>
   <translation initial="W">
      <search>War of the Worlds</search>
      <counter>1</counter>
      <replace>La guerra de los mundos</replace>
   </translation>
   <translation initial="W">
      <search>Witness for the Prosecution</search>
      <counter>1</counter>
      <replace>Testigo de cargo</replace>
   </translation>
   <translation initial="W">
      <search>Wuthering Heights</search>
      <counter>1</counter>
      <replace>Cumbres borrascosas</replace>
   </translation>
   <translation initial="X">
      <search>X chromosome</search>
      <counter>1</counter>
      <replace>Cromosoma X</replace>
   </translation>
   <translation initial="X">
      <search>Xenophon</search>
      <counter>1</counter>
      <replace>Jenofonte</replace>
   </translation>
   <translation initial="Y">
      <search>Yacht</search>
      <counter>1</counter>
      <replace>Yate</replace>
   </translation>
   <translation initial="Y">
      <search>Yakuza</search>
      <counter>1</counter>
      <replace>Yakuza</replace>
   </translation>
   <translation initial="Y">
      <search>You Only Live Twice</search>
      <counter>1</counter>
      <replace>Sólo se vive dos veces</replace>
   </translation>
   <translation initial="Y">
      <search>Yugoslav Macedonia</search>
      <counter>1</counter>
      <replace>República de Macedonia</replace>
   </translation>
   <translation initial="Y">
      <search>Yugoslav Partisans</search>
      <counter>2</counter>
      <replace>Partisanos</replace>
      <replace>Partisanos Yugoslavia</replace>
   </translation>
   <translation initial="Z">
      <search>Zespri</search>
      <counter>1</counter>
      <replace>Actinidia deliciosa</replace>
   </translation>
   <translation initial="Z">
      <search>Zimniy Dvorets</search>
      <counter>1</counter>
      <replace>Palacio de Invierno</replace>
   </translation>
   <translation initial="Z">
      <search>Zosimus</search>
      <counter>2</counter>
      <replace>Zósimo</replace>
      <replace>Zósimo historiador</replace>
   </translation>
</Dictionary>

Open in new window

AussieSilverAsked:
Who is Participating?
 
Geert BormansInformation ArchitectCommented:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
    <xsl:key name="initial" match="translation" use="@initial"/>
    <xsl:template match="Dictionary">
        <html>
            <head>
                <title> Bilingual Lexicon <xsl:value-of select="/Dictionary/from" />-<xsl:value-of select="/Dictionary/to" /></title>
            </head>
            <body>
                <h3>Browse by letter</h3>
                <p>
                    <xsl:apply-templates select="translation[generate-id() = generate-id(key('initial', @initial)[1])]" mode="TOC" >
                        <xsl:sort select="@initial" order="ascending" data-type="text"/>
                    </xsl:apply-templates>
                </p>
                <table border="1">
                    <tr><th>search</th><th>replace</th></tr>
                    <xsl:apply-templates select="translation" mode="FLOW">
                        <xsl:sort select="@initial" order="ascending" data-type="text"/>
                    </xsl:apply-templates>
                    
                </table>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="translation" mode="TOC">
        <a href="{concat('#Dictionary', @initial)}">
            <b><xsl:value-of select="@initial" /></b>
        </a>
        <xsl:text>&#160; </xsl:text>
    </xsl:template>
    
    <xsl:template match="translation" mode="FLOW">
        <xsl:variable name="is-first-initial" select="not(preceding-sibling::translation[@initial = current()/@initial])"/>
        <tr>
            <td>
                <xsl:if test="$is-first-initial">
                    <a name="{concat('Dictionary', @initial)}"></a>
                </xsl:if>
                <xsl:value-of select="search"/>
            </td>
            <td>
                <xsl:for-each select="replace">
                    <xsl:if test="not(position() = 1)">
                        <xsl:text>; </xsl:text>
                    </xsl:if>
                    <xsl:value-of select="."/>
                </xsl:for-each>
            </td>
        </tr>
    </xsl:template>

</xsl:stylesheet>

Open in new window

0
 
AussieSilverAuthor Commented:
Is the question not clear?

where are you gertone?
0
 
AussieSilverAuthor Commented:
:)
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Geert BormansInformation ArchitectCommented:
I was out my friend, am working on it now
0
 
AussieSilverAuthor Commented:
Thanks bro
0
 
Geert BormansInformation ArchitectCommented:
Basically that is another Muenchian, but now with the attribute as a key indexer

Do you really want a seperate process (you source seems to be the result of your other question)
0
 
AussieSilverAuthor Commented:
yes please ... the source is the outcome of the previous threads
0
 
Geert BormansInformation ArchitectCommented:
something like this?
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
    <xsl:key name="initial" match="translation" use="@initial"/>
    <xsl:template match="Dictionary">
        <html>
            <head>
                <title> Bilingual Lexicon <xsl:value-of select="/Dictionary/from" />-<xsl:value-of select="/Dictionary/to" /></title>
            </head>
            <body>
                <h3>Browse by letter</h3>
                <xsl:apply-templates select="translation[generate-id() = generate-id(key('initial', @initial)[1])]" mode="TOC" >
                    <xsl:sort select="@initial" order="ascending" data-type="text"/>
                </xsl:apply-templates>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="translation" mode="TOC">
        <p>
            <a href="{concat('#Dictionary', @initial)}">
                <b><xsl:value-of select="@initial" /></b>
            </a>
        </p>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
AussieSilverAuthor Commented:
Hello My friend,

It gives the following error:

Error on line 24 column 17 of file:/home/dmlTL6/dictionary.xslt:
  SXXP0003: Error reported by XML parser: XML document structures must start and end within
  the same entity.
Failed to compile stylesheet. 1 error detected.
0
 
AussieSilverAuthor Commented:
no no stop ... i think i did something wrong hang on please
0
 
AussieSilverAuthor Commented:
yes seems working .... but I want to show the content of letter A like the following:

A Clockwork Orange                      La naranja mecánica


---------

A Clockwork Orange is the search element
  La naranja mecánica is the replace element

:) cheers,
0
 
AussieSilverAuthor Commented:
this happens once I click each letter
0
 
Geert BormansInformation ArchitectCommented:
OK, wait a second (it would help if your specs were clear from the start.

You need the index, but also want the full list and links to it?
0
 
AussieSilverAuthor Commented:
:)

yes that is what i want... I'm sorry for not being very clear
0
 
Geert BormansInformation ArchitectCommented:
Look at this code,
it creates an index (in mode TOC)
and the normal flow (in mode FLOW) as a table, with row spanning for the searches with multiple replaces and a named anchor for linking on each first occurence of an initial

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
    <xsl:key name="initial" match="translation" use="@initial"/>
    <xsl:template match="Dictionary">
        <html>
            <head>
                <title> Bilingual Lexicon <xsl:value-of select="/Dictionary/from" />-<xsl:value-of select="/Dictionary/to" /></title>
            </head>
            <body>
                <h3>Browse by letter</h3>
                <p>
                    <xsl:apply-templates select="translation[generate-id() = generate-id(key('initial', @initial)[1])]" mode="TOC" >
                        <xsl:sort select="@initial" order="ascending" data-type="text"/>
                    </xsl:apply-templates>
                </p>
                <table border="1">
                    <tr><th>search</th><th>replace</th></tr>
                    <xsl:apply-templates select="translation" mode="FLOW">
                        <xsl:sort select="@initial" order="ascending" data-type="text"/>
                    </xsl:apply-templates>
                    
                </table>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="translation" mode="TOC">
        <a href="{concat('#Dictionary', @initial)}">
            <b><xsl:value-of select="@initial" /></b>
        </a>
        <xsl:text>&#160; </xsl:text>
    </xsl:template>
    
    <xsl:template match="translation" mode="FLOW">
        <xsl:variable name="is-first-initial" select="not(preceding-sibling::translation[@initial = current()/@initial])"/>
        <xsl:for-each select="replace">
            <tr>
                <xsl:if test="position() = 1">
                    <td>
                        <xsl:if test="../counter > 1">
                            <xsl:attribute name="rowspan">
                                <xsl:value-of select="../counter"/>
                            </xsl:attribute>
                        </xsl:if>
                        <xsl:if test="$is-first-initial">
                            <a name="{concat('Dictionary', ../@initial)}"></a>
                        </xsl:if>
                        <xsl:value-of select="../search"/>
                    </td>
                </xsl:if>
                <td>
                    <xsl:value-of select="."/>
                </td>
            </tr>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
AussieSilverAuthor Commented:
YES.. Almost complete... there is a small requirement for multiple replace elements:

e.g.

Abel    Abel;Caín

Myocardial infarction  Infarto;Infarto de miocardio

the multiple replaces should be in one row divided by a semi-colon (:)

THANKS AGAIN and AGAIN
0
 
AussieSilverAuthor Commented:
Hi,

Should I put that requirement is a separate thread ?

thanks
0
 
Geert BormansInformation ArchitectCommented:
no, I can deal with that here
0
 
AussieSilverAuthor Commented:
Perfect ...

Time to have them in plain English explanation please  :)   , I can put it in a different post if you want :)
0
 
Geert BormansInformation ArchitectCommented:
Explanation will come, but I have to finish some other stuff now
0
 
AussieSilverAuthor Commented:
thanks bro
0
 
Geert BormansInformation ArchitectCommented:
here you are
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
    <xsl:key name="initial" match="translation" use="@initial"/>
====> key for uniqueness (Muenchian on the initial attribute)
    <xsl:template match="Dictionary">
        <html>
            <head>
                <title> Bilingual Lexicon <xsl:value-of select="/Dictionary/from" />-<xsl:value-of select="/Dictionary/to" /></title>
            </head>
            <body>
                <h3>Browse by letter</h3>
====> There are two subsequent constructs made from the full dataset, a TOC and the full list
====> So there are two apply-templates, pushing out the nodes, in a different mode. 
====> They will only be picked up by templates having teh same mode               
                <p>
                    <xsl:apply-templates select="translation[generate-id() = generate-id(key('initial', @initial)[1])]" mode="TOC" >
====> Muenchian grouping, used to push out only the nodes with a unique initial attribute
                        <xsl:sort select="@initial" order="ascending" data-type="text"/>
====> The unique nodes for the initials in the TOC will be sorted (though I am suspicious about them being sorted allready)
                    </xsl:apply-templates>
                </p>
                <table border="1">
                    <tr><th>search</th><th>replace</th></tr>
====> second apply-templates, now inside a table for generating a line for a node, sorted on initial
                    <xsl:apply-templates select="translation" mode="FLOW">
                        <xsl:sort select="@initial" order="ascending" data-type="text"/>
                    </xsl:apply-templates>
                </table>
            </body>
        </html>
    </xsl:template>
    
====> for unique initial nodes, a link is generated    
    <xsl:template match="translation" mode="TOC">
        <a href="{concat('#Dictionary', @initial)}">
            <b><xsl:value-of select="@initial" /></b>
        </a>
        <xsl:text>&#160; </xsl:text>
    </xsl:template>

====> for the flow, a table row is generated per translation    
    <xsl:template match="translation" mode="FLOW">
====> I create a boolean variable that is true if there is no preceding sibling with the same @initial 
====> This will be set to true() if t is the first translation with a certain initial
====> will be used to put the named anchor for the in-document link
        <xsl:variable name="is-first-initial" select="not(preceding-sibling::translation[@initial = current()/@initial])"/>
        <tr>
            <td>
                <xsl:if test="$is-first-initial">
====> named anchor for in-document link
                    <a name="{concat('Dictionary', @initial)}"></a>
                </xsl:if>
                <xsl:value-of select="search"/>
            </td>
            <td>
                <xsl:for-each select="replace">
====> looping over each replace in the translation, seperating values with ';', unless first
                    <xsl:if test="not(position() = 1)">
                        <xsl:text>; </xsl:text>
                    </xsl:if>
                    <xsl:value-of select="."/>
                </xsl:for-each>
            </td>
        </tr>
    </xsl:template>

</xsl:stylesheet>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.