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

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

changes to columns, terms (unfinished) ; .ui-context-dialog

File size: 8.3 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:message>components_uri:<xsl:value-of select="$components_uri" /></xsl:message>
42                <xsl:choose>                   
43                <xsl:when test="contains($format,'htmlpage')" >
44                        <xsl:call-template name="html"/>   
45                </xsl:when>
46                <xsl:otherwise>                         
47                        <xsl:call-template name="continue-root"/>   
48                </xsl:otherwise>
49         </xsl:choose>
50</xsl:template>
51
52
53<xsl:template name="html">
54
55        <html>
56        <head>
57        <title><xsl:value-of select="$title"/></title>
58
59        <link rel="stylesheet" href="{$base_dir}/style/jquery/clarindotblue/jquery-ui-1.8.5.custom.css" type="text/css" />
60        <link href="{$base_dir}/style/jquery/jquery-treeview/jquery.treeview.css" rel="stylesheet" />
61        <link href="{$base_dir}/style/jquery/treetable/jquery.treeTable.css" rel="stylesheet" ></link>
62        <link href="{$base_dir}/style/cmds-ui.css" type="text/css" rel="stylesheet"></link>
63       
64        <link href="{$base_dir}style/jquery/jquery-textboxlist/TextboxList.css" rel="stylesheet" type="text/css"></link>
65        <link href="{$base_dir}style/jquery/jquery-autocomplete/jquery.autocomplete.css" rel="stylesheet" type="text/css"></link>
66
67        <script src="{$base_dir}/scripts/jquery/js/jquery-1.4.2.js" type="text/javascript"></script>
68        <script src="{$base_dir}/scripts/jquery/js/jquery-ui-1.8.5.custom.min.js" type="text/javascript"></script>
69        <script src="{$base_dir}/scripts/jquery/jquery-treeview/jquery.treeview.js" type="text/javascript"></script>
70        <script src="{$base_dir}/scripts/jquery/jquery-treeTable/jquery.treeTable.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="count($elems/*) &gt; 1" >
171                                                        STRUCTURE!
172                                                        <ul>
173                                                                <xsl:for-each select="$elems" >                                                 
174                                                                        <li><xsl:call-template name="format-value" /></li>
175                                                                </xsl:for-each>
176                                                        </ul>
177                                                </xsl:when>
178                                                <xsl:when test="count($elems) &gt; 1" >
179                                                        <ul>
180                                                                <xsl:for-each select="$elems" >                                                 
181                                                                        <li><xsl:call-template name="format-value" /></li>
182                                                                </xsl:for-each>
183                                                        </ul>
184                                                </xsl:when>
185                                                <xsl:otherwise>
186                                                        <xsl:call-template name="format-value">
187                                                                <xsl:with-param name="value" select="$elems" />
188                                                        </xsl:call-template>                                                   
189                                                </xsl:otherwise>                       
190                                        </xsl:choose>
191                                         
192</xsl:template>
193
194<xsl:template name="format-value" >
195<xsl:param name="value" select="."/>
196        <!-- cnt_value:<xsl:value-of select="count($value)" />  -->
197                                        <xsl:choose>
198                                                 <xsl:when test="starts-with($value[1], 'http:') " >
199                                                                <a target="_blank" class="external" href="{$value}"><xsl:value-of select="$value"></xsl:value-of></a>
200                                                </xsl:when>
201                                                <xsl:otherwise>
202                                                                <xsl:value-of select="$value" />
203                                                </xsl:otherwise>
204                                        </xsl:choose>
205</xsl:template>                                 
206
207
208
209</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.