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