~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to share/extensions/xaml2svg/animation.xsl

  • Committer: JazzyNico
  • Date: 2011-08-29 20:25:30 UTC
  • Revision ID: nicoduf@yahoo.fr-20110829202530-6deuoz11q90usldv
Code refactoring and merging with trunk (revision 10599).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="UTF-8"?>
2
 
 
3
 
<!--
4
 
Copyright (c) 2005-2007 Toine de Greef (a.degreef@chello.nl)
5
 
 
6
 
Permission is hereby granted, free of charge, to any person obtaining a copy
7
 
of this software and associated documentation files (the "Software"), to deal
8
 
in the Software without restriction, including without limitation the rights
9
 
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 
copies of the Software, and to permit persons to whom the Software is
11
 
furnished to do so, subject to the following conditions:
12
 
 
13
 
The above copyright notice and this permission notice shall be included in
14
 
all copies or substantial portions of the Software.
15
 
 
16
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
 
THE SOFTWARE.
23
 
-->
24
 
 
25
 
<xsl:stylesheet version="1.0" 
26
 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27
 
xmlns:xlink="http://www.w3.org/1999/xlink"
28
 
xmlns:svg="http://www.w3.org/2000/svg"
29
 
xmlns:def="Definition"
30
 
exclude-result-prefixes="def">
31
 
<xsl:strip-space elements="*" />
32
 
<xsl:output method="xml" encoding="ISO-8859-1"/>
33
 
 
34
 
<xsl:template name="template_animation">
35
 
  <xsl:if test="@From"><xsl:attribute name="from"><xsl:value-of select="@From" /></xsl:attribute></xsl:if>
36
 
  <xsl:if test="@To"><xsl:attribute name="to"><xsl:value-of select="@To" /></xsl:attribute></xsl:if>
37
 
  <xsl:if test="@Duration"><xsl:attribute name="dur"><xsl:value-of select="@Duration" /></xsl:attribute></xsl:if>
38
 
  <xsl:if test="@RepeatDuration"><xsl:attribute name="repeatDur"><xsl:value-of select="translate(@RepeatDuration, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" /></xsl:attribute></xsl:if>
39
 
  <xsl:if test="@RepeatCount"><xsl:attribute name="repeatCount"><xsl:value-of select="@RepeatCount" /></xsl:attribute></xsl:if>
40
 
  <xsl:if test="@AutoReverse">
41
 
    <xsl:attribute name="fill">
42
 
      <xsl:choose>
43
 
        <xsl:when test="@AutoReverse = 'True'">remove</xsl:when>
44
 
        <xsl:otherwise>freeze</xsl:otherwise>
45
 
      </xsl:choose>
46
 
    </xsl:attribute>  
47
 
  </xsl:if>
48
 
</xsl:template>
49
 
 
50
 
<xsl:template name="template_timeline_animations">
51
 
  <xsl:variable name="id" select="@ID" />
52
 
  <xsl:variable name="name" select="@Name" />
53
 
  <xsl:apply-templates select="//*[name(.) = 'SetterTimeline' and ($id = @TargetID or $name = @TargetName)]" />
54
 
</xsl:template>
55
 
 
56
 
<xsl:template name="template_animation_path">
57
 
  <xsl:param name="target" />
58
 
  <xsl:choose>
59
 
    <xsl:when test="$target = '(Line.X2)'">x2</xsl:when>
60
 
    <xsl:when test="$target = '(Rectangle.Opacity)'">opacity</xsl:when>
61
 
  </xsl:choose>
62
 
</xsl:template>
63
 
 
64
 
<xsl:template match="*[name(.) = concat(name(..), '.Storyboards')]">
65
 
  <!--xsl:apply-templates /-->
66
 
</xsl:template>
67
 
 
68
 
<xsl:template match="*[name(.) = 'ParallelTimeLine']">
69
 
  <xsl:apply-templates />
70
 
</xsl:template>
71
 
 
72
 
<xsl:template match="*[name(.) = 'SetterTimeline']">
73
 
  <xsl:apply-templates />
74
 
</xsl:template>
75
 
 
76
 
