source: MDService2/trunk/MDService2/src/xsl/cmd_commons.xsl @ 685

Last change on this file since 685 was 685, checked in by vronk, 14 years ago

treetabelview for collections and model
introducing header-callback template

File size: 9.9 KB
Line 
1<?xml version="1.0"?>
2<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:my="myFunctions">
4
5<!--
6<purpose>generic functions and templates for displaying/summarizing table-data</purpose>
7<history>
8        <change on="2010-03-19" type="created" by="vr">based on 3RMA/suki/dc4_commons.xsl</change>                     
9        <change on="2010-03-23" type="changed" by="vr">really started rework - added html wrapper, ...</change>                 
10</history>
11
12-->
13<xsl:include href="params.xsl"/>
14
15<!-- <xsl:param name="mode" select="'html'" /> -->
16
17<xsl:param name="dict_file" select="'dict.xml'" />
18<xsl:variable name="dict" select="document($dict_file)" />
19
20<!-- params for include-processing
21moved to params.xsl
22        <xsl:param name="components_uri" select="'http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/'" />         
23        <xsl:param name="prefix_replace" select="'file:///C:/Users/master/3lingua/clarin/CMDI/_repo2/metadata/toolkit/components'" />
24-->
25
26        <xsl:param name="src_file" />           
27        <xsl:param name="root_uri" select="$src_file" />               
28
29<xsl:template match="/">
30                <xsl:message>root_document-uri:<xsl:value-of select="$root_uri" /></xsl:message>
31                <xsl:message>components_uri:<xsl:value-of select="$components_uri" /></xsl:message>
32                <xsl:choose>                   
33                <xsl:when test="contains($format,'htmlpage')" >
34                        <xsl:call-template name="html"/>   
35                </xsl:when>
36                <xsl:otherwise>                         
37                        <xsl:call-template name="continue-root"/>   
38                </xsl:otherwise>
39         </xsl:choose>
40</xsl:template>
41
42
43<xsl:template name="html">
44        <html>
45        <head>
46        <title><xsl:value-of select="$title"/></title>
47         <!--  <link rel="stylesheet" media="all" type="text/css" href="{$style_dir}/vronk_style.css"  />                         
48         <link rel="stylesheet" media="all" type="text/css" href="{$style_dir}/cmdi.css"  />
49          -->
50         <link rel="stylesheet" href="{$base_dir}/style/jquery/smoothness/jquery-ui-1.8.1.custom.css" type="text/css" ></link>
51<link href="{$base_dir}/style/jquery/jquery-treeview/jquery.treeview.css" rel="stylesheet" ></link>
52<link href="{$base_dir}/style/jquery/treetable/jquery.treeTable.css" rel="stylesheet" ></link>
53<link href="{$base_dir}/style/metares.css" type="text/css" rel="stylesheet" ></link>
54<link href="{$base_dir}/style/cmdi.css" type="text/css" rel="stylesheet" ></link>
55<link href="{$base_dir}/style/query.css" type="text/css" rel="stylesheet" ></link>
56<!--
57<link href="{$base_dir}/style/jquery/jquery-textboxlist/TextboxList.css" rel="stylesheet" type="text/css" />
58<link href="{$base_dir}/style/jquery/jquery-autocomplete/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
59-->
60<!-- 
61<script src="{$base_dir}/scripts/jquery/js/jquery-1.3.2.min.js" type="text/javascript"></script>-->
62<script src="{$base_dir}/scripts/jquery/js/jquery-1.4.2.js" type="text/javascript"></script>
63<script src="{$base_dir}/scripts/jquery/js/jquery-ui-1.8.1.custom.min.js" type="text/javascript"></script>
64
65<!--
66<script src="{$base_dir}/scripts/jquery/jquery-textboxlist/GrowingInput.js" type="text/javascript"></script>
67
68<script src="scripts/jquery/jquery-textboxlist/TextboxList.js" type="text/javascript"></script>
69
70 -->
71
72<script src="{$base_dir}/scripts/jquery/jquery-treeview/jquery.treeview.js" type="text/javascript"></script>
73
74<script src="{$base_dir}/scripts/jquery/jquery-treeTable/jquery.treeTable.js" type="text/javascript"></script>
75<!-- <script src="scripts/jquery/jquery-autocomplete/jquery.autocomplete.js" type="text/javascript"></script>
76
77<script src="scripts/mdservice_searchclause.js" type="text/javascript"></script>
78<script src="scripts/mdservice_model.js" type="text/javascript"></script>
79<script src="scripts/mdservice2_ui.js" type="text/javascript"></script>
80          -->
81        <xsl:call-template name="callback-header"/> 
82        </head>
83        <body>
84                <h1><xsl:value-of select="$title"/></h1>               
85                        <xsl:call-template name="continue-root"/>   
86        </body>
87        </html>
88</xsl:template>
89
90<xsl:template name="callback-header">
91
92</xsl:template>
93
94<!--
95<xsl:template name="continue-root">
96
97</xsl:template>
98 -->
99    <!-- Start includes -->
100   
101    <!-- resolve includes -->
102    <xsl:template match="@*|node()" mode="include">
103        <xsl:copy>
104            <xsl:apply-templates select="@*|node()" mode="include"/>
105        </xsl:copy>
106    </xsl:template>
107
108
109    <xsl:template match="CMD_Component[@ComponentId]" mode="include">
110   
111                <!-- <xsl:param name="resolved_path" select="if (matches(@filename, $prefix)) then $prefix_replace else './'" /> -->
112
113                <!-- <xsl:variable name="resolved_fn" select="if (matches(@filename, $prefix)) then replace(@filename, $prefix, $prefix_replace) else if (document-uri(/)) then @filename else concat( $root_uri, '/', @filename)" /> -->
114                <!--  <xsl:variable name="resolved_fn" select="concat($components_uri, @ComponentId)" />  -->
115                <xsl:variable name="resolved_fn" select="concat($components_uri, my:extractID(@ComponentId))" />   
116            <xsl:variable name="compid" select="@ComponentId" /> 
117               
118        <!-- <xsl:variable name="resolved_fn" select="replace(@filename, 'http://www.clarin.eu/cmd/components', 'file:///C:/Users/master/3lingua/clarin/CMDI/_repo2/metadata/toolkit/components')" /> -->
119       
120        <xsl:message>resolved_fn:<xsl:value-of select="$resolved_fn" /></xsl:message>
121        <xsl:message>document-uri:<xsl:value-of select="document-uri(/)" /></xsl:message>
122        <!-- some of the outer CMD_Component attributes can overwrite the inner CMD_Component attributes -->
123       
124        <xsl:variable name="outer-attr" select="@CardinalityMin|@CardinalityMax"/>
125        <xsl:for-each select="document($resolved_fn)/CMD_ComponentSpec/CMD_Component">
126            <xsl:variable name="inner-attr" select="@*"/>
127            <xsl:copy>
128                        <!-- <xsl:attribute name="filename" select="replace($resolved_fn,$prefix_replace,'')" /> -->
129               
130                        <xsl:attribute name="ComponentId" select="$compid" />
131                <xsl:apply-templates select="$outer-attr" mode="include"/>
132                <xsl:apply-templates select="$inner-attr[not(node-name(.) = $outer-attr/node-name(.))]" mode="include"/>
133                <xsl:apply-templates select="node()" mode="include">
134        <!--            <xsl:with-param name="resolved_path" select="$resolved_path" /> -->
135                </xsl:apply-templates>
136            </xsl:copy>
137        </xsl:for-each>
138    </xsl:template>
139   
140
141    <xsl:template match="componentDescription[id] | profileDescription[id]" mode="include">
142   
143        <xsl:variable name="resolved_uri" select="concat($root_uri, '/', id)" /> 
144       
145        <xsl:message>resolved_uri:<xsl:value-of select="$resolved_uri" /></xsl:message>
146        <xsl:message>document-uri:<xsl:value-of select="document-uri(/)" /></xsl:message>
147               
148        <xsl:copy>             
149                <xsl:apply-templates mode="include" />
150                <xsl:apply-templates select="document($resolved_uri)" mode="include" />
151                <!-- <xsl:copy-of select="document($resolved_uri)" /> -->
152                <!-- <xsl:copy-of select="document(id, $root_uri)" />  -->
153        </xsl:copy>
154    </xsl:template>
155       
156    <!-- Stop includes -->
157
158
159        <xsl:function name="my:dict">
160     <xsl:param name="key"/>                             
161     <xsl:value-of select="my:dict($key, $key)" />                                     
162   </xsl:function>
163   
164        <xsl:function name="my:dict">
165     <xsl:param name="key"/>                           
166     <xsl:param name="fallback"/>     
167                <xsl:choose>
168                        <xsl:when test="$dict/list/item[@key=$key]" >
169                                <xsl:value-of select="$dict/list/item[@key=$key]" />
170                        </xsl:when>                     
171                        <xsl:when test="$dict/list/item[.=$key]" >
172                                <xsl:value-of select="$dict/list/item[.=$key]/@key" />
173                        </xsl:when>                     
174                        <xsl:otherwise>
175                        <xsl:value-of select="$fallback" />
176                        </xsl:otherwise>
177                </xsl:choose>
178   </xsl:function>
179               
180        <xsl:function name="my:extractID" >             
181                <xsl:param name="uri" />
182               
183                <xsl:choose>
184                        <xsl:when test="contains($uri,$isocat_base_uri)">
185                                <xsl:value-of select="substring-after($uri, $isocat_base_uri)" />
186                        </xsl:when>
187                        <xsl:when test="contains($uri,$components_id_prefix)">
188                        <!--   <xsl:value-of select="substring-after($uri,'clarin.eu:cr1:')" /> -->
189                                <xsl:value-of select="substring-after($uri, $components_id_prefix)" />
190                        </xsl:when>
191                        <xsl:otherwise><xsl:value-of select="$uri" /></xsl:otherwise>
192                </xsl:choose>           
193        </xsl:function>
194       
195        <xsl:function name="my:shortURL" >
196                <xsl:param name="url" />
197                <!--   <xsl:value-of select="replace($url, 'http://www.isocat.org/datcat/','isocat:')" /> -->
198                <xsl:value-of select="replace($url, $isocat_uri_match,'isocat:')" />           
199        </xsl:function> 
200       
201        <!--  rewrite specific URLs (linking to target services) to redirect them locally (via MDService)
202        should work for: dcif:dataCategory@pid, pcompone
203        -->
204        <xsl:function name="my:rewriteURL" >
205                <xsl:param name="url" />       
206                <xsl:choose>
207                                <xsl:when test="contains($url,$isocat_base_uri)">
208                                                <xsl:value-of select="replace($url, $isocat_uri_match, $isocat_uri_replace)" />
209                                </xsl:when>     
210                                <xsl:otherwise><xsl:value-of select="concat($detail_complist_prefix, my:extractID($url))" /></xsl:otherwise>
211                        </xsl:choose>           
212        </xsl:function> 
213               
214        <xsl:function name="my:comppath" >
215                <xsl:param name="child" />
216        <xsl:for-each select="$child/ancestor::CMD_Component" >
217                        <xsl:value-of select="@name" />.</xsl:for-each><xsl:value-of select="$child/@name" />   
218        </xsl:function> 
219   
220<!--
221<xsl:function name="my:numberFormat">
222<xsl:param name="unit" />
223        <xsl:choose>
224                <xsl:when test="$unit='count' or $unit='count-distinct'" ><xsl:value-of select="$format_count" /></xsl:when>
225                <xsl:when test="$unit='kg'" ><xsl:value-of select="$format_kg" /></xsl:when>
226                <xsl:when test="$unit='t'" ><xsl:value-of select="$format_t" /></xsl:when>
227                <xsl:when test="$unit='m3'" ><xsl:value-of select="$format_m3" /></xsl:when>
228                <xsl:when test="$unit='per' or $unit='percent'" ><xsl:value-of select="$format_per" /></xsl:when>
229                <xsl:when test="$unit='sum'" ><xsl:value-of select="$format_kg" /></xsl:when>
230                <xsl:otherwise><xsl:value-of select="$format_default" /></xsl:otherwise>               
231        </xsl:choose>
232</xsl:function>
233-->
234
235</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.