Project

Profile

Help

How to connect?
Download (14.1 KB) Statistics
| Branch: | Revision:

he / tools / make-menu.xsl @ 5d25f10d

1
<!-- Stylesheet to be executed client-side to supply the navigation menu in each page -->
2

    
3
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4

    
5
  <xsl:variable name="homepage" select="'../welcome/welcome.xml'"/>
6
  
7
  <xsl:variable name="contents-doc" select="document('../src/userdoc/contents.xml')"/>
8

    
9
  <xsl:template match="*">
10
    <xsl:copy>
11
      <xsl:copy-of select="@*"/>
12
      <xsl:apply-templates/>
13
    </xsl:copy>
14
  </xsl:template>
15

    
16
  <!-- Used to insert Saxon version information - e.g. current-maintenance-release on download_page -->
17
  <xsl:template match="insert">
18
    <xsl:value-of select="document('../src/userdoc/contents.xml')
19
                            //constant[@name=current()/@name]/@value"/>
20
  </xsl:template>
21

    
22
  <!-- Used on Client testimonials page -->
23
  <xsl:template match="div[@style='multi-column']">
24
    <table class="client-table">
25
      <tr>
26
        <xsl:apply-templates/>
27
      </tr>
28
    </table>
29
  </xsl:template>
30
  <xsl:template match="div[@style='multi-column']/div">
31
    <td>
32
      <xsl:copy-of select="@*"/>
33
      <xsl:apply-templates/>
34
    </td>
35
  </xsl:template>
36

    
37
  <!-- Don't copy over 'this-is' elements -->
38
  <xsl:template match="this-is"/>
39

    
40
  <!-- Ignore certain sections unless in correct mode -->
41
  <xsl:template match="div[@id='aside']"/>
42
  <xsl:template match="div[@id='fixed-aside']"/>
43
  <xsl:template match="div[@id='fullpage']"/>
44

    
45
  <!-- Make mail link - on Evaluation License page -->
46
  <xsl:template match="email">
47
    <a class="bodylink" href="mailto:{@address}">
48
      <xsl:value-of select="@title"/>
49
    </a>
50
  </xsl:template>
51

    
52

    
53
  <!-- Page formating - if window is smaller than fixed page width, then ensure whole page is scrollable
54
  i.e. no fixed top nav bar, etc. -->
55
  <xsl:template match="head">
56
    <head>
57
      <xsl:copy-of select="node()"/>
58
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
59
      <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"
60
        rel="stylesheet"/>      
61
      <link rel="stylesheet" href="../saxondocs.css?v=1.7" type="text/css"></link>  
62

    
63
      <script type="text/javascript">
64
        function getWidth() {
65
        if (self.innerHeight) {
66
        return self.innerWidth;
67
        }
68
        
69
        if (document.documentElement &amp;&amp; document.documentElement.clientHeight) {
70
        return document.documentElement.clientWidth;
71
        }
72
        
73
        if (document.body) {
74
        return document.body.clientWidth;
75
        }
76
        }
77
       
78
       function header_fixed_or_not(){
79
        //window.alert(getWidth());       
80
        if (getWidth() &lt; $("#wrapper").width()){
81
        //document.getElementById("header-container").style.position = "static";
82
        //document.getElementById("content-container").style.padding = "12px 0 0 0";
83
        $("#header-container").css("position", "static");
84
        $("#header-container").css("height", "auto");
85
        $("#content-container").css("padding", "0 0 0 0");
86
        $("a.anchor").css("top", "-20px");
87
        //window.alert("window sizing - static");
88
        }
89
        else{
90
        //document.getElementById("header-container").style.position = "fixed";
91
        //document.getElementById("content-container").style.padding = "112px 0 0 0";
92
        $("#header-container").css("position", "fixed");
93
        $("#header-container").css("height", "110px");
94
        $("#content-container").css("padding", "110px 0 0 0");
95
        $("a.anchor").css("top", "-120px");
96
        //window.alert("window sizing - fixed");
97
        }        
98
        }
