source: MDService2/trunk/MDService2/src/xsl/terms2view.xsl @ 1038

Last change on this file since 1038 was 1038, checked in by gaba, 13 years ago

query - columns, autocolumns

File size: 13.8 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet  version="2.0"
3  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4  xmlns:xs="http://www.w3.org/2001/XMLSchema"    xmlns:my="myFunctions"
5>
6<!--
7<purpose> generate all the views for terms-matrix</purpose>
8<params>
9<param name=""></param>
10</params>
11<history>
12        <change on="2010-10-11" type="created" by="vr">from model2view.xsl</change>             
13</history>
14-->
15<xsl:import href="cmd_commons.xsl"/>
16
17<!--  <xsl:output method="xml" />  --> 
18
19<!-- <xsl:param name="size_lowerbound">0</xsl:param>
20<xsl:param name="max_depth">0</xsl:param>
21<xsl:param name="freq_limit">20</xsl:param>
22<xsl:param name="show">file</xsl:param> 
23<xsl:param name="detail_uri_prefix" select="'?q='"/> 
24<xsl:param name="mode" select="'htmldiv'" /> -->
25
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<xsl:param name="title" select="'Terms'" />
29
30<xsl:decimal-format name="european" decimal-separator=',' grouping-separator='.' />
31
32<xsl:template name="continue-root">
33        <div>   
34                <xsl:choose>                   
35                 <xsl:when test="$format='terms2htmltable'" >
36                        <xsl:call-template name="header"/>   
37                        <xsl:call-template name="table"/>
38                           
39                </xsl:when>
40                <xsl:when test="$format='terms2htmlpage'" >
41                        <xsl:call-template name="header"/>
42                            <div id="terms-matrix">
43                                <xsl:apply-templates select="Termsets/Termset" mode="terms-tree" />                             
44                                </div>                                                                                         
45                        </xsl:when>                             
46                <xsl:when test="$format='terms2htmllist'" >                     
47                        <xsl:call-template name="list"/>   
48                </xsl:when>
49                <xsl:when test="$format='terms2flat'" >                                                                 
50                                <xsl:call-template name="terms-flat"/>                                                     
51                </xsl:when> 
52                <xsl:when test="$format='terms2autocomplete'" >
53                        <xsl:variable name="terms_flat" >                                       
54                                <xsl:call-template name="terms-flat"/>
55                        </xsl:variable>                         
56                        <xsl:apply-templates select="$terms_flat" mode="autocomplete"/>                             
57                </xsl:when> 
58                <xsl:when test="$format='terms2htmlselect'" >
59                                        <select id="terms-select">             
60                                                        <xsl:apply-templates select=".//Termset" mode="select"/>                                                       
61                                        </select>                                                               
62                        </xsl:when>
63                <xsl:otherwise>
64                        <xsl:call-template name="list"/>   
65                </xsl:otherwise>
66         </xsl:choose>
67    </div>       
68       
69</xsl:template> 
70
71
72<xsl:template name="header">
73        <h2>MDService Terms</h2>       
74        <table>
75                <tbody>
76                        <tr><td>count Termsets</td><td align="right"><xsl:value-of select="count(/Termsets/Termset)"/></td></tr>                                                                                               
77                </tbody>
78        </table>
79</xsl:template>         
80
81<xsl:template name="table">
82        <table>
83                <caption>Terms Usage</caption>
84                <thead><tr><th>name/path</th><th>count elems</th><th>count text</th><th>count distinct text</th>
85                <th>context</th><th>corresp comp</th><th>datcat</th></tr></thead>
86                <tbody>         
87                        <xsl:apply-templates select="*" mode="table" />                 
88                </tbody>
89        </table>
90
91</xsl:template>
92
93<xsl:template match="Term" mode="table">
94                                <tr><td>
95                                <!-- <a href="?q={@path}" > -->
96                                        <span class="cmd cmd_add">      </span>
97                                        <span class="column-elem"><xsl:value-of select="translate(@path,'/','.')"/></span>
98                                        <!-- </a> -->
99                                        </td>
100                                                <td align="right"><xsl:value-of select="@count"/></td>
101                                                <td align="right"><xsl:value-of select="@count_text"/></td>                                             
102                                                <td align="right"><xsl:value-of select="@count_distinct_text"/></td>                                           
103                                                <td><xsl:value-of select="@context"/></td>
104                                                <td><xsl:value-of select="@corresponding_component"/></td>
105                                                <td><xsl:value-of select="@datcat"/></td>
106                                               
107                                </tr>                                                   
108                                <xsl:apply-templates select="*" mode="table" />                 
109</xsl:template>
110
111<xsl:template name="list">
112        <div class="terms">             
113                <!--  format:<xsl:value-of select="$format" /> -->
114                <!--<xsl:variable name="translated_term" select="translate(replace(/*/Term[1]/@path,'//',''),'/','.')" />
115                 <input id="query_terms" value="{$translated_term}" /> -->             
116                <ul class="treeview">
117                        <xsl:apply-templates select="/*/Term[@path]" mode="list" />                     
118                </ul>   
119        </div>
120</xsl:template>
121
122<xsl:template match="Term" mode="list" >
123<xsl:param name="options" select="''" />
124                <!--  <xsl:variable name="translated_path" select="translate(replace(@path,'//',''),'/','.')" /> -->
125                <!--  filter out empty datcats  -->
126                <xsl:if test="@elem or descendant::*[@elem] or $options='all'" >
127                                <li><div class="cmds-elem-plus"><span class="detail-caller"><!-- <a href="{concat($detail_model_prefix,@context)}" >  -->
128                                        <xsl:value-of select="@path"/></span>
129                                        <span class="note">|<xsl:value-of select="@count"/>|</span>
130                                        <!--  /<xsl:value-of select="@count_text"/>/<xsl:value-of select="@count_distinct_text"/> -->                                   
131                                        <span class="data comppath"><xsl:value-of select="@path" /></span>               
132                                        <span class="cmd cmd_filter"><xsl:text> </xsl:text></span>
133                                        <span class="cmd cmd_detail" ><xsl:text> </xsl:text></span>
134                                        <span class="cmd cmd_columns" ><xsl:text> </xsl:text></span>
135                                        <xsl:call-template name="attr-detail-div" />
136                                                <!--  <div class="detail">
137                                                        <xsl:for-each select="@*" >
138                                                                <div class="cmds-elem-prop"><span class="label"><xsl:value-of select="name()" />: </span>
139                                                                        <span class="value"><xsl:value-of select="." /></span></div>
140                                                        </xsl:for-each>
141                                                </div> -->
142                                        </div>
143                                        <ul><xsl:apply-templates select="Term" mode="list" >
144                                                        <xsl:with-param name="options" select="$options"></xsl:with-param>
145                                                </xsl:apply-templates>
146                                        </ul>                           
147                                </li>   
148                </xsl:if>               
149</xsl:template>
150
151
152<xsl:template match="Termset" mode="terms-tree" >
153                                        <table class="terms-tree" >
154                                                <thead>
155                                                <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>
156                                                </thead>                                       
157                                                <xsl:apply-templates select="Term" mode="detail">
158                                                        <xsl:sort order="ascending" select="@n" />                                                     
159                                                </xsl:apply-templates>
160                                        </table>
161</xsl:template>                                 
162
163<xsl:template match="Term" mode="detail" >
164<xsl:param name="parentid" select="'x-'" />
165
166<xsl:variable name="lv" select="count(ancestor::Term)" />
167
168        <xsl:variable name="xid" >
169                <xsl:choose>
170                <xsl:when test="$lv=0"><xsl:value-of select="concat($parentid,position())" /></xsl:when>
171                <xsl:otherwise><xsl:value-of select="concat($parentid,'-', position())" /></xsl:otherwise>
172                </xsl:choose> 
173        </xsl:variable>
174       
175        <tr id="{$xid}" >
176          <xsl:if test="$lv!=0" >
177                <xsl:attribute name="class" select="concat('child-of-',$parentid)" />
178          </xsl:if>
179                <td class="treecol" ><xsl:value-of select="@name" /></td>               
180                <td class="number"><xsl:value-of select="@count" /></td>
181                <td class="number"><xsl:value-of select="@count_text" /></td>
182                <td class="number"><xsl:value-of select="@count_distinct_text" /></td>
183                <td><xsl:value-of select="@path" />,<xsl:value-of select="@context" /></td>                     
184                <td><xsl:value-of select="@corresponding_component" />,<xsl:value-of select="@datcat" /></td>
185     </tr> 
186                <xsl:if test="Term and ($lv&lt;$max_depth or $max_depth=0)">
187                       
188                                <xsl:choose>
189                                        <xsl:when test="$sort='s'">                             
190                                                <xsl:apply-templates select="Term" mode="detail">
191                                                        <xsl:with-param name="parentid" select="$xid" />                       
192                                                                <xsl:sort order="descending" select="@count_distinct_text" data-type="number" />
193                                                </xsl:apply-templates>         
194                                        </xsl:when>
195                                        <xsl:when test="$sort='n'">                             
196                                        <xsl:apply-templates select="Term" mode="detail">
197                                                        <xsl:with-param name="parentid" select="$xid" />
198                                                                <xsl:sort order="ascending" select="@n" />
199                                                </xsl:apply-templates>
200                                        </xsl:when>
201                                        <xsl:otherwise>
202                                        <!--  testwise: show only non empty Terms-->
203                                                <xsl:apply-templates select="Term" mode="detail">
204                                                        <xsl:with-param name="parentid" select="$xid" />                                                               
205                                                </xsl:apply-templates>         
206                                        </xsl:otherwise>
207                                </xsl:choose>                                   
208                                       
209                </xsl:if>
210       
211</xsl:template>
212
213<xsl:template match="Termset" mode="select">
214       
215        <xsl:variable name="count" select="if (Term/@count) then concat(' |',Term/@count,'|') else '' " />
216        <xsl:variable name="call-value" select="if (@type='model') then @name else @id" />
217        <option value="{$call-value}" ><xsl:value-of select="@name" /><xsl:value-of select="$count" /></option>                                 
218</xsl:template>
219
220<xsl:template match="Term" mode="autocomplete">
221        <xsl:copy>
222                <xsl:copy-of select="@*" />
223                <div class="term-contexts">
224                        <ul>
225                                <xsl:apply-templates mode="autocomplete" />
226                        </ul>
227                </div>
228        </xsl:copy>                                     
229</xsl:template>
230
231<xsl:template match="context" mode="autocomplete">
232        <li class="context cmds-elem-plus">
233                <span class="autocomplete-select-caller">
234                <!--
235                <a href="{concat($detail_model_prefix,@path)}" >
236                                <xsl:value-of select="@path"/></a>
237                 --> <xsl:value-of select="@path"/>
238                                </span>
239                                       
240                <xsl:call-template name="attr-detail-div" />
241                <ul>
242                        <xsl:apply-templates select="context" mode="autocomplete" />
243                </ul>
244        </li>                                   
245</xsl:template>
246
247
248<xsl:template name="terms-flat">
249       
250                <!--  group union of model, dcr and rr Terms --> 
251                <xsl:for-each-group select=".//Termset[@type='model']//Term | .//Termset[@type='dcr']/Term | .//Termset[@type='rr']//Term[@type='rel']" group-by="lower-case(@name)" >
252<!--            <xsl:for-each-group select="//Term[exists(@name)][parent::Termset]" group-by="lower-case(@name)" >-->
253                        <xsl:sort select="lower-case(@name)" />
254                        <!--  <xsl:if test="exists(current-group()[not(@type='datcat')])" >  -->
255                                <Term name="{@name}">
256                                        <xsl:for-each select="current-group()[not(@type='datcat' or @type='rel')]" >
257                                                <context><!-- <xsl:value-of select="ancestor::Termset[1]/@id" />:  -->
258                                                        <xsl:copy-of select="@*" />
259                                                <xsl:value-of select="@path" /></context>
260                                        </xsl:for-each>
261                                        <xsl:for-each select="current-group()[@type='datcat'][parent::Termset]" >
262                                                <xsl:variable name="datcat" select="." />
263                                                <context><xsl:copy-of select="@*" /><xsl:value-of select="ancestor::Termset[1]/@id" />:<xsl:value-of select="@name" />
264                                                <xsl:for-each-group select="$datcat/Term" group-by="@path" >
265                                                        <context><xsl:copy-of select="@*" /><xsl:copy-of select="@*" /><xsl:value-of select="@path" /></context>
266                                                </xsl:for-each-group>
267                                                </context>                             
268                                        </xsl:for-each>
269                                       
270                                        <xsl:for-each select="current-group()[@type='rel']" >
271                                                <xsl:variable name="datcat" select="if(parent::Term[@type='rel']) then parent::Term[@type='rel'] else . " />
272                                                                <context><xsl:copy-of select="@*" /><!-- <xsl:value-of select="ancestor::Termset[1]/@id" />: --><xsl:value-of select="@path" />
273<!--                                            <xsl:for-each-group select="$datcat//Term[@type!='datcat']" group-by="@path" >-->
274                                                               
275                                                        <xsl:for-each select="$datcat//Term[@type='datcat']" > <!-- [Term/@path] -->
276                                                                <context><xsl:copy-of select="@*" /><xsl:value-of select="@path" />
277                                                                <xsl:for-each-group select="Term[@path]" group-by="@path" >
278                                                                                <context><xsl:copy-of select="@*" /><xsl:value-of select="@path" /></context>
279                                                                </xsl:for-each-group>
280                                                                </context>
281                                                        </xsl:for-each>
282                                                </context>                             
283                                        </xsl:for-each>
284                                </Term>
285<!--                    </xsl:if>-->
286                </xsl:for-each-group>
287</xsl:template>
288
289<xsl:template name="list-datcats">
290        <xsl:param name="matrix" select="."></xsl:param>
291        <table>
292                <caption>DatCats |<xsl:value-of select="count(distinct-values($matrix//Term/@datcat))" />| <span class="note">* Click on numbers to see detail </span></caption>
293                                <thead><tr><th rowspan="2">id</th><th rowspan="2">name</th>
294                                        <th colspan="3" >count </th><th rowspan="2">elems</th></tr>
295                                        <tr><th>profile*</th><th >all*</th><th>elems</th> </tr>         </thead>
296                <tbody>         
297                                <xsl:for-each-group select="$matrix//Term" group-by="@datcat">
298                                        <xsl:sort select="lower-case(@datcat)" order="ascending"/>                                     
299                                                <tr><td valign="top"><xsl:value-of select="my:shortURL(@datcat)"/></td>
300                                                <td valign="top"><xsl:value-of select="my:rewriteURL(@datcat)"/></td>
301                                                <td valign="top" align="right">
302                                                        <span class="detail-caller" ><xsl:value-of select="count(distinct-values(current-group()/@name))"/></span>
303                                                        <div class="detail" >
304                                                                        <div class="box_heading"><xsl:value-of select="my:rewriteURL(@datcat)"/></div>
305                                                                        <ul>
306                                                                                <xsl:for-each select="distinct-values(current-group()/@name)" >
307                                                                                        <li><xsl:value-of select="." /></li>
308                                                                                </xsl:for-each>
309                                                                        </ul>
310                                                                </div>                                                 
311                                                </td>
312                                                <td valign="top" align="right">
313                                                        <span class="term_detail_caller" ><xsl:value-of select="count(current-group())"/></span>
314                                                        <div class="term_detail" >
315                                                                        <div class="box_heading"><xsl:value-of select="my:rewriteURL(@datcat)"/></div>
316                                                                        <ul>
317                                                                                <xsl:for-each-group select="current-group()" group-by="@name" >
318                                                                                        <li><xsl:value-of select="@name" />
319                                                                                                        <ul>
320                                                                                                                <xsl:for-each select="current-group()/@context" >
321                                                                                                                                <li><xsl:value-of select="." /></li>
322                                                                                                                </xsl:for-each>
323                                                                                                        </ul>
324                                                                                        </li>
325                                                                                </xsl:for-each-group>
326                                                                        </ul>
327                                                                </div>                                                 
328                                                </td>
329                                                <td valign="top" align="right"><xsl:value-of select="count(distinct-values(current-group()/@elem))"/></td>                                             
330                                                       
331                                                <td width="40%">                                               
332                                                                <xsl:for-each select="distinct-values(current-group()/@elem)">
333                                                                        <xsl:sort select="." />
334                                                                        <xsl:value-of select="."/>,
335                                                                </xsl:for-each>
336                                                </td>                                                                                           
337                                                </tr>                                   
338                                </xsl:for-each-group>
339                </tbody>
340        </table>
341        </xsl:template>
342
343<xsl:template name="callback-header" >
344        <style type="text/css">
345                #modeltree { margin-left: 10px; border: 1px solid #9999aa; border-collapse: collapse;}
346                .number { text-align: right; }
347                td { border-bottom: 1px solid #9999aa; padding: 1px 4px;}
348                .treecol {padding-left: 1.5em;}
349                table thead {background: #ccccff; font-size:0.9em; }
350                table thead tr th { border:1px solid #9999aa; font-weight:normal; text-align:left; padding: 1px 4px;}
351
352        </style> 
353        <script type="text/javascript" >
354                $(function(){
355                        $(".terms-tree").treeTable({initialState:"expanded"});
356                });
357        </script>
358</xsl:template>
359
360</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.