comparison toolboxes/graph_visualisation/share/graphviz/doc/html/schema/attributes.xslt @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 <?xml version="1.0"?>
2 <xsl:stylesheet
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
5 xmlns="http://www.w3.org/1999/xhtml"
6 xmlns:gv="urn:graphviz"
7 version="1.0">
8
9 <xsl:output method="html" />
10
11 <xsl:variable name="arguments" select="document('arguments.xml')" />
12
13 <xsl:template match="/">
14 <html>
15 <head>
16 <title>Node, Edge and Graph Attributes</title>
17 <style>
18 body
19 {
20 margin: 0px;
21 padding: 0px;
22 overflow: hidden;
23
24 font-family: Georgia;
25 }
26
27 code
28 {
29 font-family: Courier;
30 }
31
32 a
33 {
34 text-decoration: none;
35 }
36
37 a:hover
38 {
39 text-decoration: underline;
40 }
41
42 #indices
43 {
44 position: absolute;
45 left: 0px;
46 width: 200px;
47 top: 0px;
48 bottom: 0px; /* IE doesn't use this */
49 height: expression(offsetParent.offsetHeight); /* only IE uses this */
50 overflow: auto;
51
52 background: #EEEEEE
53 }
54
55 #contents
56 {
57 position: absolute;
58 left: 210px;
59 right:0px; /* IE doesn't use this */
60 width: expression(offsetParent.offsetWidth-210); /* only IE uses this */
61 top: 0px;
62 bottom: 0px; /* IE doesn't use this */
63 height: expression(offsetParent.offsetHeight); /* only IE uses this */
64 overflow: auto;
65 }
66
67 .val
68 {
69 font-family: Courier;
70 color: green;
71 }
72
73 .attr
74 {
75 font-family: Courier;
76 font-weight: bold;
77 }
78
79 .comp
80 {
81 }
82
83 .layout
84 {
85 }
86
87 .format
88 {
89 }
90
91 .note
92 {
93 }
94
95 .missing
96 {
97 color: lightgray;
98 }
99
100 .heading
101 {
102 padding-left: 5px;
103 padding-right: 5px;
104 padding-top: 10px;
105 padding-bottom: 2px;
106
107 color: gray;
108 font-weight: bold;
109 font-size: 60%;
110 }
111
112 .text
113 {
114 padding-left: 20px;
115 padding-bottom: 10px;
116 padding-right: 10px;
117 }
118
119 .index
120 {
121 padding-left: 20px;
122 padding-right: 5px;
123 padding-top: 2px;
124 padding-bottom: 2px;
125
126 display: block;
127 font-size: 80%;
128
129 color: blue;
130 }
131
132 .index_selected
133 {
134 background: #8888FF;
135 color: white;
136 }
137
138 .content
139 {
140 display: none;
141 }
142
143 .content_selected
144 {
145 display: block;
146 }
147 </style>
148
149 <script>
150 <xsl:text disable-output-escaping="yes">
151 var lastSelected = null;
152
153 function addClass (element, newClass)
154 {
155 if (element)
156 {
157 var classes = element.className.split (" ");
158 for (var i = 0; i &lt; classes.length; ++i)
159 if (classes [i] == newClass)
160 break;
161
162 if (i == classes.length)
163 {
164 classes.push (newClass);
165 element.className = classes.join (" ");
166 }
167 }
168 }
169
170 function removeClass (element, oldClass)
171 {
172 if (element)
173 {
174 var classes = element.className.split (" ");
175 for (var i = 0; i &lt; classes.length; ++i)
176 if (classes [i] == oldClass)
177 {
178 classes.splice (i, 1);
179 element.className = classes.join (" ");
180 break;
181 }
182 }
183 }
184
185
186 function select (selected)
187 {
188 if (selected != lastSelected)
189 {
190 // deselect the last selection
191 if (lastSelected)
192 {
193 removeClass (document.getElementById ("index_" + lastSelected.replace (':', '_')), "index_selected");
194 removeClass (document.getElementById ("content_" + lastSelected.replace (':', '_')), "content_selected");
195 }
196
197 lastSelected = selected;
198
199 var selectedIndex = document.getElementById ("index_" + lastSelected.replace (':', '_'));
200 addClass (selectedIndex, "index_selected");
201
202 // ensure selected index is visible in indices source list
203 if (selectedIndex)
204 {
205 var indexTop = selectedIndex.offsetTop;
206 var indexBottom = indexTop + selectedIndex.offsetHeight;
207 var indicesTop = selectedIndex.offsetParent.scrollTop;
208 var indicesBottom = indicesTop + selectedIndex.offsetParent.offsetHeight;
209 if (indexBottom &lt; indicesTop || indexTop &gt; indicesBottom)
210 selectedIndex.scrollIntoView ();
211 }
212
213 // display the content associated with the selected index
214 addClass (document.getElementById ("content_" + lastSelected.replace (':', '_')), "content_selected");
215 }
216 return true;
217
218 }
219
220 function hashed ()
221 {
222 // check if we navigated to a new internal location e.g. via the back button
223 // if so we need to update the selection
224 // NOTE: this means there are no real anchors in the HTML at all, we're just simulating them
225 var hash = window.location.hash;
226 if (hash &amp;&amp; hash.charAt (0) == '#')
227 select (hash.substr (1));
228 else
229 select ("h:introduction");
230 return true;
231 }
232
233 function clicked (event)
234 {
235 // check to see if an internal link was clicked, if so we need to update the selection
236 // NOTE: this is not strictly necessary since hashed () will catch it but it helps with the responsiveness
237 var clickedElement = event.target;
238 if (!clickedElement)
239 clickedElement = event.srcElement;
240 switch (clickedElement.tagName)
241 {
242 case 'a':
243 case 'A':
244 var oldHref = window.location.href;
245 var oldHash = oldHref.indexOf ('#');
246 if (oldHash == -1)
247 oldHash = oldHref.length;
248
249 var newHref = clickedElement.href;
250 var newHash = newHref.indexOf ('#');
251 if (newHash == -1)
252 newHash = newHref.length;
253
254 if (oldHref.substr (0, oldHash) == newHref.substr (0, newHash))
255 {
256 if (newHash &lt; newHref.length)
257 select (newHref.substr (newHash + 1));
258 else
259 select ("h:introduction");
260 }
261 break;
262 }
263 return true;
264 }
265
266 function loaded ()
267 {
268 hashed ();
269 window.setInterval ("hashed ()", 1000);
270 return true;
271 }
272 </xsl:text>
273 </script>
274
275 </head>
276 <body onload="return loaded ()" onclick="return clicked (event)">
277 <div id="indices">
278
279 <!-- display all the attribute type names -->
280 <div class="heading">NOTES</div>
281 <xsl:for-each select="/xsd:schema/xsd:annotation[@id]">
282 <a id="index_h_{@id}" class="index note" href="#h:{@id}">
283 <xsl:value-of select="@id" />
284 </a>
285 </xsl:for-each>
286
287 <!-- display all the attribute names -->
288 <div class="heading">ATTRIBUTES</div>
289 <xsl:for-each select="/xsd:schema/xsd:attribute">
290 <a id="index_d_{@name}" class="index attr" href="#d:{@name}">
291 <xsl:value-of select="@name" />
292 </a>
293 </xsl:for-each>
294
295 <!-- display all the attribute type names -->
296 <div class="heading">TYPES</div>
297 <xsl:for-each select="/xsd:schema/xsd:simpleType">
298 <a id="index_k_{@name}" class="index type" href="#k:{@name}">
299 <xsl:value-of select="@name" />
300 </a>
301 </xsl:for-each>
302
303
304
305 </div>
306 <div id="contents">
307
308 <!-- note content -->
309 <xsl:for-each select="/xsd:schema/xsd:annotation[@id]">
310 <div id="content_h_{@id}" class="content">
311 <div class="text">
312 <xsl:apply-templates select="xsd:documentation/*" mode="html" />
313 </div>
314 </div>
315 </xsl:for-each>
316
317 <!-- attribute content -->
318 <xsl:for-each select="/xsd:schema/xsd:attribute">
319 <div id="content_d_{@name}" class="content">
320
321 <!-- display the layouts this attribute applies to -->
322 <div class="heading">LAYOUTS</div>
323 <div class="text">
324 <xsl:variable name="attributeLayouts" select="@gv:layouts" />
325 <xsl:for-each select="$arguments/xsd:schema/xsd:simpleType[@name='layout']/xsd:restriction/xsd:enumeration">
326 <span class="layout">
327 <xsl:attribute name="class">layout <xsl:if test="$attributeLayouts and not(contains(concat(' ',$attributeLayouts,' '),concat(' ',@value,' ')))">missing</xsl:if></xsl:attribute>
328 <xsl:value-of select="@value" />
329 </span>
330 <xsl:text> </xsl:text>
331 </xsl:for-each>
332 </div>
333
334 <!-- display the components this attribute is used by -->
335 <div class="heading">COMPONENTS</div>
336 <div class="text">
337 <xsl:variable name="attributeName" select="@name" />
338 <xsl:for-each select="/xsd:schema/xsd:complexType">
339 <span class="comp">
340 <xsl:attribute name="class">comp <xsl:if test="not(xsd:attribute[@ref=$attributeName])">missing</xsl:if></xsl:attribute>
341 <xsl:value-of select="@name" />
342 </span>
343 <xsl:text> </xsl:text>
344 </xsl:for-each>
345 </div>
346
347 <!-- display the formats this attribute can output -->
348 <div class="heading">FORMATS</div>
349 <div class="text">
350 <xsl:choose>
351 <xsl:when test="@gv:formats">
352 <span class="format"><xsl:value-of select="@gv:formats" /></span>
353 </xsl:when>
354 <xsl:otherwise>
355 <span class="format missing">all</span>
356 </xsl:otherwise>
357 </xsl:choose>
358 </div>
359
360 <!-- display the type of this attribute -->
361 <div class="heading">TYPE</div>
362 <div class="text">
363 <xsl:choose>
364 <xsl:when test="@type='xsd:anyURI'">
365 <span class="type">URL</span>
366 </xsl:when>
367 <xsl:when test="@type='xsd:boolean'">
368 <span class="type">bool</span>
369 </xsl:when>
370 <xsl:when test="@type='xsd:decimal'">
371 <span class="type">double</span>
372 </xsl:when>
373 <xsl:when test="@type='xsd:integer'">
374 <span class="type">int</span>
375 </xsl:when>
376 <xsl:when test="@type='xsd:string'">
377 <span class="type">string</span>
378 </xsl:when>
379 <xsl:when test="not(contains(@type,':'))">
380 <a class="type" href="#k:{@type}"><xsl:value-of select="@type" /></a>
381 </xsl:when>
382 </xsl:choose>
383 </div>
384
385 <!-- display the attribute default or none if missing -->
386 <div class="heading">DEFAULT</div>
387 <div class="text">
388 <xsl:choose>
389 <xsl:when test="@default">
390 <span class="val">
391 <xsl:value-of select="@default" />
392 </span>
393 </xsl:when>
394 <xsl:otherwise>
395 <span class="val missing">none</span>
396 </xsl:otherwise>
397 </xsl:choose>
398 </div>
399
400 <!-- display the description from the documentation bits -->
401 <div class="heading">DESCRIPTION</div>
402 <div class="text">
403 <xsl:apply-templates select="xsd:annotation/xsd:documentation/*" mode="html" />
404 </div>
405
406 </div>
407 </xsl:for-each>
408
409 <!-- attribute type content -->
410 <xsl:for-each select="/xsd:schema/xsd:simpleType">
411 <div id="content_k_{@name}" class="content">
412
413 <!-- display the values if this is an enumeration -->
414 <xsl:if test="xsd:restriction/xsd:enumeration">
415 <div class="heading">VALUES</div>
416 <div class="text">
417 <xsl:for-each select="xsd:restriction/xsd:enumeration">
418 <span class="val"><xsl:value-of select="@value" /></span>
419 <xsl:text> </xsl:text>
420 </xsl:for-each>
421 </div>
422 </xsl:if>
423
424 <!-- display the description from the documentation bits -->
425 <div class="heading">DESCRIPTION</div>
426 <div class="text">
427 <xsl:apply-templates select="xsd:annotation/xsd:documentation/*" mode="html" />
428 </div>
429 </div>
430 </xsl:for-each>
431
432
433
434 </div>
435 </body>
436 </html>
437 </xsl:template>
438
439
440
441
442 <xsl:template match="html:a[@rel='attr']" mode="html" xmlns:html="http://www.w3.org/1999/xhtml">
443 <a href="#d:{text()}" class="attr">
444 <xsl:apply-templates select="@*|node()" mode="html" />
445 </a>
446 </xsl:template>
447
448 <xsl:template match="html:a[@rel='type']" mode="html" xmlns:html="http://www.w3.org/1999/xhtml">
449 <a href="#k:{text()}" class="type">
450 <xsl:apply-templates select="@*|node()" mode="html" />
451 </a>
452 </xsl:template>
453
454 <xsl:template match="html:a[@rel='note']" mode="html" xmlns:html="http://www.w3.org/1999/xhtml">
455 <a href="#h:{text()}" class="note">
456 <xsl:apply-templates select="@*|node()" mode="html" />
457 </a>
458 </xsl:template>
459
460 <xsl:template match="@*|node()" mode="html">
461 <xsl:copy>
462 <xsl:apply-templates select="@*|node()" mode="html" />
463 </xsl:copy>
464 </xsl:template>
465
466
467 </xsl:stylesheet>