99
        
100
        function header_size(){
101
        var headerHeight = document.getElementById("header-nav-container").clientHeight;
102
        if (headerHeight &gt; 110 &amp;&amp; getWidth() &gt; $("#wrapper").width()){
103
        $("#content-container").css("padding-top", headerHeight);
104
        $("a.anchor").css("top", -headerHeight);
105
        //window.alert("header nav sizing");
106
        }
107
        }
108
      </script>
109

    
110
      <script type="text/javascript">
111
  var _gaq = _gaq || [];
112
  _gaq.push(["_setAccount", "UA-38837694-1"]);
113
  _gaq.push(["_trackPageview"]);
114

    
115
  (function() {
116
    var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
117
    ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") +
118
    ".google-analytics.com/ga.js";
119
    var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
120
  })();
121
      </script>
122

    
123
    </head>
124
  </xsl:template>
125

    
126
  <xsl:template match="body">
127
    <body onload="header_fixed_or_not(), header_size()" onresize="header_fixed_or_not(), header_size()">
128
      <xsl:copy-of select="@*"/>
129
      <div id="wrapper">
130
        
131
          <div id="header-container">
132
            <div id="header-nav-container">
133
          <div id="header">
134
            <div class="header-saxonica-logo">
135
              <a href="{$homepage}">
136
                <img src="../img/logo_crop-mid-blue-background.gif" width="260" height="55"
137
                  border="0" hspace="10px" alt="saxonica.com"/>
138
              </a>
139
            </div>
140
            <div class="social-media">
141
              <a href="https://saxonica.plan.io/" title="Saxonica forum">
142
                <i class="fa fa-comments-o fa-2x"/>
143
              </a>
144
              <a href="mailto:saxon-orders@saxonica.com" title="Email us">
145
                <i class="fa fa-envelope-square fa-2x"/>
146
              </a>
147
              <a href="https://www.linkedin.com/company/saxonica-ltd" title="LinkedIn">
148
                <i class="fa fa-linkedin-square fa-2x"/>
149
              </a>
150
              <a href="https://twitter.com/michaelhkay" title="Michael Kay's twitter">
151
                <i class="fa fa-twitter-square fa-2x"/>
152
              </a>
153
              <a href="http://dev.saxonica.com/blog/" title="Saxonica blogs">
154
                <i class="fa fa-bullhorn fa-2x"/>
155
              </a>
156
            </div>            
157
          </div>
158
          <xsl:apply-templates mode="menu-area" select="."/>
159
          <!--<div style="clear:both"/>   -->         
160
            </div>
161
           <xsl:apply-templates mode="fixed-aside-area" select="./div[@id='fixed-aside']"/>
162
        </div>
163

    
164
        <div class="content-cont" id="content-container">
165
          <a id="top" class="anchor"/>
166
          <xsl:if test="not(./div[@id='fullpage']) and not(./div[@id='section'])">
167
            <div id="section">
168
              <xsl:apply-templates/>
169
            </div>
170
          </xsl:if>
171
          <xsl:apply-templates mode="page-content" select="./div[@id='fullpage']"/>
172
          <xsl:apply-templates mode="page-content" select="./div[@id='section']"/>
173
          <xsl:apply-templates mode="aside-content" select="./div[@id='aside']"/>
174
          <div id="footer">
175
            <p>&#169; 2020 Saxonica</p>
176
          </div>
177
        </div>
178

    
179
      </div>
180
    </body>
181
  </xsl:template>
182

    
183
  <xsl:template match="div[@id='section' or @id='fullpage']" mode="page-content">
184
    <xsl:copy>
185
      <xsl:copy-of select="@*"/>
186
      <xsl:apply-templates/>
187
    </xsl:copy>
188
  </xsl:template>
189

    
190
  <xsl:template match="div[@id='aside']" mode="aside-content">
191
    <div id="aside" class="aside">
