×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

A-Z list links (qid=1328351 cont.)

A-Z list links (qid=1328351 cont.)

A-Z list links (qid=1328351 cont.)

(OP)

Hi

After a long search I found thread 1328351 but it's closed. As k5tm is still active here, I hope he sees this or maybe somebody else can reply.

I integrated the last reply (7 Feb 07 11:28) into my xslt and get it to run without complaints. As I am a beginner I now should find out which part of his code to replace with my field name.

"My" original sort select was:
<xsl:sort select="translate(normalize-space(translation/translations/entry/value),'abcdefghijklmnopqrstuvwxyzäöüéèàç','ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>

But the sort still works when I shorten it to
<xsl:sort select="translation/translations/entry/value"/>
which is what the name field is called in the XML file.

It's normal text, A-Z, what I would like to do is insert a jump navigation so I can navigate to a certain letter in the alphabet, which would be the first letter of translation/translations/entry/value.

---

I will copy k5tm's reply below - my question is: where do I have to replace his "name" with my "translation/translations/entry/value"?

If there is a simpler solution by now I'm not at all against it!

Thank you smile

RE: A-Z list links (qid=1328351 cont.)

(OP)
Thread 1328351, k5tm, 7 Feb 07 11:28

CODE -->

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>

<xsl:key name="initialChar" match="resource" use="translate(substring(name,1,1),
                                                     'abcdefghijklmnopqrstuvwxyz',
                                                  'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />

<xsl:template match="/">
    <html>
    <body>
    <!-- iterate over all the unique initial letter values -->
    <xsl:for-each select="//resource[generate-id(.)=generate-id(key('initialChar', 
                                                                  translate(substring(name,1,1),
                                                                'abcdefghijklmnopqrstuvwxyz',
                                                                'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))[1])]">
        <!-- sort the nodes for this initial letter value by name -->
        <xsl:sort select="name"/>
          <xsl:variable name="myChar" select="translate(substring(name,1,1),
                                                      'abcdefghijklmnopqrstuvwxyz',
                                                         'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
        <!-- output the links -->
        <xsl:call-template name="genLinks"/>
        <xsl:element name="a"><xsl:attribute name="name"><xsl:value-of select="string($myChar)"/></xsl:attribute></xsl:element>
        <!-- output all the nodes having this intial letter value -->
        <xsl:for-each select="key('initialChar',$myChar)">
            <xsl:sort select="name"/>
            <h2><xsl:value-of select="name"/></h2>
            <h3><xsl:value-of select="description"/></h3>
        </xsl:for-each>
      </xsl:for-each>
        <!-- output the final links -->
        <xsl:call-template name="genLinks"/>
    </body>
    </html>

</xsl:template>

<xsl:template name="genLinks">
        <span style="letter-spacing:7px; font-size=12pt">
        <center>
        <!-- The for-each will iterate exactly once for each unique initial letter. -->
        <xsl:for-each select="//resource[generate-id(.)=generate-id(key('initialChar', 
                                                                       translate(substring(name,1,1),
                                                                    'abcdefghijklmnopqrstuvwxyz',
                                                                    'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))[1])]">
            <xsl:sort select="name"/>
            <xsl:variable name="myLinkChar" select="translate(substring(name,1,1),
                                            'abcdefghijklmnopqrstuvwxyz',
                                            'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
            <a><xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="$myLinkChar"/></xsl:attribute>
               <xsl:value-of select="$myLinkChar"/></a>
               <xsl:if test="position()!=last()"><xsl:text>-</xsl:text></xsl:if>
        </xsl:for-each>
        </center>
        </span>
</xsl:template>

</xsl:stylesheet> 

RE: A-Z list links (qid=1328351 cont.)

I am still here. Not enough time to study this right now, but will try to come back to this...

Tom Morrison
Micro Focus

RE: A-Z list links (qid=1328351 cont.)

(OP)
Thank you. No hurry - it's just the closest I got so far. I would tell you here if I solved it some other way.

"But the sort still works when I shorten it..." is not true, it has to be normalized to sort correctly.

This is the output without the A-Z navigation: swissbib.ch/libraries.

RE: A-Z list links (qid=1328351 cont.)

(OP)
I just used your faq about grouping for another list with the same input, by the way. Works great, thank you for writing it.

RE: A-Z list links (qid=1328351 cont.)

Ok, I would need to see a small sample of your XML input document. (I presume it is used to produce the output seen at your link.) It would also be good for you to post your existing XSLT.

And I am slightly confused about exactly what you are asking. If you are asking about the navigation links, the following code lines are used to create the link line, followed by an anchor tag for the letter being started:

CODE

<!-- output the links -->
        <xsl:call-template name="genLinks"/><!--  this template generates the line 
                                            containing the links to all the letters -->

        <!-- the following line creates the anchor tag before the entries beginning with the letter contained in $myChar -->
        <xsl:element name="a"><xsl:attribute name="name"><xsl:value-of select="string($myChar)"/></xsl:attribute></xsl:element> 

Tom Morrison
Micro Focus

RE: A-Z list links (qid=1328351 cont.)

(OP)
> And I am slightly confused about exactly what you are asking.

Which part of your code I have to replace with my sort select. I'll copy the XML + XSLT below, but I'm out of office until next Thursday and offline from tomorrow until Wednesday.

Thank you for taking the time to look into this :)

RE: A-Z list links (qid=1328351 cont.)

(OP)
Output

XML:

CODE -->

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<libraryconfiguration>
 <libraries>
        <library>
            <addressURL>http://www.indologie.uzh.ch/access.html</addressURL>
            <adminDatabase>UZH50</adminDatabase>
            <designator>true</designator>
            <favorite>true</favorite>
            <favoriteQueryString>9902="UINDO"</favoriteQueryString>
            <id>1863</id>
            <institutionURL> </institutionURL>
            <libraryGroupIdentifier>UZH01</libraryGroupIdentifier>
            <libraryIdentifier>UINDO</libraryIdentifier>
            <libraryIdentifierMatcher> </libraryIdentifierMatcher>
            <name>UINDO</name>
            <reroSubGroup> </reroSubGroup>
            <road>Rämistr. 68</road>
            <sort>0</sort>
            <town>Zürich</town>
            <translation>
                <designator>TP_PARAMETER_[1863,0]</designator>
                <groupId>655</groupId>
                <translations>
                    <entry>
                        <key>de</key>
                        <value>Uni Zürich - Asien-Orient Institute - Indologische Bibliothek</value>
                    </entry>
                    <entry>
                        <key>it</key>
                        <value>Uni Zürich - Asien-Orient Institute - Indologische Bibliothek</value>
                    </entry>
                    <entry>
                        <key>fr</key>
                        <value>Uni Zürich - Asien-Orient Institute - Indologische Bibliothek</value>
                    </entry>
                    <entry>
                        <key>en</key>
                        <value>Uni Zürich - Asien-Orient Institute - Indologische Bibliothek</value>
                    </entry>
                    <entry>
                        <key>nl</key>
                        <value></value>
                    </entry>
                </translations>
            </translation>
            <treeLeaf>
                <rootId>3</rootId>
                <sort>0</sort>
                <treeNodeId>79</treeNodeId>
                <valueId>1863</valueId>
            </treeLeaf>
            <type>2</type>
            <url>http://biblio.unizh.ch/F?func=item-global&doc_library=UZH01&doc_number=<<RecordID>>&sub_library=UINDO</url>
            <zipCode>8001</zipCode>
        </library>
        <library>
            <addressURL>http://www.ville-fribourg.ch/vfr/fr/pub/officielle/admin_generale/archives.htm</addressURL>
            <adminDatabase> </adminDatabase>
            <designator>true</designator>
            <favorite>true</favorite>
            <favoriteQueryString>9902="R1089"</favoriteQueryString>
            <id>1078</id>
            <institutionURL> </institutionURL>
            <libraryGroupIdentifier>RERO</libraryGroupIdentifier>
            <libraryIdentifier>10890000</libraryIdentifier>
            <libraryIdentifierMatcher>R1089</libraryIdentifierMatcher>
            <name>10890000</name>
            <reroSubGroup>R1</reroSubGroup>
            <road>Rue des Chanoines 1</road>
            <sort>0</sort>
            <town>Fribourg</town>
            <translation>
                <designator>TP_PARAMETER_[1078,0]</designator>
                <groupId>655</groupId>
                <translations>
                    <entry>
                        <key>de</key>
                        <value>Archives de la Ville de Fribourg</value>
                    </entry>
                    <entry>
                        <key>it</key>
                        <value>Archives de la Ville de Fribourg</value>
                    </entry>
                    <entry>
                        <key>fr</key>
                        <value>Archives de la Ville de Fribourg</value>
                    </entry>
                    <entry>
                        <key>en</key>
                        <value>Archives de la Ville de Fribourg</value>
                    </entry>
                    <entry>
                        <key>nl</key>
                        <value>Archives de la Ville de Fribourg</value>
                    </entry>
                </translations>
            </translation>
            <treeLeaf>
                <rootId>3</rootId>
                <sort>28</sort>
                <treeNodeId>76</treeNodeId>
                <valueId>1078</valueId>
            </treeLeaf>
            <type>2</type>
            <url>http://opac.rero.ch/gateway?beginsrch=1&lng=<<Language>>&inst=<<Institution>>&search=KEYWORD&function=INITREQ&t1=<<RecordID>>&u1=12101&floc=<<SubLibraryFilter>>&fltset=submsn</url>
            <zipCode>1701</zipCode>
        </library>
        <library>
            <addressURL>http://www.musees-neuchatelois.ch/lieux/la-chaux-de-fonds/musee-international-dhorlogerie</addressURL>
            <adminDatabase> </adminDatabase>
            <designator>true</designator>
            <favorite>true</favorite>
            <favoriteQueryString>9902="R31083"</favoriteQueryString>
            <id>1820</id>
            <institutionURL> </institutionURL>
            <libraryGroupIdentifier>RERO</libraryGroupIdentifier>
            <libraryIdentifier>310830000</libraryIdentifier>
            <libraryIdentifierMatcher>R31083</libraryIdentifierMatcher>
            <name>310830000</name>
            <reroSubGroup>R31</reroSubGroup>
            <road>Rue des Musées 29</road>
            <sort>568</sort>
            <town>La Chaux-de-Fonds</town>
            <translation>
                <designator>TP_PARAMETER_[1820,0]</designator>
                <groupId>655</groupId>
                <translations>
                    <entry>
                        <key>de</key>
                        <value>Musée international de l'horlogerie, La Chaux-de-Fonds</value>
                    </entry>
                    <entry>
                        <key>it</key>
                        <value>Musée international de l'horlogerie, La Chaux-de-Fonds</value>
                    </entry>
                    <entry>
                        <key>fr</key>
                        <value>Musée international de l'horlogerie, La Chaux-de-Fonds</value>
                    </entry>
                    <entry>
                        <key>en</key>
                        <value>Musée international de l'horlogerie, La Chaux-de-Fonds</value>
                    </entry>
                    <entry>
                        <key>nl</key>
                        <value>Musée international de l'horlogerie, La Chaux-de-Fonds</value>
                    </entry>
                </translations>
            </translation>
            <treeLeaf>
                <rootId>3</rootId>
                <sort>246</sort>
                <treeNodeId>76</treeNodeId>
                <valueId>1820</valueId>
            </treeLeaf>
            <type>2</type>
            <url>http://opac.rero.ch/gateway?beginsrch=1&lng=<<Language>>&inst=<<Institution>>&search=KEYWORD&function=INITREQ&t1=<<RecordID>>&u1=12101&floc=<<SubLibraryFilter>>&fltset=submsn</url>
            <zipCode>2300</zipCode>
        </library>
        <library>
            <addressURL>http://www.musees-neuchatelois.ch/lieux/la-chaux-de-fonds/musee-dhistoire-naturelle</addressURL>
            <adminDatabase> </adminDatabase>
            <designator>true</designator>
            <favorite>true</favorite>
            <favoriteQueryString>9902="R31084"</favoriteQueryString>
            <id>1521</id>
            <institutionURL> </institutionURL>
            <libraryGroupIdentifier>RERO</libraryGroupIdentifier>
            <libraryIdentifier>310840000</libraryIdentifier>
            <libraryIdentifierMatcher>R31084</libraryIdentifierMatcher>
            <name>310840000</name>
            <reroSubGroup>R31</reroSubGroup>
            <road>Avenue Léopold-Robert 63</road>
            <sort>569</sort>
            <town>La Chaux-de-Fonds</town>
            <translation>
                <designator>TP_PARAMETER_[1521,0]</designator>
                <groupId>655</groupId>
                <translations>
                    <entry>
                        <key>de</key>
                        <value>Musée d'histoire naturelle, La Chaux-de-Fonds</value>
                    </entry>
                    <entry>
                        <key>it</key>
                        <value>Musée d'histoire naturelle, La Chaux-de-Fonds</value>
                    </entry>
                    <entry>
                        <key>fr</key>
                        <value>Musée d'histoire naturelle, La Chaux-de-Fonds</value>
                    </entry>
                    <entry>
                        <key>en</key>
                        <value>Musée d'histoire naturelle, La Chaux-de-Fonds</value>
                    </entry>
                    <entry>
                        <key>nl</key>
                        <value>Musée d'histoire naturelle, La Chaux-de-Fonds</value>
                    </entry>
                </translations>
            </translation>
            <treeLeaf>
                <rootId>3</rootId>
                <sort>103</sort>
                <treeNodeId>76</treeNodeId>
                <valueId>1521</valueId>
            </treeLeaf>
            <type>2</type>
            <url>http://opac.rero.ch/gateway?beginsrch=1&lng=<<Language>>&inst=<<Institution>>&search=KEYWORD&function=INITREQ&t1=<<RecordID>>&u1=12101&floc=<<SubLibraryFilter>>&fltset=submsn</url>
            <zipCode>2300</zipCode>
        </library>
 <library>
            <addressURL>http://www.infodoc-radix.ch/</addressURL>
            <adminDatabase>EAD50</adminDatabase>
            <designator>true</designator>
            <favorite>true</favorite>
            <favoriteQueryString>9902="E88"</favoriteQueryString>
            <id>1175</id>
            <institutionURL> </institutionURL>
            <libraryGroupIdentifier>EBI01</libraryGroupIdentifier>
            <libraryIdentifier>E88</libraryIdentifier>
            <libraryIdentifierMatcher> </libraryIdentifierMatcher>
            <name>E88</name>
            <reroSubGroup> </reroSubGroup>
            <road>Stampfenbachstrasse 161</road>
            <sort>427</sort>
            <town>Zürich</town>
            <translation>
                <designator>TP_PARAMETER_[1175,0]</designator>
                <groupId>655</groupId>
                <translations>
                    <entry>
                        <key>de</key>
                        <value>infoDoc RADIX, Zürich</value>
                    </entry>
                    <entry>
                        <key>it</key>
                        <value>infoDoc RADIX, Zürich</value>
                    </entry>
                    <entry>
                        <key>fr</key>
                        <value>infoDoc RADIX, Zürich</value>
                    </entry>
                    <entry>
                        <key>en</key>
                        <value>infoDoc RADIX, Zürich</value>
                    </entry>
                    <entry>
                        <key>nl</key>
                        <value>infoDoc RADIX, Zürich</value>
                    </entry>
                </translations>
            </translation>
            <treeLeaf>
                <rootId>3</rootId>
                <sort>21</sort>
                <treeNodeId>75</treeNodeId>
                <valueId>1175</valueId>
            </treeLeaf>
            <type>2</type>
            <url>http://opac.nebis.ch/F?func=item-global&doc_library=EBI01&doc_number=<<RecordID>>&sub_library=E88</url>
            <zipCode>8006</zipCode>
        </library>
    </libraries>
</libraryconfiguration> 



RE: A-Z list links (qid=1328351 cont.)

(OP)
XSL:

CODE -->

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" encoding="utf-8" indent="yes" />
    <xsl:param name="datestring" />

    <xsl:template match="/">
    <xsl:text disable-output-escaping='yes'><!DOCTYPE html></xsl:text>
        <html lang="de">
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    <title>Bibliotheken in swissbib</title>
                <link href="libstyle.css" rel="stylesheet" />
            </head> 
        <body>
        <div class="full_wrapper">
            
        <div class="title_wrapper">
               <h1 class="title">Bibliotheken in <xsl:element name="a"><xsl:attribute name="href">..</xsl:attribute>swissbib
                 </xsl:element></h1>
            
            <p>
                <xsl:if test="$datestring != ''">
                    <xsl:value-of select="concat('Stand: ',$datestring)"/>
                </xsl:if>
            </p>
            
              <p>  <xsl:element name="a">
                <xsl:attribute name="href">codelist.html</xsl:attribute>
                nach Codes sortieren
            </xsl:element>
            </p>
            
        </div>
            
        <div class="list_wrapper">
            <xsl:for-each select="//library">
           <xsl:sort select="translate(normalize-space(translation/translations/entry/value),'abcdefghijklmnopqrstuvwxyzäöüéèàç','ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
                <div class="library">
                    
                <span class="libname">
                        <xsl:value-of select="normalize-space(translation/translations/entry/value)"/>
                    </span>
                    
                          <span class="rowtitle"><br /> </span>
                    <span class="address"><xsl:value-of select="translate(road,'"','')"/></span>
                    <span class="rowtitle">, </span>
                    <span class="rowvontent">
                        <xsl:value-of select="zipCode"/><xsl:text> </xsl:text><xsl:value-of select="town" />
                    </span>
                    <span class="rowtitle"><br /></span>
                    
                  
                    <span class="bibinfo">
                        <xsl:if test="normalize-space(addressURL) != ''">
                            <xsl:element name="a">
                                <xsl:attribute name="href"><xsl:value-of select="normalize-space(addressURL)"/></xsl:attribute>
                                Bibliotheksinfo
                                <xsl:choose>
                                    <xsl:when test="libraryIdentifierMatcher != ' '">
                                        <xsl:value-of select="libraryIdentifierMatcher"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="name"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:element>
                        </xsl:if>
                    </span>
                    
                    <span class="rowtitle"><br /></span>
             
                    <span class="bibinfo">
                         <xsl:element name="a">
                                <xsl:choose>
                                    <xsl:when test="libraryIdentifierMatcher != ' '">
                                <xsl:element name="a"><xsl:attribute name="href">http://www.swissbib.ch/TouchPoint/start.do?Query=1805="<xsl:value-of select="libraryIdentifierMatcher"/>"</xsl:attribute>
                                            Bestand
                                        </xsl:element>
                                      </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:element name="a"><xsl:attribute name="href">http://www.swissbib.ch/TouchPoint/start.do?Query=1805="<xsl:value-of select="name"/>"</xsl:attribute>
                                            Bestand
                                        </xsl:element>               
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:element>
                    </span>
                </div>
            </xsl:for-each>
        </div>
    </div>
</body>
</html>
</xsl:template>
</xsl:stylesheet> 

RE: A-Z list links (qid=1328351 cont.)

(OP)
ps: the XSLT has a part <librarygroups> </librarygroups> before <libraries> </libraries>, but that's not used in my output.

RE: A-Z list links (qid=1328351 cont.)

(OP)
and the css. the fonts weren't my idea ;)

CODE -->

.full_wrapper {
	font-size: 80%;
	font-family:Arial, Helvetica, sans-serif;
	color:#494E59;
	word-wrap:break-word; 
}
  
 
  h1, h2, h3, h4, h5, h6 {
	font-family: "Times New Roman", Times, serif; 
	font-weight:bold;
	color:#2F333C;
}

  a {
	text-decoration:none;
	color:#1e9e00;
        }

 a:hover {
       	background-color:#D4F2CE;
	color:#0f5200;
	}

 a:visited {
	text-decoration:none;
	color:#146b00;
}

     
     .title_wrapper { 
       padding-top:0.3em;
       padding-left:1.5em;         
    }
    
      .list_wrapper { 
       padding-left:2.5em;  
       padding-bottom:1.5em;  
          }
    
     .library { 
       padding-top:1em;
       padding-right:0.3em;
          }
    
    .code { 
      padding-right:1em;
              }
    
    .libname { 
       font-weight:bold;
      padding-top:0.5em;
                   }
    
    .rowtitle { 
        padding-top:1em;
     }
    .rowcontent  { 
       padding-top:1em;
          } 
    
     .address { 
       padding-left:2em;
         }      
    
    .bibinfo { 
       padding-left:2em;
         } 

RE: A-Z list links (qid=1328351 cont.)

Ok, I have had a look at your posts.

Yor XSLT has exactly one sort in it, so lets look at it.

CODE -->

<xsl:for-each select="//library">
           <xsl:sort select="translate(normalize-space(translation/translations/entry/value),'abcdefghijklmnopqrstuvwxyzäöüéèàç','ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/> 

The xsl:for-each is going to iterate over the set of <library> nodes. The problem you may be having is that there are multiple translation/translations/entry/value nodes subordinate to each <library> node. Which one do you want to use for determining the sort order? Perhaps you would like to use the one whose language is 'de' rather than the first <value>, in which case you might want to use an XPath expression such as:

CODE

translation/translations/entry[key='de']/value 

Or maybe I am still not understanding what you are asking... ponder What in particular is wrong with your output?

Tom Morrison
Micro Focus

RE: A-Z list links (qid=1328351 cont.)

(OP)
Nothing wrong with my output as it is, but I would like to introduce an jump navigation (is that the term?), so that I could jump directly to the names that begin with the letter U, for example, instead of having to scroll down: example.

I thought this was what thread 1328351 was solving but maybe I got that wrong?

RE: A-Z list links (qid=1328351 cont.)

You are correct, that is what that thread (and therefore this thread) is about.

And I understand now what I need to show you. Unfortunately, Thursday is my busiest day, especially in the morning (USA time).

I will return - probably today - with your solution.

Tom Morrison
Micro Focus

RE: A-Z list links (qid=1328351 cont.)

(OP)
No hurry. And thank you! smile

RE: A-Z list links (qid=1328351 cont.)

Here is a solution, which you should study and if not clear to you, ask questions.

I moved the formatting of an individual library into a called template, so that the link generation logic is more obvious.

I would suggest also that you use the xsl:output mechanism for output of the DOCTYPE declaration. I have chosen HTML 4.01 strict for the DOCTYPE; adjust as you see fit.

My technique outputs navigation links only for those letters that actually appear in the data. If you want a list of all letters, then a slightly different technique will be needed, and you need to decide whether there will be href values for all the letters, or whether only those letters that exist in the data will have href values.

Let me know how this works for you...

CODE --> XSLT

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" encoding="utf-8" indent="yes" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN"/>

    <xsl:param name="datestring" />

	<xsl:key name="libFirstChar" match="library" 
	                             use="translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
								                'abcdefghijklmnopqrstuvwxyzäöüéèàç',
									            'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>

    <xsl:template match="/">
        <html lang="de">
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    <title>Bibliotheken in swissbib</title>
                <link href="libstyle.css" rel="stylesheet" />
            </head> 
        <body>
        <div class="full_wrapper">
            
        <div class="title_wrapper">
               <h1 class="title">Bibliotheken in <xsl:element name="a"><xsl:attribute name="href">..</xsl:attribute>swissbib
                 </xsl:element></h1>
            
            <p>
                <xsl:if test="$datestring != ''">
                    <xsl:value-of select="concat('Stand: ',$datestring)"/>
                </xsl:if>
            </p>
            
              <p>  <xsl:element name="a">
                <xsl:attribute name="href">codelist.html</xsl:attribute>
                nach Codes sortieren
            </xsl:element>
            </p>
            
        </div>
            
        <div class="list_wrapper">
		   <!-- iterate over the first node for each starting character -->
		   <xsl:for-each select="//library[generate-id(.)=generate-id(key('libFirstChar', 
                                                                          translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
			                                                                        'abcdefghijklmnopqrstuvwxyzäöüéèàç',
                                                                                    'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC'))[1])]">
		   <xsl:sort select="translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
			                          'abcdefghijklmnopqrstuvwxyzäöüéèàç',
                                      'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
           <!-- we are now in the context of a <library> node -->
           <xsl:variable name="myFirstChar" select="translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
                                                              'abcdefghijklmnopqrstuvwxyzäöüéèàç',
                                                              'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>

           <!-- output the links -->
           <xsl:call-template name="genLinks"/>
           <xsl:element name="a"><xsl:attribute name="name"><xsl:value-of select="string($myFirstChar)"/></xsl:attribute></xsl:element>
           <!-- Now iterate over all the <library> nodes that start with the same character sort value -->
		   <xsl:for-each select="key('libFirstChar',$myFirstChar)">
		   <!-- sort all the <library> nodes in this result set by their full <value> (we know they all start with the same first letter) -->
               <xsl:sort select="translate(normalize-space(translation/translations/entry/value),
                                           'abcdefghijklmnopqrstuvwxyzäöüéèàç',
                                           'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
                   <xsl:call-template name="outputLibrary"/>
               </xsl:for-each>
           </xsl:for-each>
           <xsl:call-template name="genLinks"/>
        </div>
    </div>
