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

Last change on this file since 1076 was 1076, checked in by vronk, 13 years ago

reduced logging messages,
changes to CQL-handling in js and XCQL2Xpath-mapping;
reworked docs, introduced example queries

File size: 9.5 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 templates for MDService2</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        <change on="2010-12-29" type="changed" by="vr">extracted function into: cmd_functions.xsl</change>
11</history>
12
13-->
14
15<xsl:include href="cmd_functions.xsl"/>
16
17<!--<xsl:include href="params.xsl"/>-->
18
19<!-- <xsl:param name="mode" select="'html'" /> -->
20
21<!-- moved to cmd_functions.xsl-->
22<!--<xsl:param name="dict_file" select="'dict.xml'" />-->
23<!--<xsl:variable name="dict" select="document($dict_file)" />-->
24<!--<xsl:variable name="terms_setup" select="document($terms_setup_uri)" />-->
25<!--<xsl:variable name="terms_flat" select="document($terms_flat_uri)" />-->
26
27
28
29<!-- params for include-processing
30moved to params.xsl
31        <xsl:param name="components_uri" select="'http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/'" />         
32        <xsl:param name="prefix_replace" select="'file:///C:/Users/master/3lingua/clarin/CMDI/_repo2/metadata/toolkit/components'" />
33-->
34
35        <xsl:param name="src_file" />   
36        <!--  FIXME: he? -->   
37        <xsl:param name="root_uri" select="$src_file" />               
38
39<xsl:template match="/">
40                <xsl:message>root_document-uri:<xsl:value-of select="$root_uri" /></xsl:message>               
41                <xsl:choose>                   
42                <xsl:when test="contains($format,'htmlpage')" >
43                        <xsl:call-template name="html"/>   
44                </xsl:when>
45                <xsl:otherwise>                         
46                        <xsl:call-template name="continue-root"/>   
47                </xsl:otherwise>
48         </xsl:choose>
49</xsl:template>
50
51
52<xsl:template name="html">
53
54        <html>
55        <head>
56        <title><xsl:value-of select="$title"/></title>
57
58        <link rel="stylesheet" href="{$base_dir}/style/jquery/clarindotblue/jquery-ui-1.8.5.custom.css" type="text/css" />
59        <link href="{$base_dir}/style/jquery/jquery-treeview/jquery.treeview.css" rel="stylesheet" />
60        <link href="{$base_dir}/style/jquery/treetable/jquery.treeTable.css" rel="stylesheet" ></link>
61        <link href="{$base_dir}/style/cmds-ui.css" type="text/css" rel="stylesheet"></link>
62       
63        <link href="{$base_dir}style/jquery/jquery-textboxlist/TextboxList.css" rel="stylesheet" type="text/css"></link>
64        <link href="{$base_dir}style/jquery/jquery-autocomplete/jquery.autocomplete.css" rel="stylesheet" type="text/css"></link>
65
66        <script src="{$base_dir}/scripts/jquery/js/jquery-1.4.2.js" type="text/javascript"></script>
67        <script src="{$base_dir}/scripts/jquery/js/jquery-ui-1.8.5.custom.min.js" type="text/javascript"></script>
68        <script src="{$base_dir}/scripts/jquery/jquery-treeview/jquery.treeview.js" type="text/javascript"></script>
69        <script src="{$base_dir}/scripts/jquery/jquery-treeTable/jquery.treeTable.js" type="text/javascript"></script>
70        <script src="{$base_dir}/scripts/mdservice_helpers.js" type="text/javascript"></script>
71        <!-- <script src="scripts/jquery/jquery-autocomplete/jquery.autocomplete.js" type="text/javascript"></script>
72       
73        <script src="scripts/mdservice_searchclause.js" type="text/javascript"></script>
74        <script src="scripts/mdservice_model.js" type="text/javascript"></script>
75        <script src="scripts/mdservice2_ui.js" type="text/javascript"></script>
76          -->
77
78        <xsl:call-template name="callback-header"/> 
79        </head>
80        <body>
81                <h1><xsl:value-of select="$title"/></h1>               
82                        <xsl:call-template name="continue-root"/>   
83        </body>
84        </html>
85</xsl:template>
86
87<xsl:template name="callback-header">
88
89</xsl:template>
90
91<!--
92<xsl:template name="continue-root">
93
94</xsl:template>
95 -->
96    <!-- Start includes -->
97   
98    <!-- resolve includes -->
99    <xsl:template match="@*|node()" mode="include">
100        <xsl:copy>
101            <xsl:apply-templates select="@*|node()" mode="include"/>
102        </xsl:copy>
103    </xsl:template>
104
105
106    <xsl:template match="CMD_Component[@ComponentId]" mode="include">
107   
108                <!-- <xsl:param name="resolved_path" select="if (matches(@filename, $prefix)) then $prefix_replace else './'" /> -->
109
110                <!-- <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)" /> -->
111                <!--  <xsl:variable name="resolved_fn" select="concat($components_uri, @ComponentId)" />  -->
112                <xsl:variable name="resolved_fn" select="concat($components_uri, my:extractID(@ComponentId))" />   
113            <xsl:variable name="compid" select="@ComponentId" /> 
114               
115        <!-- <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')" /> -->
116       
117        <xsl:message>resolved_fn:<xsl:value-of select="$resolved_fn" /></xsl:message>
118        <xsl:message>document-uri:<xsl:value-of select="document-uri(/)" /></xsl:message>
119        <!-- some of the outer CMD_Component attributes can overwrite the inner CMD_Component attributes -->
120       
121        <xsl:variable name="outer-attr" select="@CardinalityMin|@CardinalityMax"/>
122        <xsl:for-each select="document($resolved_fn)/CMD_ComponentSpec/CMD_Component">
123            <xsl:variable name="inner-attr" select="@*"/>
124            <xsl:copy>
125                        <!-- <xsl:attribute name="filename" select="replace($resolved_fn,$prefix_replace,'')" /> -->
126               
127                        <xsl:attribute name="ComponentId" select="$compid" />
128                <xsl:apply-templates select="$outer-attr" mode="include"/>
129                <xsl:apply-templates select="$inner-attr[not(node-name(.) = $outer-attr/node-name(.))]" mode="include"/>
130                <xsl:apply-templates select="node()" mode="include">
131        <!--            <xsl:with-param name="resolved_path" select="$resolved_path" /> -->
132                </xsl:apply-templates>
133            </xsl:copy>
134        </xsl:for-each>
135    </xsl:template>
136   
137
138    <xsl:template match="componentDescription[id] | profileDescription[id]" mode="include">
139   
140        <!--  <xsl:variable name="resolved_uri" select="concat($root_uri, '/', id)" />-->
141        <xsl:variable name="resolved_uri" select="concat($cmdprofiles_uri , '/', my:extractID(id))" /> 
142       
143       
144        <xsl:message>resolved_uri:<xsl:value-of select="$resolved_uri" /></xsl:message>
145        <xsl:message>document-uri:<xsl:value-of select="document-uri(/)" /></xsl:message>
146               
147        <xsl:copy>             
148                <xsl:apply-templates mode="include" />
149                <xsl:apply-templates select="document($resolved_uri)" mode="include" />
150                <!-- <xsl:copy-of select="document($resolved_uri)" /> -->
151                <!-- <xsl:copy-of select="document(id, $root_uri)" />  -->
152        </xsl:copy>
153    </xsl:template>
154       
155    <!-- Stop includes -->
156
157<!--  generic templates -->
158<xsl:template name="attr-detail-div" >
159                <div class="detail">
160                        <xsl:for-each select="@*" >
161                                <div class="cmds-elem-prop"><span class="label"><xsl:value-of select="name()" />: </span>
162                                        <span class="value"><xsl:value-of select="." /></span></div>
163                        </xsl:for-each>
164                </div>
165</xsl:template>
166
167<xsl:template name="format-field" >
168        <xsl:param name="elems" />
169                                        <xsl:choose>
170                                                 <xsl:when test="$elems/*" >                                   
171                                                                <xsl:apply-templates select="$elems" mode="format-xmlelem" >   
172                                                                </xsl:apply-templates>                                                 
173                                                </xsl:when>
174                                                <xsl:when test="count($elems) &gt; 1" >
175                                                        <ul>
176                                                                <xsl:for-each select="$elems" >                                                 
177                                                                        <li><xsl:call-template name="format-value" /></li>
178                                                                </xsl:for-each>
179                                                        </ul>
180                                                </xsl:when>
181                                                <xsl:otherwise>
182                                                        <xsl:call-template name="format-value">
183                                                                <xsl:with-param name="value" select="$elems" />
184                                                        </xsl:call-template>                                                   
185                                                </xsl:otherwise>                       
186                                        </xsl:choose>
187                                         
188</xsl:template>
189
190<xsl:template name="format-value" >
191<xsl:param name="value" select="."/>
192        <!-- cnt_value:<xsl:value-of select="count($value)" />  -->
193                                        <xsl:choose>
194                                                 <xsl:when test="starts-with($value[1], 'http:') " >
195                                                                <a target="_blank" class="external" href="{$value}"><xsl:value-of select="$value"></xsl:value-of></a>
196                                                </xsl:when>
197                                                <xsl:otherwise>
198                                                                <xsl:value-of select="$value" />
199                                                </xsl:otherwise>
200                                        </xsl:choose>
201</xsl:template>                                 
202
203<!-- copied from mdinst2view.xsl -->
204<xsl:template match="*" mode="format-xmlelem" >
205       
206        <xsl:if test="exists(.//text()) or @*" >
207                <xsl:variable name="has_text" >
208                        <xsl:choose>
209                                <xsl:when test="normalize-space(text()[1])='Unspecified'">unspecified</xsl:when>
210                                <xsl:when test="not(normalize-space(string-join(text(),''))='')">text</xsl:when>                               
211                                <xsl:otherwise>empty</xsl:otherwise>
212                        </xsl:choose>                   
213                </xsl:variable>
214                <xsl:variable name="has_children" select="if(*) then 'has-children' else ''"  />
215                       
216                <div class="cmds-xmlelem {$has_children} value-{$has_text}" >           
217                                <span class="label"><xsl:value-of select="name()" />:</span>
218                                <span class="value"><xsl:call-template name="format-value" > 
219                                                                                <xsl:with-param name="value" select="text()[.!='']" />
220                                                                        </xsl:call-template>
221                                </span>
222                        <xsl:apply-templates select="*" mode="format-xmlelem"/>
223                        <xsl:if test="@*">
224                                <div class="attributes">
225                                        <xsl:apply-templates select="@*" mode="format-attr"/>
226                                </div>
227                        </xsl:if>
228                </div> 
229        </xsl:if>
230</xsl:template> 
231
232<xsl:template match="@*" mode="format-attr">
233        <span class="label">@<xsl:value-of select="name()" />: </span><span class="value"><xsl:call-template name="format-value" /><!--<xsl:value-of select="." /> --></span>;
234</xsl:template> 
235
236
237</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.