192
      <xsl:apply-templates/>
193
    </div>
194
  </xsl:template>
195

    
196
  <xsl:template match="div[@id='fixed-aside']" mode="fixed-aside-area">
197
    <div id="fixed-aside" class="aside">
198
      <xsl:apply-templates/>
199
    </div>
200
  </xsl:template> 
201
  
202
  <xsl:template match="div[@id='sitemap']">
203
    <xsl:param name="extension" select="'xml'"/>
204
    <table class="sitemap-table">
205
      <xsl:for-each select="$contents-doc/*/section | $contents-doc/*/home">
206
        <tr>
207
          <td class="col1">
208
            <ul>
209
              <li><a href="../{@folder}/{@name}.{$extension}" class="block-link"><xsl:value-of
210
              select="@title"/></a></li>
211
            </ul>
212
          </td>
213
          <td>
214
            <table>
215
              <tr>
216
                <xsl:for-each select="page">
217
                  <td>
218
                    <ul>
219
                      <li>
220
                        <xsl:if test="@name">
221
                          <a href="../{@folder}/{@name}.{$extension}">
222
                            <xsl:value-of select="@title"/>
223
                          </a>
224
                        </xsl:if>
225
                        <xsl:if test="@href">
226
                          <a href="{@href}">
227
                            <xsl:value-of select="@title"/>
228
                          </a>
229
                        </xsl:if>
230
                      </li>
231
                      <xsl:for-each select="subpage[@name != 'download_asp' and @name != 'php_api']">
232
                        <li>
233
                          <xsl:if test="@name">
234
                            <a href="../{@folder}/{@name}.{$extension}">
235
                              <xsl:value-of select="@title"/>
236
                            </a>
237
                          </xsl:if>
238
                          <xsl:if test="@href">
239
                            <a href="{@href}">
240
                              <xsl:value-of select="@title"/>
241
                            </a>
242
                          </xsl:if>
243
                        </li>
244
                      </xsl:for-each>
245
                    </ul>
246
                  </td>
247
                </xsl:for-each>
248
              </tr>
249
            </table>
250
          </td>
251
        </tr>
252
      </xsl:for-each>
253
    </table>
254
  </xsl:template>
255
  
256
  <xsl:template mode="menu-area" match="*">
257
    <xsl:param name="extension" select="'xml'"/>
258
    <xsl:variable name="this-page" select="(//this-is)[1]"/>
259
    <xsl:variable name="this-folder">
260
      <xsl:choose>
261
        <xsl:when test="$this-page/@folder">
262
          <xsl:value-of select="$this-page/@folder"/>
263
        </xsl:when>
264
        <xsl:otherwise>
265
          <xsl:value-of select="$this-page/@section"/>
266
        </xsl:otherwise>
267
      </xsl:choose>
268
    </xsl:variable>
269

    
270
    <ul class="nav">
271
      <xsl:for-each select="$contents-doc/*/section">
272
        <xsl:choose>
273
          <xsl:when test="./@folder = 'sitemap'">
274
            <li class="float-right">
275
              <a href="../{@folder}/{@name}.{$extension}">
276
                <xsl:if test="./@folder = $this-page/@section">
277
                  <xsl:attribute name="id">thispage</xsl:attribute>
278
                </xsl:if>
279
                <xsl:attribute name="class">sitemap</xsl:attribute>
280
                <xsl:value-of select="@title"/>
281
              </a>
282
            </li>
283
          </xsl:when>
284
          <xsl:otherwise>
285
            <li>
286
              <a href="../{@folder}/{@name}.{$extension}">
287
                <xsl:if test="./@folder = $this-page/@section">
288
                  <xsl:attribute name="id">thispage</xsl:attribute>
289
                </xsl:if>
290
                <xsl:value-of select="@title"/>
291
              </a>
292
              <!-- drop down menus -->
293
              <ul>
294
                <xsl:for-each select="page">
295
                  <xsl:if test="@name">