</body>
</html>
</xsl:template>

<xsl:template name="genLinks">
        <span>
        <!-- The for-each will iterate exactly once for each unique initial letter. -->
        <xsl:for-each select="//library[generate-id(.)=generate-id(key('libFirstChar', 
                                                                          translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
			                                                                        'abcdefghijklmnopqrstuvwxyzäöüéèàç',
                                                                                    'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC'))[1])]">
            <xsl:sort select="translate(normalize-space(translation/translations/entry/value),
                                           'abcdefghijklmnopqrstuvwxyzäöüéèàç',
                                           'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>
            <xsl:variable name="myLinkChar" select="translate(substring(normalize-space(translation/translations/entry/value[1]),1,1),
                                                              'abcdefghijklmnopqrstuvwxyzäöüéèàç',
                                                              'ABCDEFGHIJKLMNOPQRSTUVWXYZAOUEEAC')"/>

            <a><xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="$myLinkChar"/></xsl:attribute>
               <xsl:value-of select="$myLinkChar"/></a>
               <xsl:if test="position()!=last()"><xsl:text>-</xsl:text></xsl:if>
        </xsl:for-each>
        </span>
</xsl:template>

<xsl:template name="outputLibrary">
                <div class="library">
                    
                <span class="libname">
                        <xsl:value-of select="normalize-space(translation/translations/entry/value)"/>
                    </span>
                    
                          <span class="rowtitle"><br /> </span>
                    <span class="address"><xsl:value-of select="translate(road,'"','')"/></span>
                    <span class="rowtitle">, </span>
                    <span class="rowvontent">
                        <xsl:value-of select="zipCode"/><xsl:text> </xsl:text><xsl:value-of select="town" />
                    </span>
                    <span class="rowtitle"><br /></span>
                    
                  
                    <span class="bibinfo">
                        <xsl:if test="normalize-space(addressURL) != ''">
                            <xsl:element name="a">
                                <xsl:attribute name="href"><xsl:value-of select="normalize-space(addressURL)"/></xsl:attribute>
                                Bibliotheksinfo
                                <xsl:choose>
                                    <xsl:when test="libraryIdentifierMatcher != ' '">
                                        <xsl:value-of select="libraryIdentifierMatcher"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="name"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:element>
                        </xsl:if>
                    </span>
                    
                    <span class="rowtitle"><br /></span>
             
                    <span class="bibinfo">
                         <xsl:element name="a">
                                <xsl:choose>
                                    <xsl:when test="libraryIdentifierMatcher != ' '">
                                <xsl:element name="a"><xsl:attribute name="href">http://www.swissbib.ch/TouchPoint/start.do?Query=1805="<xsl:value-of select="libraryIdentifierMatcher"/>"</xsl:attribute>
                                            Bestand
                                        </xsl:element>
                                      </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:element name="a"><xsl:attribute name="href">http://www.swissbib.ch/TouchPoint/start.do?Query=1805="<xsl:value-of select="name"/>"</xsl:attribute>
                                            Bestand
                                        </xsl:element>               
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:element>
                    </span>
                </div>
