source: MDService2/trunk/MDService2/src/xsl/mdinst2view.xsl @ 1495

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

started cleaning up code, adding inline-documentation;
also changes to output method in xsl (xhtml)

File size: 4.6 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet
3  version="2.0"
4  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5  xmlns:xs="http://www.w3.org/2001/XMLSchema"
6 xmlns:my="myFunctions" 
7>
8<!--
9<purpose> generate a generic html view of a CMDI-instance.</purpose>
10<params>
11<param name=""></param>
12</params>
13<history>
14        <change on="2009-12-31" type="created" by="vr">from cmd2view.xsl (no adaptation yet)</change>   
15        <change on="2010-03-20" type="changed" by="vr">only started to rework</change> 
16        <change on="2010-03-26" type="changed" by="vr">include cmd_commons.xsl</change>
17        <change on="2010-07-11" type="changed" by="vr">integrate into MDService</change>
18</history>
19-->
20   
21<!--  method="xhtml" is saxon-specific! prevents  collapsing empty <script> tags, that makes browsers choke -->
22<xsl:output method="xhtml" media-type="application/xhtml+xml" indent="yes" encoding="UTF-8" 
23doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" /> 
24
25
26<xsl:include href="cmd_commons.xsl"/>
27
28<xsl:param name="base_uri" select="'file:///C:/Users/master/3lingua/clarin/CMDI/data/C4_cmds/'" />   
29
30<!--   <xsl:param name="mode" select="'htmldiv'" /> -->
31<xsl:param name="title" />
32<xsl:param name="inner_title" >
33<!-- Gather just first title/name or something -->     
34        <xsl:variable name="titles" select="(//Title|//title|//ResourceName|//Name|//name)" /> 
35                <!--  <xsl:variable name="titles">                                                                       
36                                        <xsl:choose>
37                                        <xsl:when test="exists(//Title/text())">
38                                                        <xsl:copy-of select="//Title" />
39                                        </xsl:when>
40                                        <xsl:when test="exists(//title/text())">
41                                                        <xsl:copy-of select="//title" />
42                                        </xsl:when>
43                                        <xsl:otherwise>
44                                                        <xsl:copy-of select="(//Name|//name)" />
45                                        </xsl:otherwise>
46                                </xsl:choose>
47                </xsl:variable>
48                 -->
49                <!--<xsl:value-of select="count($titles)" /> -->
50                <xsl:value-of select="$titles[1]" />                   
51</xsl:param>
52
53<xsl:template name="continue-root" >
54
55        <div class="mdrecord-detail" >
56                <xsl:choose>
57                        <xsl:when test="contains($format,'htmlpage')">
58                                <h3><xsl:value-of select="$inner_title" /></h3>
59                                <xsl:call-template name="getContext" />
60                        </xsl:when>     
61                        <xsl:otherwise>
62                       
63                        <xsl:call-template name="getContext" />
64                        <!-- <div class="is-part-of collections" ><xsl:value-of select=".//IsPartOf[@level=1]" /> </div> -->
65                        <div class="title" ><xsl:call-template name="getName" /></div>
66                        <!--
67                                <span class="inner_title"><xsl:attribute name="value"><xsl:value-of select="$inner_title"/>
68                                </xsl:attribute>
69                                </span>
70                                -->
71                        </xsl:otherwise>
72                </xsl:choose>           
73         <!--<span class="label">MDRecord View: </span>
74                <div class="title" ><xsl:value-of select="$inner_title"/></div>--> 
75       
76               
77                <xsl:apply-templates select=".//ResourceProxyList" />
78                <xsl:apply-templates select=".//Components/*" mode="format-xmlelem" />
79        </div> 
80</xsl:template> 
81
82       
83<xsl:template match="ResourceProxyList" >
84                <xsl:choose>
85                        <xsl:when test="count(ResourceProxy) &gt; 1"> 
86                                <div class="resource-links">
87                                        <span class="detail-caller">
88                                                <span class="cmd cmd_up" ></span><span class="label" >references </span><xsl:value-of select="count(ResourceProxy[ResourceType='Metadata'])" /> <span class="label" > MDRecords, </span> 
89                                                                        <xsl:value-of select="count(ResourceProxy[ResourceType='Resource'])" /> <span class="label" > Resources</span>
90                                        </span>                                 
91                                        <ul class="detail"> 
92                                                <xsl:if test="count(ResourceProxy) &gt; $resourceref_limit" >
93                                                        <span class="label" >showing first </span> <xsl:value-of select="$resourceref_limit" /> <span class="label" > references. </span> 
94                                                        <s><a href="{concat($default_prefix, my:encodePID(./ancestor::CMD/Header/MdSelfLink))}">see more</a></s>                                                       
95                                                </xsl:if>
96                                                <xsl:apply-templates select="ResourceProxy[position() &lt; $resourceref_limit]" />
97                                        </ul>
98                                </div>
99                        </xsl:when>
100                        <xsl:otherwise>
101                                <ul>
102                                        <xsl:apply-templates />
103                                </ul>                   
104                        </xsl:otherwise>
105                </xsl:choose>
106               
107</xsl:template> 
108       
109        <xsl:template match="ResourceProxy" >
110       
111                        <xsl:variable name="href" >                                             
112                                <xsl:choose>
113                                        <xsl:when test="ResourceType='Resource'">
114                                                        <xsl:value-of select="ResourceRef" />
115                                        </xsl:when>
116                                        <xsl:otherwise>
117                                                        <xsl:value-of select="concat($default_prefix, my:encodePID(ResourceRef))" />
118                                        </xsl:otherwise>
119                                </xsl:choose>                           
120                        </xsl:variable>
121                       
122                        <xsl:variable name="class" select=" if (ResourceType='Resource') then 'external' else 'internal'" />
123                       
124                <li><span class="label" ><xsl:value-of select="ResourceType" />: </span> 
125                                <a class="{$class}" href="{$href}" target="_blank" >
126                                                <xsl:value-of select="ResourceRef" />
127                                </a>
128                </li>
129        </xsl:template> 
130
131</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.