source: MDService2/branches/MDService_simple3/src/xsl/cmd_commons.xsl @ 1907

Last change on this file since 1907 was 1907, checked in by gaba, 12 years ago

x-context replaced $repository, fcs/xsl's used

File size: 6.8 KB
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:my="myFunctions"
4 exclude-result-prefixes="my">
5
6<!--
7<purpose>generic templates for MDService2</purpose>
8<history>
9        <change on="2010-03-19" type="created" by="vr">based on 3RMA/suki/dc4_commons.xsl</change>                     
10        <change on="2010-03-23" type="changed" by="vr">really started rework - added html wrapper, ...</change>                 
11        <change on="2010-12-29" type="changed" by="vr">extracted function into: cmd_functions.xsl</change>
12</history>
13
14-->
15
16<xsl:include href="cmd_functions.xsl"/>
17<xsl:include href="./fcs/html_snippets.xsl"/>
18
19<xsl:param name="src_file" />   
20<xsl:param name="root_uri" select="$src_file" />               
21
22<!-- common starting point for all stylesheet; cares for unified html-envelope
23and passes back to the individual stylesheets for the content (via template: continue-root) -->
24<xsl:template match="/">
25        <xsl:message>root_document-uri:<xsl:value-of select="$root_uri" /></xsl:message>               
26        <xsl:message>format:<xsl:value-of select="$format" /></xsl:message>
27                <xsl:choose>                   
28                <xsl:when test="contains($format,'htmlpage')" >
29                        <xsl:call-template name="html"/>   
30                </xsl:when>
31                <xsl:when test="contains($format,'htmljspage')" >
32                        <xsl:call-template name="htmljs"/>   
33                </xsl:when>
34                <xsl:when test="contains($format,'htmlsimple')" >
35                        <xsl:call-template name="htmlsimple"/>   
36                </xsl:when>
37                <xsl:otherwise>                         
38                        <xsl:call-template name="continue-root"/>   
39                </xsl:otherwise>
40         </xsl:choose>
41</xsl:template>
42
43
44<xsl:template name="html">
45
46        <html xmlns="http://www.w3.org/1999/xhtml" >
47        <head>
48                <xsl:call-template name="html-head"></xsl:call-template>
49                <xsl:call-template name="callback-header"/> 
50        </head>
51        <body>
52               
53                <xsl:call-template name="page-header" />       
54       
55                <h1><xsl:value-of select="$title"/></h1>
56                               
57                <xsl:call-template name="continue-root"/>
58                   
59        </body>
60        </html>
61</xsl:template>
62
63<xsl:template name="htmljs">
64
65        <html xmlns="http://www.w3.org/1999/xhtml" >
66        <head>
67                <xsl:call-template name="html-head"></xsl:call-template>
68                <xsl:call-template name="callback-header"/> 
69        </head>
70        <body>
71               
72                <xsl:call-template name="page-header" />       
73       
74                <h1><xsl:value-of select="$title"/></h1>
75                               
76                <xsl:call-template name="query-input" />
77                <xsl:call-template name="query-list" />
78                <xsl:call-template name="detail-space" />
79                <xsl:call-template name="public-space" />
80                <xsl:call-template name="user-space" />
81                <!--  <xsl:call-template name="continue-root"/>-->
82                   
83        </body>
84        </html>
85</xsl:template>
86
87<!-- a html-envelope for a simple (noscript) view -->
88<xsl:template name="htmlsimple">
89        <html xmlns="http://www.w3.org/1999/xhtml" > 
90        <head>
91                <title><xsl:value-of select="$title"/></title>
92                <link href="{$scripts_url}/style/cmds-ui.css" type="text/css" rel="stylesheet"></link>
93
94                <!-- <xsl:call-template name="callback-header"/> -->                   
95        </head>
96       
97        <xsl:call-template name="page-header" />
98               
99        <body>
100                <!-- <h1><xsl:value-of select="$title"/></h1> -->               
101                        <xsl:call-template name="continue-root"/>   
102        </body>
103        </html>
104</xsl:template>
105
106<xsl:template name="callback-header">
107
108</xsl:template>
109
110<!--
111<xsl:template name="continue-root">
112</xsl:template>
113 -->
114   
115<!--  generic templates -->
116<xsl:template name="attr-detail-div" >
117                <div class="detail">
118                        <xsl:for-each select="@*" >
119                                <div class="cmds-elem-prop"><span class="label"><xsl:value-of select="name()" />: </span>
120                                        <span class="value"><xsl:value-of select="." /></span></div>
121                        </xsl:for-each>
122                </div>
123</xsl:template>
124
125<xsl:template name="format-field" >
126        <xsl:param name="elems" />
127                                        <xsl:choose>
128                                                 <xsl:when test="$elems/*" >                                   
129                                                                <xsl:apply-templates select="$elems" mode="format-xmlelem" >   
130                                                                </xsl:apply-templates>                                                 
131                                                </xsl:when>
132                                                <xsl:when test="count($elems) &gt; 1" >
133                                                        <ul>
134                                                                <xsl:for-each select="$elems" >                                                 
135                                                                        <li><xsl:call-template name="format-value" /></li>
136                                                                </xsl:for-each>
137                                                        </ul>
138                                                </xsl:when>
139                                                <xsl:otherwise>
140                                                        <xsl:call-template name="format-value">
141                                                                <xsl:with-param name="value" select="$elems" />
142                                                        </xsl:call-template>                                                   
143                                                </xsl:otherwise>                       
144                                        </xsl:choose>
145                                         
146</xsl:template>
147
148<xsl:template name="format-value" >
149<xsl:param name="value" select="."/>
150        <!-- cnt_value:<xsl:value-of select="count($value)" />  -->
151                                        <xsl:choose>
152                                                 <xsl:when test="starts-with($value[1], 'http:') " >
153                                                                <a target="_blank" class="external" href="{$value}"><xsl:value-of select="$value"></xsl:value-of></a>
154                                                </xsl:when>
155                                                <xsl:otherwise>
156                                                                <xsl:value-of select="$value" />
157                                                </xsl:otherwise>
158                                        </xsl:choose>
159</xsl:template>                                 
160
161<!-- copied from mdinst2view.xsl
162        generic html-view for xml-elements 
163-->
164<xsl:template match="*" mode="format-xmlelem" >
165       
166        <xsl:if test="exists(.//text()) or @*" >
167                <xsl:variable name="has_text" >
168                        <xsl:choose>
169                                <xsl:when test="normalize-space(text()[1])='Unspecified'">unspecified</xsl:when>
170                                <xsl:when test="not(normalize-space(string-join(text(),''))='')">text</xsl:when>                               
171                                <xsl:otherwise>empty</xsl:otherwise>
172                        </xsl:choose>                   
173                </xsl:variable>
174                <xsl:variable name="has_children" select="if(*) then 'has-children' else ''"  />
175                       
176                <div class="cmds-xmlelem {$has_children} value-{$has_text}" >           
177                                <span class="label"><xsl:value-of select="name()" />:</span>
178                                <span class="value"><xsl:call-template name="format-value" > 
179                                                                                <xsl:with-param name="value" select="text()[.!='']" />
180                                                                        </xsl:call-template>
181                                </span>
182                        <xsl:apply-templates select="*" mode="format-xmlelem"/>
183                        <xsl:if test="@*">
184                                <div class="attributes">
185                                        <xsl:apply-templates select="@*" mode="format-attr"/>
186                                </div>
187                        </xsl:if>
188                </div> 
189        </xsl:if>
190</xsl:template> 
191
192<xsl:template match="@*" mode="format-attr">
193        <span class="label">@<xsl:value-of select="name()" />: </span><span class="value"><xsl:call-template name="format-value" /><!--<xsl:value-of select="." /> --></span>;
194</xsl:template> 
195
196<xsl:template name="getName" >
197                <xsl:value-of select="(.//*[lower-case(name()) = $name_element])[1]" /> 
198</xsl:template>
199
200<xsl:template name="getContext" >
201<!--    <div class="is-part-of collections" ><xsl:value-of select=".//IsPartOf" /> </div>-->
202        <xsl:apply-templates select=".//IsPartOfList" />
203</xsl:template>
204
205       
206<xsl:template match="IsPartOfList" >
207        <div class="ispartof-list"><span class="label">in: </span>
208                <xsl:apply-templates select=".//IsPartOf" />
209        </div>
210</xsl:template> 
211
212<xsl:template match="IsPartOf" >
213        <!-- <a class="internal" href="{concat($default_prefix, my:encodePID(.))}"><xsl:value-of select="." /></a> > -->
214        <a class="internal" href="{my:formURL('record','htmldetail', my:encodePID(.))}"><xsl:value-of select="." /></a> >
215</xsl:template> 
216
217
218</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.