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="html_snippets.xsl"/> |
---|
18 | |
---|
19 | <xsl:param name="src_file" /> |
---|
20 | <!-- FIXME: he? --> |
---|
21 | <xsl:param name="root_uri" select="$src_file" /> |
---|
22 | |
---|
23 | <!-- common starting point for all stylesheet; cares for unified html-envelope |
---|
24 | and passes back to the individual stylesheets for the content (via template: continue-root) --> |
---|
25 | <xsl:template match="/"> |
---|
26 | <!-- <xsl:message>root_document-uri:<xsl:value-of select="$root_uri" /></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,'htmlsimple')" > |
---|
32 | <xsl:call-template name="htmlsimple"/> |
---|
33 | </xsl:when> |
---|
34 | <xsl:otherwise> |
---|
35 | <xsl:call-template name="continue-root"/> |
---|
36 | </xsl:otherwise> |
---|
37 | </xsl:choose> |
---|
38 | </xsl:template> |
---|
39 | |
---|
40 | |
---|
41 | <xsl:template name="html"> |
---|
42 | |
---|
43 | <html xmlns="http://www.w3.org/1999/xhtml" > |
---|
44 | <head> |
---|
45 | <xsl:call-template name="html-head"></xsl:call-template> |
---|
46 | <xsl:call-template name="callback-header"/> |
---|
47 | </head> |
---|
48 | <body> |
---|
49 | |
---|
50 | <xsl:call-template name="page-header" /> |
---|
51 | |
---|
52 | <h1><xsl:value-of select="$title"/></h1> |
---|
53 | |
---|
54 | <xsl:call-template name="continue-root"/> |
---|
55 | |
---|
56 | </body> |
---|
57 | </html> |
---|
58 | </xsl:template> |
---|
59 | |
---|
60 | <!-- a html-envelope for a simple (noscript) view --> |
---|
61 | <xsl:template name="htmlsimple"> |
---|
62 | <html xmlns="http://www.w3.org/1999/xhtml" > |
---|
63 | <head> |
---|
64 | <title><xsl:value-of select="$title"/></title> |
---|
65 | <link href="{$base_dir}/style/cmds-ui.css" type="text/css" rel="stylesheet"></link> |
---|
66 | |
---|
67 | <!-- <xsl:call-template name="callback-header"/> --> |
---|
68 | </head> |
---|
69 | |
---|
70 | <xsl:call-template name="page-header" /> |
---|
71 | |
---|
72 | <body> |
---|
73 | <!-- <h1><xsl:value-of select="$title"/></h1> --> |
---|
74 | <xsl:call-template name="continue-root"/> |
---|
75 | </body> |
---|
76 | </html> |
---|
77 | </xsl:template> |
---|
78 | |
---|
79 | <xsl:template name="callback-header"> |
---|
80 | |
---|
81 | </xsl:template> |
---|
82 | |
---|
83 | <!-- |
---|
84 | <xsl:template name="continue-root"> |
---|
85 | </xsl:template> |
---|
86 | --> |
---|
87 | |
---|
88 | <!-- generic templates --> |
---|
89 | <xsl:template name="attr-detail-div" > |
---|
90 | <div class="detail"> |
---|
91 | <xsl:for-each select="@*" > |
---|
92 | <div class="cmds-elem-prop"><span class="label"><xsl:value-of select="name()" />: </span> |
---|
93 | <span class="value"><xsl:value-of select="." /></span></div> |
---|
94 | </xsl:for-each> |
---|
95 | </div> |
---|
96 | </xsl:template> |
---|
97 | |
---|
98 | <xsl:template name="format-field" > |
---|
99 | <xsl:param name="elems" /> |
---|
100 | <xsl:choose> |
---|
101 | <xsl:when test="$elems/*" > |
---|
102 | <xsl:apply-templates select="$elems" mode="format-xmlelem" > |
---|
103 | </xsl:apply-templates> |
---|
104 | </xsl:when> |
---|
105 | <xsl:when test="count($elems) > 1" > |
---|
106 | <ul> |
---|
107 | <xsl:for-each select="$elems" > |
---|
108 | <li><xsl:call-template name="format-value" /></li> |
---|
109 | </xsl:for-each> |
---|
110 | </ul> |
---|
111 | </xsl:when> |
---|
112 | <xsl:otherwise> |
---|
113 | <xsl:call-template name="format-value"> |
---|
114 | <xsl:with-param name="value" select="$elems" /> |
---|
115 | </xsl:call-template> |
---|
116 | </xsl:otherwise> |
---|
117 | </xsl:choose> |
---|
118 | |
---|
119 | </xsl:template> |
---|
120 | |
---|
121 | <xsl:template name="format-value" > |
---|
122 | <xsl:param name="value" select="."/> |
---|
123 | <!-- cnt_value:<xsl:value-of select="count($value)" /> --> |
---|
124 | <xsl:choose> |
---|
125 | <xsl:when test="starts-with($value[1], 'http:') " > |
---|
126 | <a target="_blank" class="external" href="{$value}"><xsl:value-of select="$value"></xsl:value-of></a> |
---|
127 | </xsl:when> |
---|
128 | <xsl:otherwise> |
---|
129 | <xsl:value-of select="$value" /> |
---|
130 | </xsl:otherwise> |
---|
131 | </xsl:choose> |
---|
132 | </xsl:template> |
---|
133 | |
---|
134 | <!-- copied from mdinst2view.xsl |
---|
135 | generic html-view for xml-elements |
---|
136 | --> |
---|
137 | <xsl:template match="*" mode="format-xmlelem" > |
---|
138 | |
---|
139 | <xsl:if test="exists(.//text()) or @*" > |
---|
140 | <xsl:variable name="has_text" > |
---|
141 | <xsl:choose> |
---|
142 | <xsl:when test="normalize-space(text()[1])='Unspecified'">unspecified</xsl:when> |
---|
143 | <xsl:when test="not(normalize-space(string-join(text(),''))='')">text</xsl:when> |
---|
144 | <xsl:otherwise>empty</xsl:otherwise> |
---|
145 | </xsl:choose> |
---|
146 | </xsl:variable> |
---|
147 | <xsl:variable name="has_children" select="if(*) then 'has-children' else ''" /> |
---|
148 | |
---|
149 | <div class="cmds-xmlelem {$has_children} value-{$has_text}" > |
---|
150 | <span class="label"><xsl:value-of select="name()" />:</span> |
---|
151 | <span class="value"><xsl:call-template name="format-value" > |
---|
152 | <xsl:with-param name="value" select="text()[.!='']" /> |
---|
153 | </xsl:call-template> |
---|
154 | </span> |
---|
155 | <xsl:apply-templates select="*" mode="format-xmlelem"/> |
---|
156 | <xsl:if test="@*"> |
---|
157 | <div class="attributes"> |
---|
158 | <xsl:apply-templates select="@*" mode="format-attr"/> |
---|
159 | </div> |
---|
160 | </xsl:if> |
---|
161 | </div> |
---|
162 | </xsl:if> |
---|
163 | </xsl:template> |
---|
164 | |
---|
165 | <xsl:template match="@*" mode="format-attr"> |
---|
166 | <span class="label">@<xsl:value-of select="name()" />: </span><span class="value"><xsl:call-template name="format-value" /><!--<xsl:value-of select="." /> --></span>; |
---|
167 | </xsl:template> |
---|
168 | |
---|
169 | <xsl:template name="getName" > |
---|
170 | <xsl:value-of select="(.//*[lower-case(name()) = $name_element])[1]" /> |
---|
171 | </xsl:template> |
---|
172 | |
---|
173 | <xsl:template name="getContext" > |
---|
174 | <!-- <div class="is-part-of collections" ><xsl:value-of select=".//IsPartOf" /> </div>--> |
---|
175 | <xsl:apply-templates select=".//IsPartOfList" /> |
---|
176 | </xsl:template> |
---|
177 | |
---|
178 | |
---|
179 | <xsl:template match="IsPartOfList" > |
---|
180 | <div class="ispartof-list"><span class="label">in: </span> |
---|
181 | <xsl:apply-templates select=".//IsPartOf" /> |
---|
182 | </div> |
---|
183 | </xsl:template> |
---|
184 | |
---|
185 | <xsl:template match="IsPartOf" > |
---|
186 | <a class="internal" href="{concat($default_prefix, my:encodePID(.))}"><xsl:value-of select="." /></a> > |
---|
187 | </xsl:template> |
---|
188 | |
---|
189 | |
---|
190 | </xsl:stylesheet> |
---|