source: MDService2/trunk/MDService2/src/xsl/comp2view.xsl @ 794

Last change on this file since 794 was 794, checked in by vronk, 14 years ago

finishing terms (autocomplete, htmlselect)

File size: 7.2 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--
4    $Rev: 74 $
5    $Date: 2010-03-23 $
6   
7    created based on comp2schema.xsl vronk
8-->
9
10<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
11    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dcr="http://www.isocat.org"
12    xmlns:my="myFunctions">
13    <xsl:strip-space elements="*"/>
14    <xsl:include href="cmd_commons.xsl"/>
15
16    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
17               
18        <xsl:param name="title" 
19                select="concat('Component view: ', if(/CMD_ComponentSpec/Header/Name/text()) then /CMD_ComponentSpec/Header/Name/text() else /CMD_ComponentSpec/CMD_Component[1]/@name)" />                             
20       
21    <!--  includes-mode
22          and params 
23                moved to cmd_commons.xsl -->
24   
25    <!-- main -->
26    <!-- <xsl:template match="/"> -->
27    <xsl:template name="continue-root"> 
28        <!-- Resolve all includes -->
29        <xsl:variable name="tree">
30            <xsl:apply-templates mode="include"/>
31        </xsl:variable>
32
33                <!-- Process the complete tree -->                     
34               
35                <xsl:choose>
36                <xsl:when test="$format='comp2htmldetail'" >
37                                <div id="compviewdetail">
38                                        <xsl:apply-templates select="$tree/*"/>
39                                        </div>
40                </xsl:when>
41                <xsl:when test="$format='comp2htmllist'" >                     
42                        <div id="compviewlist">
43                                <xsl:apply-templates select="$tree/*" mode="list"/>
44                        </div>
45                </xsl:when>
46                <xsl:otherwise>
47                                <div id="compviewdefault">
48                                        <xsl:apply-templates select="$tree/*" />
49                                </div>
50                </xsl:otherwise>
51         </xsl:choose>
52
53
54    </xsl:template>
55   
56
57    <!-- generate actual HTML(?)-view -->
58    <xsl:template match="/CMD_ComponentSpec">
59                                                       
60                                <div class="comp_detail">
61                                        <ul id="starttree" class="treeview">
62                                        <xsl:apply-templates />
63                                        </ul>
64                                </div>                         
65        </xsl:template>
66               
67               
68        <xsl:template match="Header">
69                <div class="note">
70                        <xsl:apply-templates />
71                </div>
72        </xsl:template>
73                               
74    <!--  generic -->
75    <xsl:template match="*">
76                <div class="elem"><span class="label"><xsl:value-of select="name()" />:</span>
77                <span class="value" ><xsl:value-of select="text()" /></span></div>             
78        </xsl:template>
79       
80       
81    <xsl:template match="CMD_Component">
82                <li>
83                        <div class="cmdcomp"><h2><span class="cmdcomp_name" ><xsl:value-of select="@name" /></span>
84                                <span  class="sub" ><xsl:value-of select="@filename" /><xsl:text> </xsl:text><xsl:apply-templates select="@ConceptLink" />
85                                        <xsl:if test="@CardinalityMin | @CardinalityMax" >
86                                                <span><xsl:value-of select="concat('{',@CardinalityMin, '..', @CardinalityMax,'}')" /></span>                   
87                                        </xsl:if>               
88                                </span>                         
89                                <xsl:if test="number(@CardinalityMax) &gt; 1 or @CardinalityMax='unbounded'" >
90                                        <span class="cmd cmd_add"><xsl:text> </xsl:text></span>                 
91                                </xsl:if>       
92                        </h2>                   
93                        <xsl:apply-templates select="AttributeList"/>                           
94                 </div>
95     
96          <!--<xsl:apply-templates select="./AttributeList"/>                   
97          <xsl:apply-templates select="./CMD_Element"/> -->
98          <!-- process all components at one level deeper (recursive call) -->
99          <!-- <xsl:apply-templates select="./CMD_Component"/> -->         
100         
101                                <ul>
102          <xsl:apply-templates select="*[not(name()='AttributeList')]"/> 
103         </ul>
104
105                        <!-- </div>              -->
106                </li>
107        </xsl:template>
108               
109        <xsl:template match="CMD_Element">
110        <li>
111                <div class="cmdelem"><span class="cmdelem_name"><xsl:value-of select="@name" /></span>
112                <span  class="sub" ><xsl:apply-templates select="@ConceptLink" />
113                        <span>[<xsl:value-of select="concat('{',@CardinalityMin, '..', @CardinalityMax,'}')" /></span>
114                </span>
115                <!--<br/>               
116                  <input type="text" id="q_{@name}" value="" name="q_{@name}" />
117                <xsl:if test="number(@CardinalityMax) &gt; 1 or @CardinalityMax='unbounded'" >
118                        <span class="cmd cmd_add"><xsl:text> </xsl:text></span>                 
119                </xsl:if>               
120                        -->
121                       
122                        <span><xsl:call-template name="valuescheme" /></span>           
123                        <xsl:apply-templates select="AttributeList" />
124                </div> 
125        </li>
126        </xsl:template>
127       
128        <xsl:template name="valuescheme" >                     
129                <xsl:if test="ValueScheme | @ValueScheme | Type" >
130                        <span class="valuescheme">             
131                                [<xsl:if test="@ValueScheme"><xsl:value-of select="concat('xs:',@ValueScheme)"/></xsl:if>
132                                 <xsl:if test="Type"><xsl:value-of select="concat('xs:',Type)"/></xsl:if>
133                                  <xsl:for-each select="ValueScheme/enumeration/item[position() &lt; $display_values_limit]" >
134                                        <span class="elem_value"><xsl:value-of select="." /></span>, </xsl:for-each>
135                                        <xsl:if test="count(ValueScheme/enumeration/item) &gt; $display_values_limit" >
136                                        ...|<xsl:value-of select="count(.//item)"/> / <xsl:value-of select="string-length(ValueScheme)"/>|
137                                        </xsl:if>
138                                ]
139                       
140                        </span>
141                </xsl:if>       
142        </xsl:template>
143       
144        <xsl:template match="@ConceptLink">
145                <span class="conceptlink">[<a href="{my:rewriteURL(.)}" ><xsl:value-of select="my:shortURL(.)" /></a>]</span>                           
146        </xsl:template>
147
148        <xsl:template match="@ComponentId">
149                <span class="componentid"><xsl:value-of select="." /></span>                           
150        </xsl:template>
151
152        <xsl:template match="AttributeList">
153                <div class="attributes">
154                                <xsl:apply-templates />
155                </div>                         
156        </xsl:template>
157       
158        <xsl:template match="Attribute">
159                <span class="attribute">@<xsl:value-of select="Name"/>
160                        <span><xsl:call-template name="valuescheme" /></span>           
161                </span>                         
162        </xsl:template>
163
164
165
166 <!--  LIST  --> 
167 
168 <xsl:template match="/CMD_ComponentSpec" mode="list">
169                        <xsl:apply-templates select="Header" mode="list"/> 
170                <!--   srcfile:<xsl:value-of select="$src_file" /> -->
171                       
172                                <ul id="starttree" class="treeview">
173                                        <xsl:apply-templates select="CMD_Component" mode="list">
174                                        </xsl:apply-templates> 
175                                </ul>                           
176        </xsl:template>
177                       
178        <xsl:template match="Header" mode="list">
179                <div class="note">
180                        <xsl:apply-templates />
181                </div>
182        </xsl:template>
183
184  <xsl:template match="CMD_Component" mode="list">
185                <xsl:variable name="detail_uri" select="if(@ComponentId) then concat($detail_comp_prefix, my:extractID(@ComponentId)) else concat($detail_profile_prefix, my:extractID(parent::CMD_ComponentSpec/Header/ID))" />
186                <li><a href="{$detail_uri}" ><xsl:value-of select="@name" /></a>
187                        <span class="data comppath" ><xsl:value-of select="my:context(.)" /></span>
188                       
189                <span class="cmd cmd_filter"><xsl:text> </xsl:text></span><span class="cmd cmd_detail" ><xsl:text> </xsl:text></span>
190                <!--
191                <div class="cmdcomp"><h2><xsl:value-of select="@name" />
192                <span  class="sub" ><xsl:value-of select="@filename" /><xsl:text> </xsl:text><xsl:apply-templates select="@ConceptLink" />
193                </span>
194                </h2>                   -->
195                <ul>
196        <xsl:apply-templates select="./*" mode="list"/> 
197    </ul>
198    </li>
199
200        </xsl:template>
201                       
202        <xsl:template match="CMD_Element" mode="list">
203                        <li><xsl:value-of select="@name" />
204                                <span class="data comppath" ><xsl:value-of select="my:context(.)" /></span>
205                                <span class="cmd cmd_filter"><xsl:text> </xsl:text></span><span class="cmd cmd_detail" ><xsl:text> </xsl:text></span>
206                        </li>
207                       
208                <!--
209                <span  class="sub" ><xsl:apply-templates select="@ConceptLink" /></span></h4>           
210                        <span>[<xsl:value-of select="concat('{',@CardinalityMin, '..', @CardinalityMax,'}')" /></span>
211                        <span><xsl:call-template name="valuescheme" /></span>           
212                </div>           
213                -->
214        </xsl:template>
215       
216
217
218</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.