1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <xsl:stylesheet |
---|
3 | version="2.0" |
---|
4 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
5 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
---|
6 | xmlns:my="myFunctions" |
---|
7 | > |
---|
8 | <!-- |
---|
9 | <purpose> generate a view for a model summary (generated by model_stats.xq</purpose> |
---|
10 | <params> |
---|
11 | <param name=""></param> |
---|
12 | </params> |
---|
13 | <history> |
---|
14 | <change on="2010-01-08" type="created" by="vr">from cmd2stats.xsl</change> |
---|
15 | <change on="2010-03-27" type="changed" by="vr">include cmd_commons.xsl</change> |
---|
16 | </history> |
---|
17 | --> |
---|
18 | <xsl:import href="cmd_commons.xsl"/> |
---|
19 | <xsl:import href="model2matrix.xsl"/> |
---|
20 | |
---|
21 | |
---|
22 | <!-- <xsl:param name="size_lowerbound">0</xsl:param> |
---|
23 | <xsl:param name="max_depth">0</xsl:param> |
---|
24 | <xsl:param name="freq_limit">20</xsl:param> |
---|
25 | <xsl:param name="show">file</xsl:param> --> |
---|
26 | <xsl:param name="sort">x</xsl:param> <!-- s=size|n=name|t=time|x=default --> |
---|
27 | <xsl:param name="name_col_width" >50%</xsl:param> |
---|
28 | |
---|
29 | <!-- <xsl:param name="mode" select="'htmldiv'" /> --> |
---|
30 | <xsl:param name="title" select="'Terms'" /> |
---|
31 | |
---|
32 | <!-- |
---|
33 | <xsl:param name="detail_uri_prefix" select="'?q='"/> |
---|
34 | --> |
---|
35 | <xsl:output method="html" /> |
---|
36 | |
---|
37 | |
---|
38 | <xsl:decimal-format name="european" decimal-separator=',' grouping-separator='.' /> |
---|
39 | |
---|
40 | <xsl:template name="continue-root"> |
---|
41 | |
---|
42 | <xsl:variable name="termmatrix"> |
---|
43 | <xsl:apply-templates mode="matrix" /> |
---|
44 | </xsl:variable> |
---|
45 | |
---|
46 | <xsl:for-each select="$termmatrix" > |
---|
47 | <xsl:call-template name="continue" /> |
---|
48 | </xsl:for-each> |
---|
49 | |
---|
50 | </xsl:template> |
---|
51 | |
---|
52 | <xsl:template name="continue"> |
---|
53 | <div> |
---|
54 | <xsl:choose> |
---|
55 | <xsl:when test="$format='model2htmltable'" > |
---|
56 | <xsl:call-template name="header"/> |
---|
57 | <xsl:call-template name="table"/> |
---|
58 | |
---|
59 | </xsl:when> |
---|
60 | <xsl:when test="$format='model2htmlpage'" > |
---|
61 | <xsl:call-template name="header"/> |
---|
62 | <div id="model"> |
---|
63 | <xsl:call-template name="terms-tree" /> |
---|
64 | <xsl:call-template name="list-datcats" /> |
---|
65 | <!-- <table id="modeltree" > |
---|
66 | <thead> |
---|
67 | <tr><th class="treecol">Name</th><th>Count Elems</th><th>Count Text</th><th>Count Distinct Text</th><th>Path</th><th>comp/datcat</th></tr> |
---|
68 | </thead> |
---|
69 | <xsl:apply-templates select="*/Term" mode="detail"> |
---|
70 | <xsl:sort order="ascending" select="@n" /> |
---|
71 | </xsl:apply-templates> |
---|
72 | </table> --> |
---|
73 | </div> |
---|
74 | |
---|
75 | </xsl:when> |
---|
76 | <xsl:when test="$format='model2htmllist'" > |
---|
77 | <xsl:call-template name="list"/> |
---|
78 | </xsl:when> |
---|
79 | <xsl:when test="$format='model2htmlselect'" > |
---|
80 | <select id="terms-select"> |
---|
81 | <xsl:apply-templates select="./*/*/Term" mode="select"/> |
---|
82 | </select> |
---|
83 | </xsl:when> |
---|
84 | <xsl:otherwise> |
---|
85 | <xsl:call-template name="list"/> |
---|
86 | </xsl:otherwise> |
---|
87 | </xsl:choose> |
---|
88 | </div> |
---|
89 | |
---|
90 | </xsl:template> |
---|
91 | |
---|
92 | <xsl:template name="header"> |
---|
93 | <h2>MDRepository Statistics</h2> |
---|
94 | <table> |
---|
95 | <tbody> |
---|
96 | <tr><td>context-path</td><td align="right"><xsl:value-of select="/Terms/Term/@path"/></td></tr> |
---|
97 | <tr><td>maxdepth</td><td align="right"><xsl:value-of select="/Terms/@depth"/></td></tr> |
---|
98 | <tr><td>count distinct Terms</td><td align="right"><xsl:value-of select="count(distinct-values(//Term/@path))"/></td></tr> |
---|
99 | <tr><td>count Terms</td><td align="right"><xsl:value-of select="format-number(sum(//Term/@count),'#.###','european')"/></td></tr> |
---|
100 | <tr><td>count txt</td><td align="right"><xsl:value-of select="format-number(sum(//Term/@count_text),'#.###','european')"/></td></tr> |
---|
101 | </tbody> |
---|
102 | </table> |
---|
103 | </xsl:template> |
---|
104 | |
---|
105 | <xsl:template name="table"> |
---|
106 | <table> |
---|
107 | <caption>Terms Usage</caption> |
---|
108 | <thead><tr><th>name/path</th><th>count elems</th><th>count text</th><th>count distinct text</th></tr></thead> |
---|
109 | <tbody> |
---|
110 | <xsl:apply-templates select="*" mode="table" /> |
---|
111 | </tbody> |
---|
112 | </table> |
---|
113 | |
---|
114 | </xsl:template> |
---|
115 | |
---|
116 | <xsl:template match="Term" mode="table"> |
---|
117 | <tr><td><a href="?q={@path}" > |
---|
118 | <xsl:value-of select="translate(@path,'/','.')"/></a></td> |
---|
119 | <td align="right"><xsl:value-of select="@count"/></td> |
---|
120 | <td align="right"><xsl:value-of select="@count_text"/></td> |
---|
121 | <td align="right"><xsl:value-of select="@count_distinct_text"/></td> |
---|
122 | </tr> |
---|
123 | <xsl:apply-templates select="*" mode="table" /> |
---|
124 | </xsl:template> |
---|
125 | |
---|
126 | <xsl:template name="list"> |
---|
127 | <div id="terms"> |
---|
128 | <!-- format:<xsl:value-of select="$format" /> --> |
---|
129 | <xsl:variable name="translated_term" select="translate(replace(/*/Term[1]/@path,'//',''),'/','.')" /> |
---|
130 | <!-- <input id="query_terms" value="{$translated_term}" /> --> |
---|
131 | <ul class="treeview"> |
---|
132 | <xsl:apply-templates select="/*/Term/Term" mode="list" /> |
---|
133 | </ul> |
---|
134 | </div> |
---|
135 | </xsl:template> |
---|
136 | |
---|
137 | <xsl:template match="Term" mode="list" > |
---|
138 | <!-- <xsl:variable name="translated_path" select="translate(replace(@path,'//',''),'/','.')" /> --> |
---|
139 | <li><div class="cmds-elem-plus"><span class="detail-caller"><a href="{concat($detail_model_prefix,@context)}" > |
---|
140 | <xsl:value-of select="@name"/></a></span> |
---|
141 | <span class="note">|<xsl:value-of select="@count"/>/<xsl:value-of select="@count_text"/>/<xsl:value-of select="@count_distinct_text"/>|</span> |
---|
142 | <span class="data comppath"><xsl:value-of select="@path" /></span> |
---|
143 | <span class="cmd cmd_filter"><xsl:text> </xsl:text></span> |
---|
144 | <span class="cmd cmd_detail" ><xsl:text> </xsl:text></span> |
---|
145 | <span class="cmd cmd_columns" ><xsl:text> </xsl:text></span> |
---|
146 | <div class="detail"> |
---|
147 | <xsl:for-each select="@*" > |
---|
148 | <div class="cmds-elem-prop"><span class="label"><xsl:value-of select="name()" />: </span> |
---|
149 | <span class="value"><xsl:value-of select="." /></span></div> |
---|
150 | </xsl:for-each> |
---|
151 | </div> |
---|
152 | </div> |
---|
153 | <ul><xsl:apply-templates select="*" mode="list" /></ul> |
---|
154 | </li> |
---|
155 | </xsl:template> |
---|
156 | |
---|
157 | |
---|
158 | <xsl:template name="terms-tree" > |
---|
159 | <table id="modeltree" > |
---|
160 | <thead> |
---|
161 | <tr><th class="treecol">Name</th><th>Count Elems</th><th>Count Text</th><th>Count Distinct Text</th><th>Path</th><th>comp/datcat</th></tr> |
---|
162 | </thead> |
---|
163 | <xsl:apply-templates select="*/Term" mode="detail"> |
---|
164 | <xsl:sort order="ascending" select="@n" /> |
---|
165 | </xsl:apply-templates> |
---|
166 | </table> |
---|
167 | </xsl:template> |
---|
168 | |
---|
169 | <xsl:template match="Term" mode="detail" > |
---|
170 | <xsl:param name="parentid" select="'x-'" /> |
---|
171 | |
---|
172 | <xsl:variable name="lv" select="count(ancestor::Term)" /> |
---|
173 | |
---|
174 | <xsl:variable name="xid" > |
---|
175 | <xsl:choose> |
---|
176 | <xsl:when test="$lv=0"><xsl:value-of select="concat($parentid,position())" /></xsl:when> |
---|
177 | <xsl:otherwise><xsl:value-of select="concat($parentid,'-', position())" /></xsl:otherwise> |
---|
178 | </xsl:choose> |
---|
179 | </xsl:variable> |
---|
180 | |
---|
181 | <tr id="{$xid}" > |
---|
182 | <xsl:if test="$lv!=0" > |
---|
183 | <xsl:attribute name="class" select="concat('child-of-',$parentid)" /> |
---|
184 | </xsl:if> |
---|
185 | <td class="treecol" ><xsl:value-of select="@name" /></td> |
---|
186 | <td class="number"><xsl:value-of select="@count" /></td> |
---|
187 | <td class="number"><xsl:value-of select="@count_text" /></td> |
---|
188 | <td class="number"><xsl:value-of select="@count_distinct_text" /></td> |
---|
189 | <td><xsl:value-of select="@path" />,<xsl:value-of select="@context" /></td> |
---|
190 | <td><xsl:value-of select="@corresponding_component" />,<xsl:value-of select="@datcat" /></td> |
---|
191 | </tr> |
---|
192 | <xsl:if test="Term and ($lv<$max_depth or $max_depth=0)"> |
---|
193 | |
---|
194 | <xsl:choose> |
---|
195 | <xsl:when test="$sort='s'"> |
---|
196 | <xsl:apply-templates select="Term" mode="detail"> |
---|
197 | <xsl:with-param name="parentid" select="$xid" /> |
---|
198 | <xsl:sort order="descending" select="@count_distinct_text" data-type="number" /> |
---|
199 | </xsl:apply-templates> |
---|
200 | </xsl:when> |
---|
201 | <xsl:when test="$sort='n'"> |
---|
202 | <xsl:apply-templates select="Term" mode="detail"> |
---|
203 | <xsl:with-param name="parentid" select="$xid" /> |
---|
204 | <xsl:sort order="ascending" select="@n" /> |
---|
205 | </xsl:apply-templates> |
---|
206 | </xsl:when> |
---|
207 | <xsl:otherwise> |
---|
208 | <!-- testwise: show only non empty Terms, no good, because only leaf-elements have filled @count_distinct_text |
---|
209 | <xsl:apply-templates select="Term[@count_distinct_text > 1]" mode="detail"> --> |
---|
210 | <xsl:apply-templates select="Term" mode="detail"> |
---|
211 | <xsl:with-param name="parentid" select="$xid" /> |
---|
212 | </xsl:apply-templates> |
---|
213 | </xsl:otherwise> |
---|
214 | </xsl:choose> |
---|
215 | |
---|
216 | </xsl:if> |
---|
217 | |
---|
218 | </xsl:template> |
---|
219 | |
---|
220 | <xsl:template match="Term" mode="select"> |
---|
221 | <xsl:variable name="lv" select="count(ancestor::Term)" /> |
---|
222 | |
---|
223 | <option value="{@name}" ><xsl:value-of select="for $i in (2 to $lv) return ' '" /><xsl:value-of select="@name" /> |<xsl:value-of select="@count" />|</option> |
---|
224 | <xsl:apply-templates select="Term" mode="select" /> |
---|
225 | </xsl:template> |
---|
226 | |
---|
227 | <!-- |
---|
228 | <xsl:template name="list-datcats" > |
---|
229 | <table id="datcats" > |
---|
230 | <thead> |
---|
231 | <tr><th class="treecol">Name</th><th>Count Elems</th><th>Count Text</th><th>Count Distinct Text</th><th>Path</th><th>comp/datcat</th></tr> |
---|
232 | </thead> |
---|
233 | <xsl:apply-templates select="*/Term" mode="detail"> |
---|
234 | <xsl:sort order="ascending" select="@n" /> |
---|
235 | </xsl:apply-templates> |
---|
236 | </table> |
---|
237 | </xsl:template> |
---|
238 | --> |
---|
239 | <xsl:template name="list-datcats"> |
---|
240 | <xsl:param name="matrix" select="."></xsl:param> |
---|
241 | <table> |
---|
242 | <caption>DatCats |<xsl:value-of select="count(distinct-values($matrix//Term/@datcat))" />| <span class="note">* Click on numbers to see detail </span></caption> |
---|
243 | <thead><tr><th rowspan="2">id</th><th rowspan="2">name</th> |
---|
244 | <th colspan="3" >count </th><th rowspan="2">elems</th></tr> |
---|
245 | <tr><th>profile*</th><th >all*</th><th>elems</th> </tr> </thead> |
---|
246 | <tbody> |
---|
247 | <xsl:for-each-group select="$matrix//Term" group-by="@datcat"> |
---|
248 | <xsl:sort select="lower-case(@datcat)" order="ascending"/> |
---|
249 | <tr><td valign="top"><xsl:value-of select="my:shortURL(@datcat)"/></td> |
---|
250 | <td valign="top"><xsl:value-of select="my:rewriteURL(@datcat)"/></td> |
---|
251 | <td valign="top" align="right"> |
---|
252 | <span class="detail-caller" ><xsl:value-of select="count(distinct-values(current-group()/@name))"/></span> |
---|
253 | <div class="detail" > |
---|
254 | <div class="box_heading"><xsl:value-of select="my:rewriteURL(@datcat)"/></div> |
---|
255 | <ul> |
---|
256 | <xsl:for-each select="distinct-values(current-group()/@name)" > |
---|
257 | <li><xsl:value-of select="." /></li> |
---|
258 | </xsl:for-each> |
---|
259 | </ul> |
---|
260 | </div> |
---|
261 | </td> |
---|
262 | <td valign="top" align="right"> |
---|
263 | <span class="term_detail_caller" ><xsl:value-of select="count(current-group())"/></span> |
---|
264 | <div class="term_detail" > |
---|
265 | <div class="box_heading"><xsl:value-of select="my:rewriteURL(@datcat)"/></div> |
---|
266 | <ul> |
---|
267 | <xsl:for-each-group select="current-group()" group-by="@name" > |
---|
268 | <li><xsl:value-of select="@name" /> |
---|
269 | <ul> |
---|
270 | <xsl:for-each select="current-group()/@context" > |
---|
271 | <li><xsl:value-of select="." /></li> |
---|
272 | </xsl:for-each> |
---|
273 | </ul> |
---|
274 | </li> |
---|
275 | </xsl:for-each-group> |
---|
276 | </ul> |
---|
277 | </div> |
---|
278 | </td> |
---|
279 | <td valign="top" align="right"><xsl:value-of select="count(distinct-values(current-group()/@elem))"/></td> |
---|
280 | |
---|
281 | <td width="40%"> |
---|
282 | <xsl:for-each select="distinct-values(current-group()/@elem)"> |
---|
283 | <xsl:sort select="." /> |
---|
284 | <xsl:value-of select="."/>, |
---|
285 | </xsl:for-each> |
---|
286 | </td> |
---|
287 | </tr> |
---|
288 | </xsl:for-each-group> |
---|
289 | </tbody> |
---|
290 | </table> |
---|
291 | </xsl:template> |
---|
292 | |
---|
293 | |
---|
294 | |
---|
295 | |
---|
296 | |
---|
297 | <xsl:template name="callback-header" > |
---|
298 | <style type="text/css"> |
---|
299 | #modeltree { margin-left: 10px; border: 1px solid #9999aa; border-collapse: collapse;} |
---|
300 | .number { text-align: right; } |
---|
301 | td { border-bottom: 1px solid #9999aa; padding: 1px 4px;} |
---|
302 | .treecol {padding-left: 1.5em;} |
---|
303 | table thead {background: #ccccff; font-size:0.9em; } |
---|
304 | table thead tr th { border:1px solid #9999aa; font-weight:normal; text-align:left; padding: 1px 4px;} |
---|
305 | |
---|
306 | </style> |
---|
307 | <script type="text/javascript" > |
---|
308 | $(function(){ |
---|
309 | $("#modeltree").treeTable({initialState:"expanded"}); |
---|
310 | }); |
---|
311 | </script> |
---|
312 | </xsl:template> |
---|
313 | |
---|
314 | |
---|
315 | |
---|
316 | </xsl:stylesheet> |
---|