<xsl:template match="*[name(.) = 'ByteAnimationCollection' or name(.) = 'DecimalAnimationCollection' or name(.) = 'DoubleAnimationCollection' or name(.) = 'Int16AnimationCollection' or name(.) = 'Int32AnimationCollection' or name(.) = 'Int64AnimationCollection' or name(.) = 'LengthAnimationCollection' or name(.) = 'SingleAnimationCollection' or name(.) = 'SizeAnimationCollection' or name(.) = 'ThicknessAnimationCollection']">
77
 
  <xsl:apply-templates />
78
 
</xsl:template>
79
 
 
80
 
<xsl:template match="*[name(.) = 'ByteAnimation' or name(.) = 'DecimalAnimation' or name(.) = 'DoubleAnimation' or name(.) = 'Int16Animation' or name(.) = 'Int32Animation' or name(.) = 'Int64Animation' or name(.) = 'LengthAnimation' or name(.) = 'SingleAnimation' or name(.) = 'SizeAnimation' or name(.) = 'ThicknessAnimation']">
81
 
  <xsl:choose>
82
 
    <xsl:when test="../@Path">
83
 
      <animate>
84
 
        <xsl:attribute name="attributeName"><xsl:call-template name="template_animation_path"><xsl:with-param name="target" select="../@Path" /></xsl:call-template></xsl:attribute>
85
 
        <xsl:call-template name="template_animation" />
86
 
      </animate>
87
 
    </xsl:when>
88
 
    <xsl:when test="name(..) = concat(name(.), 'Collection')">
89
 
      <animate>
90
 
        <xsl:attribute name="attributeName"><xsl:value-of select="translate(substring-after(name(../..), concat(name(../../..), '.')), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" /></xsl:attribute>
91
 
        <xsl:call-template name="template_animation" />
92
 
      </animate>
93
 
    </xsl:when>
94
 
    <xsl:when test="name(..) = concat(name(../..), '.AngleAnimations')">
95
 
      <animateTransform attributeName="transform" type="rotate">
96
 
        <xsl:call-template name="template_animation" />
97
 
      </animateTransform>
98
 
    </xsl:when>
99
 
  </xsl:choose>  
100
 
</xsl:template>
101
 
 
102
 
<xsl:template match="*[name(.) = concat(name(..), '.ColorAnimations')]">
103
 
  <xsl:apply-templates />
104
 
</xsl:template>
105
 
 
106
 
<xsl:template match="*[name(.) = concat(name(..), '.AngleAnimations')]">
107
 
  <xsl:apply-templates />
108
 
</xsl:template>
109
 
 
110
 
<xsl:template match="*[name(.) = 'ColorAnimation']">
111
 
  <animateColor>
112
 
    <xsl:if test="../@Path">
113
 
      <xsl:attribute name="attributeName"><xsl:call-template name="template_animation_path"><xsl:with-param name="target" select="../@Path" /></xsl:call-template></xsl:attribute>
114
 
    </xsl:if>
115
 
    <xsl:if test="name(..) = concat(name(../..), '.ColorAnimations')">
116
 
      <xsl:choose>
117
 
        <xsl:when test="name(../..) = 'SolidColorBrush'">
118
 
          <xsl:attribute name="attributeName">
119
 
            <xsl:value-of select="translate(substring-after(name(../../..), concat(name(../../../..), '.')), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />
120
 
          </xsl:attribute>
121
 
        </xsl:when>
122
 
      </xsl:choose>  
123
 
    </xsl:if>    
124
 
    <xsl:call-template name="template_animation" />
125
 
  </animateColor>
126
 
</xsl:template>
127
 
 
128
 
<xsl:template match="*[name(.) = 'PointAnimation']">
129
 
  <animateMotion>
130
 
    <xsl:if test="../@Path">
131
 
      <xsl:attribute name="attributeName"><xsl:call-template name="template_animation_path"><xsl:with-param name="target" select="../@Path" /></xsl:call-template></xsl:attribute>
132
 
    </xsl:if>  
133
 
    <xsl:call-template name="template_animation" />
134
 
  </animateMotion>
