summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6c28c26)
raw | patch | inline | side by side (parent: 6c28c26)
author | JazzyNico <nicoduf@yahoo.fr> | |
Fri, 21 Jan 2011 11:32:22 +0000 (12:32 +0100) | ||
committer | JazzyNico <nicoduf@yahoo.fr> | |
Fri, 21 Jan 2011 11:32:22 +0000 (12:32 +0100) |
share/extensions/svg2xaml.xsl | patch | blob | history |
index a21da1290938d6232f734d7a9b2c750d54a2c2ec..cbea98c2ab309965c6f429e0da62c6e60209b8ea 100755 (executable)
<xsl:strip-space elements="*" />
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
-<xsl:param name="silverlight_compatible" select="1" />
+<xsl:param name="silverlight_compatible" select="0" />
<!--
// Containers //
-->
<xsl:template mode="forward" match="*[name(.) = 'svg' or name(.) = 'g']">
<xsl:choose>
- <xsl:when test="name(.) = 'svg' or @transform or @viewBox or @id or @clip-path or (@style and contains(@style, 'clip-path:url(#')) or (@width and not(contains(@width, '%'))) or @x or @y or (@height and not(contains(@height, '%'))) or *[name(.) = 'linearGradient' or name(.) = 'radialGradient' or name(.) = 'defs' or name(.) = 'clipPath']">
+ <xsl:when test="name(.) = 'svg' or @transform or @viewBox or @id or @clip-path or @filter or (@style and contains(@style, 'clip-path:url(#')) or (@width and not(contains(@width, '%'))) or @x or @y or (@height and not(contains(@height, '%'))) or *[name(.) = 'linearGradient' or name(.) = 'radialGradient' or name(.) = 'defs' or name(.) = 'clipPath']">
<Canvas>
<xsl:apply-templates mode="id" select="." />
+ <xsl:apply-templates mode="filter_effect" select="." />
<!--
<xsl:apply-templates mode="clip" select="." />
-->
</xsl:call-template>
</xsl:attribute>
</xsl:if>
+
<xsl:if test="@viewBox">
<xsl:variable name="viewBox">
<xsl:value-of select="normalize-space(translate(@viewBox, ',', ' '))" />
</Canvas.RenderTransform>
</xsl:if>
<xsl:if test="@transform">
- <Canvas>
- <Canvas.RenderTransform>
- <TransformGroup>
- <xsl:apply-templates mode="transform" select="." />
- </TransformGroup>
- </Canvas.RenderTransform>
+ <xsl:apply-templates mode="transform" select=".">
+ <xsl:with-param name="mapped_type" select="'Canvas'" />
+ </xsl:apply-templates>
<xsl:apply-templates mode="forward" select="*" />
- </Canvas>
</xsl:if>
<xsl:if test="*[name(.) = 'linearGradient' or name(.) = 'radialGradient' or name(.) = 'defs' or name(.) = 'clipPath']">
-->
<xsl:template mode="transform" match="*">
<xsl:param name="mapped_type" />
+
<xsl:if test="@transform or @gradientTransform">
<xsl:variable name="transform">
<xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
+
+ <xsl:variable name="values" select="normalize-space(translate($transform, ',', ' '))" />
+ <xsl:variable name="value1">
+ <xsl:choose>
+ <xsl:when test="contains($values, ') ')">
+ <xsl:value-of select="concat(substring-before($values, ') '), ')')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$values" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="value2">
+ <xsl:if test="substring-after($values, $value1) != ''">
+ <xsl:choose>
+ <xsl:when test="contains(substring-after($values, $value1), ') ')">
+ <xsl:value-of select="normalize-space(concat(substring-before(substring-after($values, $value1), ') '), ')'))" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="normalize-space(substring-after($values, $value1))" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="value3">
+ <xsl:if test="$value2 != '' and substring-after($values, $value2) != ''">
+ <xsl:choose>
+ <xsl:when test="contains(substring-after($values, $value2), ') ')">
+ <xsl:value-of select="normalize-space(concat(substring-before(substring-after($values, $value2), ') '), ')'))" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="normalize-space(substring-after($values, $value2))" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:variable>
+
<xsl:variable name="transform_nodes">
- <xsl:call-template name="parse_transform">
- <xsl:with-param name="input" select="$transform" />
- </xsl:call-template>
+ <xsl:if test="$value3 !=''">
+ <xsl:call-template name="parse_transform">
+ <xsl:with-param name="input" select="$value3" />
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="$value2 !=''">
+ <xsl:call-template name="parse_transform">
+ <xsl:with-param name="input" select="$value2" />
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="$value1 !=''">
+ <xsl:call-template name="parse_transform">
+ <xsl:with-param name="input" select="$value1" />
+ </xsl:call-template>
+ </xsl:if>
</xsl:variable>
<xsl:choose>
* Gradient stop
* Gradient stop opacity
* Gradient stop offset
+* Image stretch
-->
<!--
-->
<xsl:template mode="stroke_linejoin" match="*">
<xsl:choose>
- <xsl:when test="@stroke-miterlimit">
+ <xsl:when test="@stroke-linejoin">
<xsl:attribute name="StrokeLineJoin">
<xsl:call-template name="linejoin_svg_to_xaml">
<xsl:with-param name="linejoin">
</xsl:choose>
</xsl:template>
+<!--
+ // Image stretch //
+ SVG: preserveAspectRatio, XAML: Stretch
+-->
+<xsl:template mode="image_stretch" match="*">
+ <xsl:variable name="value">
+ <xsl:choose>
+ <xsl:when test="@preserveAspectRatio">
+ <xsl:value-of select="@preserveAspectRatio" />
+ </xsl:when>
+ <xsl:when test="@style and contains(@style, 'preserveAspectRatio:')">
+ <xsl:variable name="ratio" select="normalize-space(substring-after(@style, 'preserveAspectRatio:'))" />
+ <xsl:choose>
+ <xsl:when test="contains($ratio, ';')">
+ <xsl:value-of select="substring-before($ratio, ';')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$ratio" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:if test="$value = 'none'">
+ <xsl:attribute name="Stretch">Fill</xsl:attribute>
+ </xsl:if>
+</xsl:template>
+
<!--
// Text specific templates //
</xsl:when>
</xsl:choose>
</xsl:template>
+
<!--
// Text font size //
SVG: font-size, XAML: FontSize
<xsl:choose>
<xsl:when test="$silverlight_compatible = 1">
<xsl:attribute name="Data">
- <xsl:value-of select="translate(@d , ',', ' ')" />
+ <xsl:value-of select="translate(@d , ',', ' ')" />
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
</xsl:call-template>
</xsl:attribute>
</xsl:if>
+
+ <xsl:apply-templates mode="image_stretch" select="." />
<xsl:apply-templates mode="transform" select=".">
<xsl:with-param name="mapped_type" select="'Image'" />
</xsl:apply-templates>