</xsl:template>

</xsl:stylesheet> 

Tom Morrison
Micro Focus

RE: A-Z list links (qid=1328351 cont.)

(OP)
It works! big smile

Copying the code here had turned ..."translate(road,'&quot;','')" to ..."translate(road,'"','')"

but I can't see a way to edit a post.

I added a <br /> after <xsl:template name="genLinks">, now it looks great. Will be online soon.

I think all the keywords are covered, so others also have a chance of finding this.

Thank you again, this is exactly what I was looking for.

RE: A-Z list links (qid=1328351 cont.)

Yes I had the same problem with that same line when I copied your code into my XSLT debugger. It was correct going into the post. Such is the problem of trying to process XML through a complex system. I am on the 'advisory board' for Tek-Tips, so I will report this problem to the technical guys.

And, by the way, welcome to Tek-Tips!

Tom Morrison
Micro Focus

RE: A-Z list links (qid=1328351 cont.)

It looks like you can code an:
&amp;quot;
inside the code box.

Here is an attempt:

CODE --> XML

<anelement attrib="&quot;"/> 

It works on the preview. Pressing Submit Post button...

Tom Morrison
Micro Focus

RE: A-Z list links (qid=1328351 cont.)

(OP)
> welcome
Thank you. I'm glad i found it.

> I am on the 'advisory board'
Could you advise them to introduce an edit button?

RE: A-Z list links (qid=1328351 cont.)

Quote (meandering)

Could you advise them to introduce an edit button?

That is on the list of desired features. Not too close to the top of the list, though.

Tom Morrison
Micro Focus

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close