135
 
</xsl:template>
136
 
 
137
 
<xsl:template match="*[name(.) = 'RectAnimation']">
138
 
<!-- -->
139
 
</xsl:template>
140
 
 
141
 
</xsl:stylesheet>
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
 
 
3
<!--
 
4
Copyright (c) 2005-2007 Toine de Greef (a.degreef@chello.nl)
 
5
 
 
6
Permission is hereby granted, free of charge, to any person obtaining a copy
 
7
of this software and associated documentation files (the "Software"), to deal
 
8
in the Software without restriction, including without limitation the rights
 
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
10
copies of the Software, and to permit persons to whom the Software is
 
11
furnished to do so, subject to the following conditions:
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
22
THE SOFTWARE.
 
23
-->
 
24
 
 
25
<xsl:stylesheet version="1.0" 
 
26
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
27
xmlns:xlink="http://www.w3.org/1999/xlink"
 
28
xmlns:svg="http://www.w3.org/2000/svg"
 
29
xmlns:def="Definition"
 
30
exclude-result-prefixes="def">
 
31
<xsl:strip-space elements="*" />
 
32
<xsl:output method="xml" encoding="ISO-8859-1"/>
 
33
 
 
34
<xsl:template name="template_animation">
 
35
  <xsl:if test="@From"><xsl:attribute name="from"><xsl:value-of select="@From" /></xsl:attribute></xsl:if>
 
36
  <xsl:if test="@To"><xsl:attribute name="to"><xsl:value-of select="@To" /></xsl:attribute></xsl:if>
 
37
  <xsl:if test="@Duration"><xsl:attribute name="dur"><xsl:value-of select="@Duration" /></xsl:attribute></xsl:if>
 
38
  <xsl:if test="@RepeatDuration"><xsl:attribute name="repeatDur"><xsl:value-of select="translate(@RepeatDuration, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" /></xsl:attribute></xsl:if>
 
39
  <xsl:if test="@RepeatCount"><xsl:attribute name="repeatCount"><xsl:value-of select="@RepeatCount" /></xsl:attribute></xsl:if>
 
40
  <xsl:if test="@AutoReverse">
 
41
    <xsl:attribute name="fill">
 
42
      <xsl:choose>
 
43
        <xsl:when test="@AutoReverse = 'True'">remove</xsl:when>
 
44
        <xsl:otherwise>freeze</xsl:otherwise>
 
45
      </xsl:choose>
 
46
    </xsl:attribute>  
 
47
  </xsl:if>
 
48
</xsl:template>
 
49
 
 
50
<xsl:template name="template_timeline_animations">
 
51
  <xsl:variable name="id" select="@ID" />
 
52
  <xsl:variable name="name" select="@Name" />
 
53
  <xsl:apply-templates select="//*[name(.) = 'SetterTimeline' and ($id = @TargetID or $name = @TargetName)]" />
 
54
</xsl:template>
 
55
 
 
56
<xsl:template name="template_animation_path">
 
57
  <xsl:param name="target" />
 
58
  <xsl:choose>
 
59
    <xsl:when test="$target = '(Line.X2)'">x2</xsl:when>
 
60
    <xsl:when test="$target = '(Rectangle.Opacity)'">opacity</xsl:when>
 
61
  </xsl:choose>
 
62
</xsl:template>
 
63
 
 
64
<xsl:template match="*[name(.) = concat(name(..), '.Storyboards')]">
 
65
  <!--xsl:apply-templates /-->
 
66
</xsl:template>
 
67
 
 
68
<xsl:template match="*[name(.) = 'ParallelTimeLine']">
 
69
  <xsl:apply-templates />
 
70
</xsl:template>
 
71
 
 
72
<xsl:template match="*[name(.) = 'SetterTimeline']">
 
73
  <xsl:apply-templates />
 
74
</xsl:template>
 
