root/juggler/branches/2.2/modules/vrjuggler/data/xslt/2.0a4-2.0b1.xsl

Revision 19729, 16.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
31    This stylesheet provides an upgrade path for VR Juggler 2.0 Alpha 4
32    configuration files to changes made for VR Juggler 2.0 Beta 1.
33
34       xsltproc -o new-file.jconf 2.0a4-2.0b1.xsl old-file.jconf
35
36    or
37
38       xalan -in old-file.jconf -xsl 2.0a4-2.0b1.xsl -out new-file.jconf
39
40 -->
41
42 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
43                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44                 xmlns:jconf="http://www.vrjuggler.org/jccl/xsd/3.0/configuration">
45    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
46
47    <!-- Define a handy way to insert newlines when necessary. -->
48    <xsl:variable name="newline">
49 <xsl:text>
50 </xsl:text>
51    </xsl:variable>
52
53    <!-- The namespace for JCCL configuration files. -->
54    <xsl:variable name="jconf_schema">
55       <xsl:text>http://www.vrjuggler.org/jccl/xsd/3.0/configuration</xsl:text>
56    </xsl:variable>
57
58    <!-- The schema for JCCL configuration files. -->
59    <xsl:variable name="jconf_schema_file">
60       <xsl:text>http://www.vrjuggler.org/jccl/xsd/3.0/configuration.xsd</xsl:text>
61    </xsl:variable>
62
63    <xsl:template match="/">
64      <!-- Add the file format version information. -->
65      <xsl:processing-instruction name="org-vrjuggler-jccl-settings">configuration.version="3.0"</xsl:processing-instruction>
66       <xsl:value-of select="$newline"/>
67
68       <xsl:apply-templates />
69
70       <xsl:message>
71          <xsl:text>Processing is complete.  You should now use VRJConfig</xsl:text>
72          <xsl:value-of select="$newline"/>
73          <xsl:text>to verify the results and make any necessary changes.</xsl:text>
74          <xsl:value-of select="$newline"/>
75       </xsl:message>
76    </xsl:template>
77
78    <xsl:template match="jconf:configuration">
79       <xsl:copy>
80
81          <!-- XXX: Why doesn't xsl:copy copy these two attributes? -->
82          <xsl:attribute name="name">
83             <xsl:value-of select="@name"/>
84          </xsl:attribute>
85          <xsl:attribute name="xsl:schemaLocation"
86                         namespace="http://www.w3.org/2001/XMLSchema-instance">
87             <xsl:value-of select="@xsi:schemaLocation"/>
88          </xsl:attribute>
89
90          <xsl:apply-templates />
91       </xsl:copy>
92    </xsl:template>
93
94    <xsl:template match="jconf:include">
95       <xsl:copy-of select="." />
96    </xsl:template>
97
98    <xsl:template match="jconf:elements">
99       <xsl:copy>
100          <xsl:apply-templates />
101       </xsl:copy>
102    </xsl:template>
103
104    <!-- Renames the RemoteInputManager plugin to RIMPlugin. -->
105    <xsl:template match="jconf:cluster_manager">
106       <xsl:element name="cluster_manager">
107          <xsl:attribute name="name">
108             <xsl:value-of select="@name" />
109          </xsl:attribute>
110          <xsl:attribute name="version">
111             <xsl:value-of select="@version" />
112          </xsl:attribute>
113
114          <xsl:copy-of select="./jconf:plugin_path" />
115
116          <xsl:for-each select="./jconf:plugin">
117             <xsl:variable name="plugin_name">
118                <xsl:value-of select="." />
119             </xsl:variable>
120             <xsl:choose>
121                <xsl:when test="$plugin_name = 'RemoteInputManager'">
122                   <xsl:element name="plugin">
123                      <xsl:text>RIMPlugin</xsl:text>
124                   </xsl:element>
125                </xsl:when>
126                <xsl:otherwise>
127                   <xsl:copy-of select="." />
128                </xsl:otherwise>
129             </xsl:choose>
130          </xsl:for-each>
131
132          <xsl:copy-of select="./jconf:cluster_node" />
133       </xsl:element>
134    </xsl:template>
135
136    <xsl:template match="jconf:display_window">
137       <xsl:choose>
138          <xsl:when test="@version = '2'">
139             <xsl:call-template name="check-event-source">
140                <xsl:with-param name="display_window" select="."/>
141             </xsl:call-template>
142             <xsl:copy-of select="." />
143          </xsl:when>
144          <xsl:when test="@version = '3'">
145             <xsl:call-template name="check-event-source">
146                <xsl:with-param name="display_window" select="."/>
147             </xsl:call-template>
148             <xsl:copy-of select="." />
149          </xsl:when>
150          <xsl:when test="@version = '4'">
151             <xsl:message>
152                <xsl:text>Found a display window (</xsl:text>
153                <xsl:value-of select="@name" />
154                <xsl:text>) that is already at version 4.</xsl:text>
155                <xsl:value-of select="$newline" />
156                <xsl:text>We will attempt to convert it to the "new" version 4.</xsl:text>
157                <xsl:value-of select="$newline" />
158                <xsl:text>Be sure to verify the changed settings in VRJConfig.</xsl:text>
159                <xsl:value-of select="$newline" />
160                <xsl:value-of select="$newline" />
161             </xsl:message>
162
163             <xsl:element name="display_window">
164                <xsl:attribute name="name">
165                   <xsl:value-of select="@name" />
166                </xsl:attribute>
167                <xsl:attribute name="version">
168                   <xsl:text>4</xsl:text>
169                </xsl:attribute>
170
171                <xsl:copy-of select="./jconf:origin[1]" />
172                <xsl:copy-of select="./jconf:origin[2]" />
173                <xsl:copy-of select="./jconf:size[1]" />
174                <xsl:copy-of select="./jconf:size[2]" />
175                <xsl:copy-of select="./jconf:pipe" />
176                <xsl:copy-of select="./jconf:frame_buffer_config" />
177                <xsl:copy-of select="./jconf:stereo" />
178                <xsl:copy-of select="./jconf:border" />
179                <xsl:copy-of select="./jconf:hide_mouse" />
180                <xsl:copy-of select="./jconf:active" />
181
182                <xsl:if test="count(./jconf:simulator_viewports) &gt; 0">
183                   <xsl:copy-of select="./jconf:simulator_viewports" />
184                </xsl:if>
185                <xsl:if test="count(./jconf:surface_viewports) &gt; 0">
186                   <xsl:copy-of select="./jconf:surface_viewports" />
187                </xsl:if>
188
189                <xsl:element name="keyboard_mouse_device_name" />
190                <xsl:element name="lock_key">
191                   <xsl:text>KEY_NONE</xsl:text>
192                </xsl:element>
193                <xsl:element name="start_locked">
194                   <xsl:text>false</xsl:text>
195                </xsl:element>
196                <xsl:element name="sleep_time">
197                   <xsl:text>75</xsl:text>
198                </xsl:element>
199             </xsl:element>
200          </xsl:when>
201          <xsl:otherwise>
202             <xsl:copy-of select="." />
203          </xsl:otherwise>
204       </xsl:choose>
205    </xsl:template>
206
207    <xsl:template match="jconf:event_window">
208       <xsl:variable name="km_dev_name">
209          <xsl:value-of select="@name"/>
210          <xsl:text> KM Dev</xsl:text>
211       </xsl:variable>
212
213       <xsl:element name="keyboard_mouse_device">
214          <xsl:attribute name="name">
215             <xsl:value-of select="$km_dev_name" />
216          </xsl:attribute>
217          <xsl:attribute name="version">
218             <xsl:text>1</xsl:text>
219          </xsl:attribute>
220
221          <xsl:element name="mouse_sensitivity">
222             <xsl:value-of select="./jconf:mouse_sensitivity" />
223          </xsl:element>
224          <xsl:element name="device_host">
225             <xsl:value-of select="./jconf:device_host" />
226          </xsl:element>
227       </xsl:element>
228
229       <xsl:element name="input_window">
230          <xsl:attribute name="name">
231             <xsl:value-of select="@name" />
232          </xsl:attribute>
233          <xsl:attribute name="version">
234             <xsl:text>1</xsl:text>
235          </xsl:attribute>
236
237          <xsl:element name="origin">
238             <xsl:value-of select="./jconf:origin[1]" />
239          </xsl:element>
240          <xsl:element name="origin">
241             <xsl:value-of select="./jconf:origin[2]" />
242          </xsl:element>
243
244          <xsl:choose>
245             <xsl:when test="@version = '1'">
246                <xsl:element name="size">
247                   <xsl:value-of select="./jconf:width" />
248                </xsl:element>
249                <xsl:element name="size">
250                   <xsl:value-of select="./jconf:height" />
251                </xsl:element>
252             </xsl:when>
253             <xsl:otherwise>
254                <xsl:element name="size">
255                   <xsl:value-of select="./jconf:size[1]" />
256                </xsl:element>
257                <xsl:element name="size">
258                   <xsl:value-of select="./jconf:size[2]" />
259                </xsl:element>
260             </xsl:otherwise>
261          </xsl:choose>
262
263          <xsl:element name="display_number">
264             <xsl:value-of select="./jconf:display_number" />
265          </xsl:element>
266          <xsl:element name="keyboard_mouse_device_name">
267             <xsl:value-of select="$km_dev_name" />
268          </xsl:element>
269          <xsl:element name="lock_key">
270             <xsl:value-of select="./jconf:lock_key" />
271          </xsl:element>
272          <xsl:element name="start_locked">
273             <xsl:value-of select="./jconf:start_locked" />
274          </xsl:element>
275          <xsl:element name="sleep_time">
276             <xsl:value-of select="./jconf:sleep_time" />
277          </xsl:element>
278       </xsl:element>
279    </xsl:template>
280
281    <xsl:template match="jconf:event_window_proxy">
282       <xsl:element name="keyboard_mouse_proxy">
283          <xsl:attribute name="name">
284             <xsl:value-of select="@name" />
285          </xsl:attribute>
286          <xsl:attribute name="version">
287             <xsl:text>1</xsl:text>
288          </xsl:attribute>
289          <xsl:variable name="dev_name">
290             <xsl:value-of select="./jconf:device" />
291          </xsl:variable>
292          <xsl:element name="device">
293             <xsl:choose>
294                <xsl:when test="contains($dev_name, '/event_window_device/')">
295                   <xsl:call-template name="strip-path">
296                      <xsl:with-param name="original" select="$dev_name" />
297                      <xsl:with-param name="path_sep"><xsl:text>/</xsl:text></xsl:with-param>
298                   </xsl:call-template>
299                   </xsl:when>
300                   <xsl:otherwise>
301                      <xsl:value-of select="./jconf:device" />
302                   </xsl:otherwise>
303                </xsl:choose>
304             <xsl:text> KM Dev</xsl:text>
305          </xsl:element>
306       </xsl:element>
307    </xsl:template>
308
309    <!-- Rename machine_specific to cluster_node.  -->
310    <xsl:template match="jconf:machine_specific">
311       <xsl:element name="cluster_node">
312          <xsl:attribute name="name">
313             <xsl:value-of select="@name" />
314          </xsl:attribute>
315          <xsl:attribute name="version">
316             <xsl:text>1</xsl:text>
317          </xsl:attribute>
318
319          <xsl:copy-of select="./jconf:display_system" />
320
321          <xsl:for-each select="./jconf:display_windows">
322             <xsl:copy>
323                <xsl:apply-templates />
324             </xsl:copy>
325          </xsl:for-each>
326
327          <xsl:copy-of select="./jconf:listen_port" />
328          <xsl:copy-of select="./jconf:host_name" />
329       </xsl:element>
330    </xsl:template>
331
332    <!--
333       Handle config files that already have machine_specific renamed to
334       cluster_node.  They may have embedded display_window elements that
335       need to be updated.
336    -->
337    <xsl:template match="jconf:cluster_node">
338       <xsl:copy>
339          <xsl:attribute name="name">
340             <xsl:value-of select="@name" />
341          </xsl:attribute>
342          <xsl:attribute name="version">
343             <xsl:value-of select="@version" />
344          </xsl:attribute>
345
346          <xsl:copy-of select="./jconf:display_system" />
347
348          <xsl:for-each select="./jconf:display_windows">
349             <xsl:copy>
350                <xsl:apply-templates />
351             </xsl:copy>
352          </xsl:for-each>
353
354          <xsl:copy-of select="./jconf:listen_port" />
355          <xsl:copy-of select="./jconf:host_name" />
356       </xsl:copy>
357    </xsl:template>
358
359    <xsl:template match="jconf:sound_manager">
360       <xsl:element name="sound_manager_sonix">
361          <xsl:attribute name="name">
362             <xsl:value-of select="@name" />
363          </xsl:attribute>
364          <xsl:attribute name="version">
365             <xsl:text>1</xsl:text>
366          </xsl:attribute>
367
368          <xsl:copy-of select="./jconf:api" />
369
370          <!-- The following copies all elements of the named type. -->
371          <xsl:copy-of select="./jconf:listener_position" />
372          <xsl:copy-of select="./jconf:file_search_path" />
373          <xsl:copy-of select="./jconf:sound" />
374       </xsl:element>
375    </xsl:template>
376
377
378 <!-- EVERYTHING ELSE ======================================================= -->
379    <!--
380       Copy everything that hasn't already been matched.
381    -->
382    <xsl:template match="*">
383       <xsl:copy-of select="." />
384    </xsl:template>
385
386
387 <!-- Helpers =============================================================== -->
388    <!--
389       Identifies when a display_window is configured to act as an event
390       source.  If it is conifgured thusly, then a new keyboard_mouse_device
391       element is created to stand in for the formerly embedded event_window
392       config element.
393    -->
394    <xsl:template name="check-event-source">
395       <xsl:param name="display_window"/>
396       <xsl:variable name="is_event_source">
397          <xsl:value-of select="$display_window/jconf:act_as_event_source"/>
398       </xsl:variable>
399       <xsl:choose>
400          <xsl:when test="$is_event_source = 'true'">
401             <xsl:call-template name="create-km-dev">
402                <xsl:with-param name="event_window" select="$display_window/jconf:event_window_device/jconf:event_window"/>
403             </xsl:call-template>
404          </xsl:when>
405          <xsl:when test="$is_event_source = '1'">
406             <xsl:call-template name="create-km-dev">
407                <xsl:with-param name="event_window" select="$display_window/jconf:event_window_device/jconf:event_window"/>
408             </xsl:call-template>
409          </xsl:when>
410       </xsl:choose>
411    </xsl:template>
412
413    <!--
414       Creates a new keyboard_mouse_device config element from the given
415       event_window element.
416    -->
417    <xsl:template name="create-km-dev">
418       <xsl:param name="event_window"/>
419
420       <xsl:element name="keyboard_mouse_device">
421          <xsl:attribute name="name">
422             <xsl:value-of select="$event_window/@name"/><xsl:text> KM Dev</xsl:text>
423          </xsl:attribute>
424          <xsl:attribute name="version">
425             <xsl:text>1</xsl:text>
426          </xsl:attribute>
427          <xsl:copy-of select="$event_window/jconf:mouse_sensitivity"/>
428          <xsl:copy-of select="$event_window/jconf:device_host"/>
429       </xsl:element>
430    </xsl:template>
431
432    <!--
433       Removes the path information from a full path, leaving only the last
434       element (normally a file name).  This is based on code from the XSLT
435       book.
436    -->
437    <xsl:template name="strip-path">
438       <xsl:param name="original"/>
439       <xsl:param name="path_sep"/>
440       <xsl:variable name="last">
441          <xsl:choose>
442             <xsl:when test="contains($original, $path_sep)">
443                <xsl:choose>
444                   <xsl:when test="contains(substring-after($original, $path_sep), $path_sep)">
445                      <xsl:call-template name="strip-path">
446                         <xsl:with-param name="original"><xsl:value-of select="substring-after($original, $path_sep)"/></xsl:with-param>
447                         <xsl:with-param name="path_sep"><xsl:value-of select="$path_sep"/></xsl:with-param>
448                      </xsl:call-template>
449                   </xsl:when>
450                   <xsl:otherwise>
451                      <xsl:value-of select="substring-after($original, $path_sep)"/>
452                   </xsl:otherwise>
453                </xsl:choose>
454             </xsl:when>
455             <xsl:otherwise>
456                <xsl:text></xsl:text>
457             </xsl:otherwise>
458          </xsl:choose>
459       </xsl:variable>
460       <xsl:value-of select="$last"/>
461    </xsl:template>
462
463 </xsl:stylesheet>
Note: See TracBrowser for help on using the browser.