296
                    <li>
297
                      <a href="../{@folder}/{@name}.{$extension}">
298
                        <xsl:value-of select="@title"/>
299
                      </a>
300
                    </li>
301
                  </xsl:if>
302
                  <xsl:if test="@href">
303
                    <li>
304
                      <a href="{@href}">
305
                        <xsl:value-of select="@title"/>
306
                      </a>
307
                    </li>
308
                  </xsl:if>
309
                </xsl:for-each>
310
              </ul>
311
            </li>
312
          </xsl:otherwise>
313
        </xsl:choose>
314
      </xsl:for-each>
315
    </ul>
316
    
317
    <div id="breadcrumbs-submenu-container">
318
    <div id="breadcrumbs">
319
      <xsl:variable name="place-in-contents" 
320
        select="$contents-doc//section[(@folder = $this-folder and @name = $this-page/@page and $this-page/@subpage='')]|
321
        $contents-doc//page[(@folder = $this-folder and @name = $this-page/@page and $this-page/@subpage='')]|        
322
        $contents-doc//subpage[(@folder = $this-folder and @name = $this-page/@subpage)]"/>
323
      <p>
324
        <a href="{$homepage}">SAXONICA</a>
325
        <xsl:text> > </xsl:text>
326
        <xsl:if test="$this-page/@section = 'welcome'">          
327
          <a href="{$homepage}">Welcome</a>
328
        </xsl:if>      
329
        <xsl:for-each select="$place-in-contents/ancestor-or-self::*[not(self::contents)]">
330
          <xsl:if test="self::section | self::page | self::subpage[not(@name = 'download_asp')]">
331
            <a href="../{@folder}/{@name}.{$extension}">
332
              <xsl:value-of select="@title"/></a>
333
          </xsl:if>
334
          <xsl:if test="self::subpage[@name = 'download_asp']">
335
            <xsl:value-of select="@title"/>
336
          </xsl:if>
337
          <xsl:if test="not(position()=last())">
338
            <xsl:text> > </xsl:text>
339
          </xsl:if>
340
        </xsl:for-each>      
341
      </p>
342
    </div>        
343
   
344
    <xsl:variable name="section-in-contents"
345
      select="$contents-doc/*/section[@folder = $this-page/@section]"/>  
346
    
347
    <div id="submenu">
348
      <xsl:choose>
349
        <xsl:when test="$this-page/@section = 'welcome'">
350
          <p>&#160;</p>
351
        </xsl:when>
352
        <xsl:otherwise>
353
          <p class="align-right">
354
            <a href="../{$section-in-contents/@folder}/{$section-in-contents/@name}.{$extension}">
355
              <xsl:if
356
                test="$section-in-contents/@name = $this-page/@page and $section-in-contents/@folder = $this-folder">
357
                <xsl:attribute name="id">thispage</xsl:attribute>
358
              </xsl:if>
359
              <xsl:value-of select="$section-in-contents/@title"/>
360
            </a>
361
            <xsl:for-each select="$section-in-contents/page">
362
              <xsl:value-of select="' | '"/>
363
              <xsl:if test="@name">
364
                <a href="../{@folder}/{@name}.{$extension}">
365
                  <xsl:if test="./@name = $this-page/@page and ./@folder = $this-folder">
366
                    <xsl:attribute name="id">thispage</xsl:attribute>
367
                  </xsl:if>
368
                  <xsl:value-of select="@title"/>
369
                </a>
370
              </xsl:if>
371
              <xsl:if test="@href">
372
                <a href="{@href}">
373
                  <xsl:value-of select="@title"/>
374
                </a>
375
              </xsl:if>
376
            </xsl:for-each>
377
          </p>
378
        </xsl:otherwise>
379
      </xsl:choose>      
380
    </div>
381
      <div style="clear:both;"/>
382
    </div>
383
  </xsl:template>
384

    
385
</xsl:stylesheet>
(13-13/15)