75
 
 
76
<xsl:template match="*[name(.) = 'ByteAnimationCollection' or name(.) = 'DecimalAnimationCollection' or name(.) = 'DoubleAnimationCollection' or name(.) = 'Int16AnimationCollection' or name(.) = 'Int32AnimationCollection' or name(.) = 'Int64AnimationCollection' or name(.) = 'LengthAnimationCollection' or name(.) = 'SingleAnimationCollection' or name(.) = 'SizeAnimationCollection' or name(.) = 'ThicknessAnimationCollection']">
 
77
  <xsl:apply-templates />
 
78
</xsl:template>
 
79
 
 
80
<xsl:template match="*[name(.) = 'ByteAnimation' or name(.) = 'DecimalAnimation' or name(.) = 'DoubleAnimation' or name(.) = 'Int16Animation' or name(.) = 'Int32Animation' or name(.) = 'Int64Animation' or name(.) = 'LengthAnimation' or name(.) = 'SingleAnimation' or name(.) = 'SizeAnimation' or name(.) = 'ThicknessAnimation']">
 
81
  <xsl:choose>
 
82
    <xsl:when test="../@Path">
 
83
      <animate>
 
84
        <xsl:attribute name="attributeName"><xsl:call-template name="template_animation_path"><xsl:with-param name="target" select="../@Path" /></xsl:call-template></xsl:attribute>
 
85
        <xsl:call-template name="template_animation" />
 
86
      </animate>
 
87
    </xsl:when>
 
88
    <xsl:when test="name(..) = concat(name(.), 'Collection')">
 
89
      <animate>
 
90
        <xsl:attribute name="attributeName"><xsl:value-of select="translate(substring-after(name(../..), concat(name(../../..), '.')), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" /></xsl:attribute>
 
91
        <xsl:call-template name="template_animation" />
 
92
      </animate>
 
93
    </xsl:when>
 
94
    <xsl:when test="name(..) = concat(name(../..), '.AngleAnimations')">
 
95
      <animateTransform attributeName="transform" type="rotate">
 
96
        <xsl:call-template name="template_animation" />
 
97
      </animateTransform>
 
98
    </xsl:when>
 
99
  </xsl:choose>  
 
100
</xsl:template>
 
101
 
 
102
<xsl:template match="*[name(.) = concat(name(..), '.ColorAnimations')]">
 
103
  <xsl:apply-templates />
 
104
</xsl:template>
 
105
 
 
106
<xsl:template match="*[name(.) = concat(name(..), '.AngleAnimations')]">
 
107
  <xsl:apply-templates />
 
108
</xsl:template>
 
109
 
 
110
<xsl:template match="*[name(.) = 'ColorAnimation']">
 
111
  <animateColor>
 
112
    <xsl:if test="../@Path">
 
113
      <xsl:attribute name="attributeName"><xsl:call-template name="template_animation_path"><xsl:with-param name="target" select="../@Path" /></xsl:call-template></xsl:attribute>
 
114
    </xsl:if>
 
115
    <xsl:if test="name(..) = concat(name(../..), '.ColorAnimations')">
 
116
      <xsl:choose>
 
117
        <xsl:when test="name(../..) = 'SolidColorBrush'">
 
118
          <xsl:attribute name="attributeName">
 
119
            <xsl:value-of select="translate(substring-after(name(../../..), concat(name(../../../..), '.')), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />
 
120
          </xsl:attribute>
 
121
        </xsl:when>
 
122
      </xsl:choose>  
 
123
    </xsl:if>    
 
124
    <xsl:call-template name="template_animation" />
 
125
  </animateColor>
 
126
</xsl:template>
 
127
 
 
128
<xsl:template match="*[name(.) = 'PointAnimation']">
 
129
  <animateMotion>
 
130
    <xsl:if test="../@Path">
 
131
      <xsl:attribute name="attributeName"><xsl:call-template name="template_animation_path"><xsl:with-param name="target" select="../@Path" /></xsl:call-template></xsl:attribute>
 
132
    </xsl:if>  
 
133
    <xsl:call-template name="template_animation" />
 
134
  </animateMotion>
 
135
</xsl:template>
 
136
 
 
137
<xsl:template match="*[name(.) = 'RectAnimation']">
 
138
<!-- -->
 
139
</xsl:template>
 
140
 
 
141
</xsl:stylesheet>