root/juggler/branches/2.2/modules/vrjuggler/data/xslt/2.0a1-2.0a2.xsl

Revision 19729, 12.7 kB (checked in by patrick, 2 years ago)

Copyright update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!-- *********** <auto-copyright.pl BEGIN do not edit this line> *********** -->
4 <!--
5  VR Juggler is (C) Copyright 1998-2007 by Iowa State University
6
7  Original Authors:
8    Allen Bierbaum, Christopher Just,
9    Patrick Hartling, Kevin Meinert,
10    Carolina Cruz-Neira, Albert Baker
11
12  This library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU Library General Public
14  License as published by the Free Software Foundation; either
15  version 2 of the License, or (at your option) any later version.
16
17  This library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  Library General Public License for more details.
21
22  You should have received a copy of the GNU Library General Public
23  License along with this library; if not, write to the
24  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25  Boston, MA 02111-1307, USA.
26  -->
27 <!-- ************ <auto-copyright.pl END do not edit this line> ************ -->
28
29 <!--
30   This stylesheet provides an upgrade path for VR Juggler 2.0 Alpha 1
31   configuration files to changes made for VR Juggler 2.0 Alpha 2.
32
33      xsltproc -o new-file.config 2.0a1-2.0a2.xsl old-file.config
34
35   or
36
37      xalan -in old-file.config -xsl 2.0a1-2.0a2.xsl -out new-file.config
38
39  -->
40
41 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
42   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
43
44   <!-- Define a handy way to insert newlines when necessary. -->
45   <xsl:variable name="newline">
46 <xsl:text>
47 </xsl:text>
48   </xsl:variable>
49
50   <xsl:template match="/">
51
52     <!-- Create the new XML tree. -->
53     <xsl:element name="ConfigChunkDB">
54       <xsl:value-of select="$newline"/>
55       <xsl:for-each select="ConfigChunkDB/*">
56         <xsl:apply-templates select="."/>
57       </xsl:for-each>
58     </xsl:element>
59
60     <xsl:message>
61       <xsl:text>Processing is complete.  You should now use VRJConfig</xsl:text>
62       <xsl:value-of select="$newline"/>
63       <xsl:text>to verify the results and make any necessary changes.</xsl:text>
64       <xsl:value-of select="$newline"/>
65     </xsl:message>
66   </xsl:template>
67
68   <!-- Rename Keyboard elements to EventWindow. -->
69   <xsl:template match="Keyboard">
70     <xsl:element name="EventWindow">
71       <xsl:attribute name="name">
72         <xsl:value-of select="@name"/>
73       </xsl:attribute>
74       <xsl:value-of select="$newline"/>
75       <xsl:for-each select="./*">
76         <xsl:copy-of select="."/>
77         <xsl:value-of select="$newline"/>
78       </xsl:for-each>
79     </xsl:element>
80     <xsl:value-of select="$newline"/>
81   </xsl:template>
82
83   <!-- Rename KeyboardProxy elements to EventWindowProxy. -->
84   <xsl:template match="KeyboardProxy">
85     <xsl:element name="EventWindowProxy">
86       <xsl:attribute name="name">
87         <xsl:value-of select="@name"/>
88       </xsl:attribute>
89       <xsl:value-of select="$newline"/>
90       <xsl:for-each select="./*">
91         <xsl:copy-of select="."/>
92         <xsl:value-of select="$newline"/>
93       </xsl:for-each>
94     </xsl:element>
95     <xsl:value-of select="$newline"/>
96   </xsl:template>
97
98   <!--
99     Lots of changes have been made to displayWindow.  This template handles
100     all of them.
101   -->
102   <xsl:template match="displayWindow">
103     <xsl:element name="displayWindow">
104       <xsl:attribute name="name">
105         <xsl:value-of select="@name"/>
106       </xsl:attribute>
107       <xsl:value-of select="$newline"/>
108
109       <!--
110         Check to see if we have any sim_viewport properties.  If we do, then
111         we have to enable this window so that it acts as an event source.
112         The test for that is done below.
113       -->
114       <xsl:variable name="sim_viewport_count">
115         <xsl:value-of select="count(sim_viewports)"/>
116       </xsl:variable>
117
118       <!--
119         Loop over all the properties.  We will look for specific properies
120         that have to change.  All others are left untouched.
121       -->
122       <xsl:for-each select="./*">
123         <xsl:choose>
124           <!-- act_as_keyboard_device is now act_as_event_source. -->
125           <xsl:when test="name() = 'act_as_keyboard_device'">
126             <xsl:element name="act_as_event_source">
127               <xsl:choose>
128                 <!--
129                   If we have 1 or more sim_viewports properties, this
130                   displayWindow has to act as an event source.
131                 -->
132                 <xsl:when test="$sim_viewport_count &gt; 0">
133                   <xsl:text>true</xsl:text>
134                 </xsl:when>
135                 <!-- Otherwise, we leave the setting as it was. -->
136                 <xsl:otherwise>
137                   <xsl:value-of select="."/>
138                 </xsl:otherwise>
139               </xsl:choose>
140             </xsl:element>
141             <xsl:value-of select="$newline"/>
142           </xsl:when>
143           <!-- keyboard_device_chunk is now event_window_device. -->
144           <xsl:when test="name() = 'keyboard_device_chunk'">
145             <xsl:element name="event_window_device">
146               <xsl:value-of select="$newline"/>
147
148               <!-- event_window_device needs to contain an EventWindow. -->
149               <xsl:apply-templates select="./Keyboard"/>
150             </xsl:element>
151             <xsl:value-of select="$newline"/>
152           </xsl:when>
153           <!--
154             The structure of simViewport elements has changed, so we need to
155             apply the simViewport template to each one that we have.
156           -->
157           <xsl:when test="name() = 'sim_viewports'">
158             <xsl:element name="sim_viewports">
159               <xsl:value-of select="$newline"/>
160               <xsl:apply-templates select="./simViewport"/>
161             </xsl:element>
162             <xsl:value-of select="$newline"/>
163           </xsl:when>
164           <!-- All other properties are left untouched. -->
165           <xsl:otherwise>
166             <xsl:copy-of select="."/>
167             <xsl:value-of select="$newline"/>
168           </xsl:otherwise>
169         </xsl:choose>
170       </xsl:for-each>
171     </xsl:element>
172     <xsl:value-of select="$newline"/>
173   </xsl:template>
174
175   <!--
176     This handles updating simViewport elements so that they define a
177     simulator plug-in.  This just moves elements around so that the
178     simPlugIn property is filled in with a default_simulator element.
179   -->
180   <xsl:template match="simViewport">
181     <xsl:element name="simViewport">
182       <xsl:attribute name="name">
183         <xsl:value-of select="@name"/>
184       </xsl:attribute>
185       <xsl:value-of select="$newline"/>
186
187       <!-- Copy what does not need to be moved into default_simulator -->
188       <xsl:copy-of select="origin[1]"/>
189       <xsl:value-of select="$newline"/>
190       <xsl:copy-of select="origin[2]"/>
191       <xsl:value-of select="$newline"/>
192       <xsl:copy-of select="size[1]"/>
193       <xsl:value-of select="$newline"/>
194       <xsl:copy-of select="size[2]"/>
195       <xsl:value-of select="$newline"/>
196       <xsl:copy-of select="view"/>
197       <xsl:value-of select="$newline"/>
198       <xsl:copy-of select="user"/>
199       <xsl:value-of select="$newline"/>
200       <xsl:copy-of select="active"/>
201       <xsl:value-of select="$newline"/>
202       <xsl:copy-of select="vert_fov"/>
203       <xsl:value-of select="$newline"/>
204
205       <!--
206         Add the simPlugIn property and fill it in using the existing values
207         from the old structure.
208       -->
209       <xsl:element name="simPlugIn">
210         <xsl:value-of select="$newline"/>
211
212         <xsl:element name="default_simulator">
213           <xsl:attribute name="name">
214             <xsl:text>simPlugIn</xsl:text>
215           </xsl:attribute>
216           <xsl:value-of select="$newline"/>
217
218           <xsl:copy-of select="cameraPos"/>
219           <xsl:value-of select="$newline"/>
220           <xsl:copy-of select="wandPos"/>
221           <xsl:value-of select="$newline"/>
222           <xsl:copy-of select="drawProjections"/>
223           <xsl:value-of select="$newline"/>
224           <xsl:copy-of select="surfaceColor[1]"/>
225           <xsl:value-of select="$newline"/>
226           <xsl:copy-of select="surfaceColor[2]"/>
227           <xsl:value-of select="$newline"/>
228           <xsl:copy-of select="surfaceColor[3]"/>
229           <xsl:value-of select="$newline"/>
230
231           <!-- These have migrated into default_simulator from apiPerformer. -->
232           <xsl:element name="simHeadModel">
233             <xsl:text>${VJ_BASE_DIR}/share/vrjuggler/data/models/head.flt</xsl:text>
234           </xsl:element>
235           <xsl:value-of select="$newline"/>
236
237           <xsl:element name="simWandModel">
238             <xsl:text>${VJ_BASE_DIR}/share/vrjuggler/data/models/wand.flt</xsl:text>
239           </xsl:element>
240           <xsl:value-of select="$newline"/>
241         </xsl:element>
242         <xsl:value-of select="$newline"/>
243       </xsl:element>
244       <xsl:value-of select="$newline"/>
245     </xsl:element>
246     <xsl:value-of select="$newline"/>
247   </xsl:template>
248
249   <!-- apiPerformer is no longer used. -->
250   <xsl:template match="apiPerformer">
251   </xsl:template>
252
253   <!-- The plug-in handling in ClusterManager changed. -->
254   <xsl:template match="ClusterManager">
255     <xsl:variable name="barrier_node">
256       <xsl:value-of select="barrier_master"/>
257     </xsl:variable>
258
259     <xsl:element name="ClusterManager">
260       <xsl:attribute name="name">
261         <xsl:value-of select="@name"/>
262       </xsl:attribute>
263       <xsl:value-of select="$newline"/>
264
265       <xsl:element name="barrier_master">
266         <xsl:value-of select="barrier_master"/>
267       </xsl:element>
268       <xsl:value-of select="$newline"/>
269
270       <xsl:for-each select="./cluster_nodes">
271         <xsl:copy-of select="."/>
272         <xsl:value-of select="$newline"/>
273       </xsl:for-each>
274
275       <xsl:for-each select="./clusterPlugin">
276         <xsl:variable name="plugin">
277           <xsl:value-of select="."/>
278         </xsl:variable>
279
280         <xsl:element name="clusterPlugin">
281           <xsl:text>${VJ_BASE_DIR}/lib/gadgeteer/plugins/lib</xsl:text>
282           <xsl:value-of select="."/>
283           <xsl:text>.so</xsl:text>
284         </xsl:element>
285         <xsl:value-of select="$newline"/>
286       </xsl:for-each>
287     </xsl:element>
288     <xsl:value-of select="$newline"/>
289
290     <xsl:element name="SwapLockTCPPlugin">
291       <xsl:attribute name="name">
292         <xsl:text>SwapLockTCPPlugin</xsl:text>
293       </xsl:attribute>
294       <xsl:value-of select="$newline"/>
295
296       <xsl:element name="sync_server">
297         <xsl:value-of select="$barrier_node"/>
298       </xsl:element>
299       <xsl:value-of select="$newline"/>
300
301       <xsl:element name="listen_port">
302         <xsl:text>8001</xsl:text>
303       </xsl:element>
304       <xsl:value-of select="$newline"/>
305     </xsl:element>
306     <xsl:value-of select="$newline"/>
307
308     <xsl:element name="StartBarrierPlugin">
309       <xsl:attribute name="name">
310         <xsl:text>StartBarrierPlugin</xsl:text>
311       </xsl:attribute>
312       <xsl:value-of select="$newline"/>
313
314       <xsl:element name="start_master">
315         <xsl:value-of select="$barrier_node"/>
316       </xsl:element>
317       <xsl:value-of select="$newline"/>
318     </xsl:element>
319     <xsl:value-of select="$newline"/>
320   </xsl:template>
321
322   <!--
323     XXX: We can't match everything, but we don't have anything specific to
324     match because all the elements are user-defined.
325   -->
326   <xsl:template match="*">
327     <!--
328       We have to handle elements with keyboardProxy properties differently
329       than all other elements.  Those had their keyboardProxy property
330       renamed to eventWindowProxy.
331     -->
332     <xsl:choose>
333       <xsl:when test="count(./keyboardProxy) &gt; 0">
334         <!--
335           Create a new configuration element with the same name as the
336           existing element.  Tricky, huh?  :)
337         -->
338         <xsl:element name="{name()}">
339           <xsl:attribute name="name">
340             <xsl:value-of select="@name"/>
341           </xsl:attribute>
342           <xsl:value-of select="$newline"/>
343
344           <!-- Now iterate over the properties, looking for keyboardProxy. -->
345           <xsl:for-each select="./*">
346             <xsl:choose>
347               <!-- Rename keyboardProxy to eventWindowProxy. -->
348               <xsl:when test="name() = 'keyboardProxy'">
349                 <xsl:element name="eventWindowProxy">
350                   <xsl:value-of select="."/>
351                 </xsl:element>
352                 <xsl:value-of select="$newline"/>
353               </xsl:when>
354               <!-- Copy everything other property without modification. -->
355               <xsl:otherwise>
356                 <xsl:copy-of select="."/>
357                 <xsl:value-of select="$newline"/>
358               </xsl:otherwise>
359             </xsl:choose>
360           </xsl:for-each>
361         </xsl:element>
362         <xsl:value-of select="$newline"/>
363       </xsl:when>
364       <!--
365         Configuration elements that do not have a keyboardProxy property
366         are left untouched.
367       -->
368       <xsl:otherwise>
369         <xsl:copy-of select="."/>
370         <xsl:value-of select="$newline"/>
371       </xsl:otherwise>
372     </xsl:choose>
373   </xsl:template>
374
375 </xsl:stylesheet>
Note: See TracBrowser for help on using the browser.