Code

Translations. POTFILES.in cleanup and inkscape.pot update.
[inkscape.git] / share / extensions / xaml2svg.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
3 <!--
4 Copyright (c) 2005-2007 Toine de Greef (a.degreef@chello.nl)
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:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
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.
24 Version history:
26 20070907 Initial release
27 20070912 Removed NaN as viewBox values
29 -->
31 <xsl:stylesheet version="1.0"
32 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33 xmlns:xlink="http://www.w3.org/1999/xlink"
34 xmlns:svg="http://www.w3.org/2000/svg"
35 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
36 xmlns:msxsl="urn:schemas-microsoft-com:xslt">
37 <xsl:strip-space elements="*" />
38 <xsl:output method="xml" encoding="UTF-8"/>
39 <xsl:include href="xaml2svg/animation.xsl" />
40 <xsl:include href="xaml2svg/brushes.xsl" />
41 <xsl:include href="xaml2svg/canvas.xsl" />
42 <xsl:include href="xaml2svg/geometry.xsl" />
43 <xsl:include href="xaml2svg/properties.xsl" />
44 <xsl:include href="xaml2svg/shapes.xsl" />
45 <xsl:include href="xaml2svg/transform.xsl" />
47 <xsl:template match="/">
48   <svg>
49     <xsl:attribute name="overflow">visible</xsl:attribute>
50     <xsl:variable name="viewBox"><xsl:apply-templates mode="boundingbox" /></xsl:variable>
51     <xsl:if test="system-property('xsl:vendor') = 'Microsoft' and (msxsl:node-set($viewBox)/boundingbox/@x1 != '') and (msxsl:node-set($viewBox)/boundingbox/@x2 != '') and (msxsl:node-set($viewBox)/boundingbox/@y1 != '') and (msxsl:node-set($viewBox)/boundingbox/@y2 != '')">
52       <xsl:attribute name="viewBox">
53         <xsl:value-of select="concat(msxsl:node-set($viewBox)/boundingbox/@x1, ' ')" />
54         <xsl:value-of select="concat(msxsl:node-set($viewBox)/boundingbox/@y1, ' ')" />
55         <xsl:value-of select="concat(msxsl:node-set($viewBox)/boundingbox/@x2 - msxsl:node-set($viewBox)/boundingbox/@x1, ' ')" />
56         <xsl:value-of select="msxsl:node-set($viewBox)/boundingbox/@y2 - msxsl:node-set($viewBox)/boundingbox/@y1" />
57       </xsl:attribute>
58     </xsl:if>  
59     <xsl:apply-templates mode="svg" />
60   </svg>
61 </xsl:template>
63 <xsl:template mode="forward" match="*[name(.) = 'Image']">
64   <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="concat('&lt;svg x=&quot;', @Canvas.Left, '&quot; y=&quot;', @Canvas.Top, '&quot;&gt;')" /></xsl:if>
65   <image>
66     <xsl:if test="@Source"><xsl:attribute name="xlink:href"><xsl:value-of select="@Source" /></xsl:attribute></xsl:if>
67     <xsl:if test="@Width"><xsl:attribute name="width"><xsl:value-of select="@Width" /></xsl:attribute></xsl:if>
68     <xsl:if test="@Height"><xsl:attribute name="height"><xsl:value-of select="@Height" /></xsl:attribute></xsl:if>
69     <xsl:call-template name="template_properties" />
70     <xsl:call-template name="template_transform" />
71     <xsl:apply-templates mode="forward" />
72   </image>
73   <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="'&lt;/svg&gt;&#13;'" /></xsl:if>
74 </xsl:template>
76 <xsl:template mode="forward" match="*[name(.) = 'TextBlock']">
77   <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="concat('&lt;svg x=&quot;', @Canvas.Left, '&quot; y=&quot;', @Canvas.Top, '&quot;&gt;')" /></xsl:if>
78   <text>
79     <xsl:if test="@FontSize"><xsl:attribute name="font-size"><xsl:value-of select="@FontSize" /></xsl:attribute></xsl:if>
80     <xsl:if test="@FontWeight"><xsl:attribute name="font-weight"><xsl:value-of select="@FontWeight" /></xsl:attribute></xsl:if>
81     <xsl:if test="@FontFamily"><xsl:attribute name="font-family"><xsl:value-of select="@FontFamily" /></xsl:attribute></xsl:if>
82     <xsl:if test="@FontStyle"><xsl:attribute name="font-style"><xsl:value-of select="@FontStyle" /></xsl:attribute></xsl:if>
83     <xsl:if test="@Foreground"><xsl:attribute name="fill"><xsl:value-of select="@Foreground" /></xsl:attribute></xsl:if>
84     <xsl:if test="@Width"><xsl:attribute name="width"><xsl:value-of select="@Width" /></xsl:attribute></xsl:if>
85     <xsl:if test="@Height"><xsl:attribute name="height"><xsl:value-of select="@Height" /></xsl:attribute></xsl:if>
86     <xsl:if test="@HorizontalAlignment">
87       <xsl:attribute name="text-anchor">
88         <xsl:choose>
89           <xsl:when test="@HorizontalAlignment = 'Left'">start</xsl:when>
90           <xsl:when test="@HorizontalAlignment = 'Center'">middle</xsl:when>
91           <xsl:when test="@HorizontalAlignment = 'Right'">end</xsl:when>
92         </xsl:choose>
93       </xsl:attribute>
94     </xsl:if>
95     <xsl:attribute name="dominant-baseline">hanging</xsl:attribute>
96     <xsl:call-template name="template_properties" />
97     <xsl:call-template name="template_transform" />
98     <xsl:apply-templates />
99   </text>
100   <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="'&lt;/svg&gt;&#13;'" /></xsl:if>
101 </xsl:template>
103 <xsl:template match="*">
104 <xsl:comment><xsl:value-of select="concat('Unknown tag: ', name(.))" /></xsl:comment>
105 </xsl:template>
107 </xsl:stylesheet>