Code

Patch for Win32 bug 176750 - Envelope and Perspective scripts report "empty string...
[inkscape.git] / share / extensions / xaml2svg / transform.xsl
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 \r
3 <!--\r
4 Copyright (c) 2005-2007 Toine de Greef (a.degreef@chello.nl)\r
5 \r
6 Permission is hereby granted, free of charge, to any person obtaining a copy\r
7 of this software and associated documentation files (the "Software"), to deal\r
8 in the Software without restriction, including without limitation the rights\r
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
10 copies of the Software, and to permit persons to whom the Software is\r
11 furnished to do so, subject to the following conditions:\r
12 \r
13 The above copyright notice and this permission notice shall be included in\r
14 all copies or substantial portions of the Software.\r
15 \r
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
22 THE SOFTWARE.\r
23 -->\r
24 \r
25 <xsl:stylesheet version="1.0" \r
26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
27 xmlns:xlink="http://www.w3.org/1999/xlink"\r
28 xmlns:svg="http://www.w3.org/2000/svg"\r
29 xmlns:def="Definition"\r
30 exclude-result-prefixes="def">\r
31 <xsl:strip-space elements="*" />\r
32 <xsl:output method="xml" encoding="ISO-8859-1"/>\r
33 \r
34 <xsl:template name="template_transform">\r
35   <xsl:variable name="transform_value">\r
36     <xsl:if test="@Transform"><xsl:value-of select="@Transform" /></xsl:if>\r
37     <xsl:apply-templates select="*[name(.) = 'UIElement.RenderTransform' or name(.) = 'Shape.RenderTransform' or name(.) = concat(name(..), '.RenderTransform')]/*" />\r
38   </xsl:variable>  \r
39   <xsl:if test="string-length($transform_value) &gt; 0"><xsl:attribute name="transform"><xsl:value-of select="$transform_value" /></xsl:attribute></xsl:if>  \r
40 </xsl:template>\r
41 \r
42 <xsl:template name="template_gradienttransform">\r
43   <xsl:variable name="transform_value">\r
44     <xsl:if test="@Canvas.Left and @Canvas.Top"><xsl:value-of select="concat('translate(', @Canvas.Left, ',', @Canvas.Top, ')')" /></xsl:if>\r
45     <xsl:if test="@Transform"><xsl:value-of select="@Transform" /></xsl:if>\r
46     <xsl:apply-templates select="*[name(.) = 'Brush.Transform' or name(.) = concat(name(..), '.Transform')]" />\r
47     <xsl:apply-templates select="*[name(.) = 'Brush.RelativeTransform' or name(.) = concat(name(..), '.RelativeTransform')]" />\r
48   </xsl:variable>  \r
49   <xsl:if test="string-length($transform_value) &gt; 0"><xsl:attribute name="gradientTransform"><xsl:value-of select="$transform_value" /></xsl:attribute></xsl:if>  \r
50 </xsl:template>\r
51 \r
52 <xsl:template match="*[name(.) = 'UIElement.RenderTransform' or name(.) = 'Shape.RenderTransform' or name(.) = concat(name(..), '.RenderTransform')]">\r
53   <!-- xsl:apply-templates /-->\r
54 </xsl:template>\r
55 \r
56 <xsl:template match="*[name(.) = 'Brush.Transform' or name(.) = concat(name(..), '.Transform')]">\r
57   <xsl:apply-templates />\r
58 </xsl:template>\r
59 \r
60 <xsl:template match="*[name(.) = 'Brush.RelativeTransform' or name(.) = concat(name(..), '.RelativeTransform')]">\r
61   <xsl:apply-templates />\r
62 </xsl:template>\r
63 \r
64 <!--\r
65 <xsl:template match="*[name(.) = 'TransformCollection' or name(.) = 'TransformGroup']">\r
66   <xsl:apply-templates />\r
67 </xsl:template>\r
68 -->\r
69 <xsl:template match="*[name(.) = 'TransformGroup']">\r
70   <xsl:apply-templates />\r
71 </xsl:template>\r
72 \r
73 \r
74 <!--\r
75 <xsl:template mode="forward" match="*[name(.) = 'TransformDecorator']">\r
76   <g>\r
77     <xsl:attribute name="transform">\r
78       <xsl:if test="@Transform"><xsl:value-of select="@Transform" /></xsl:if>\r
79       <xsl:apply-templates select="*[name(.) = 'TransformDecorator.Transform']/*" />\r
80     </xsl:attribute>\r
81   <xsl:apply-templates select="*[name(.) = 'TransformDecorator.Transform']/*/*" />  \r
82   <xsl:apply-templates mode="forward" select="*[name(.) != 'TransformDecorator.Transform']" />\r
83   </g>\r
84 </xsl:template>\r
85 -->\r
86 \r
87 <xsl:template match="*[name(.) = 'TranslateTransform']">\r
88   <xsl:if test="@X">\r
89     <xsl:value-of select="concat('translate(', @X)" />\r
90     <xsl:if test="@Y"><xsl:value-of select="concat(', ', @Y)" /></xsl:if>\r
91     <xsl:value-of select="') '" />      \r
92   </xsl:if>  \r
93 </xsl:template>\r
94 \r
95 <xsl:template match="*[name(.) = 'ScaleTransform']">\r
96   <xsl:if test="@ScaleX">\r
97     <xsl:value-of select="concat('scale(', @ScaleX)" />\r
98     <xsl:if test="@ScaleY"><xsl:value-of select="concat(', ', @ScaleY)" /></xsl:if>\r
99     <xsl:value-of select="') '" />      \r
100   </xsl:if>   \r
101 </xsl:template>\r
102 \r
103 <xsl:template match="*[name(.) = 'RotateTransform']">\r
104   <xsl:if test="@Angle">\r
105     <xsl:value-of select="concat('rotate(', @Angle)" />\r
106     <xsl:if test="@Center"><xsl:value-of select="concat(',', @Center)" /></xsl:if>\r
107     <xsl:value-of select="') '" />      \r
108   </xsl:if>\r
109 </xsl:template>\r
110 \r
111 <xsl:template match="*[name(.) = 'SkewTransform']">\r
112   <xsl:if test="@AngleX"><xsl:value-of select="concat('skewX(', @AngleX,') ')" /></xsl:if>  \r
113   <xsl:if test="@AngleY"><xsl:value-of select="concat('skewY(', @AngleY,') ')" /></xsl:if>\r
114 </xsl:template>\r
115 \r
116 <xsl:template match="*[name(.) = 'MatrixTransform']">\r
117   <xsl:if test="@Matrix"><xsl:value-of select="concat('matrix(', @Matrix,') ')" /></xsl:if>  \r
118 </xsl:template>\r
119 \r
120 </xsl:stylesheet>\r