Code

Extensions. XAML export improvements (flowRoot, text decoration, baseline alignement...
[inkscape.git] / share / extensions / svg2xaml.xsl
index a21da1290938d6232f734d7a9b2c750d54a2c2ec..c36d964bd525d001a0a5d2de4bd306670a18ec45 100755 (executable)
@@ -39,7 +39,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 <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="2" />
 
 <!-- 
   // Containers //
@@ -70,9 +70,10 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 -->
 <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="." />
         -->
@@ -118,6 +119,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
             </xsl:call-template>
           </xsl:attribute>
         </xsl:if>
+
         <xsl:if test="@viewBox">
           <xsl:variable name="viewBox">
             <xsl:value-of select="normalize-space(translate(@viewBox, ',', ' '))" />
@@ -140,14 +142,10 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
           </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']">
@@ -298,6 +296,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 -->
 <xsl:template mode="transform" match="*">
   <xsl:param name="mapped_type" />
+  
   <xsl:if test="@transform or @gradientTransform">
     <xsl:variable name="transform">
       <xsl:choose>
@@ -309,10 +308,59 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
         </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>
@@ -768,13 +816,15 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 -->
 <xsl:template mode="forward" match="*[name(.) = 'use']">
   <Canvas>
-    <xsl:if test="@xlink:href">
-      <xsl:attribute name="Style">
-        <xsl:value-of select="@xlink:href" />
-      </xsl:attribute>
-    </xsl:if>
-    <!--xsl:apply-templates mode="transform" select="." /-->
-    <xsl:apply-templates mode="forward" />
+    <StaticResource>
+      <xsl:if test="@xlink:href">
+        <xsl:attribute name="ResourceKey">
+          <xsl:value-of select="substring-after(@xlink:href, '#')" />
+        </xsl:attribute>
+      </xsl:if>
+      <!--xsl:apply-templates mode="transform" select="." /-->
+      <xsl:apply-templates mode="forward" />
+    </StaticResource>
   </Canvas>
 </xsl:template>
 
@@ -812,6 +862,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 // Colors and patterns //
 
 * Generic color template
+* Object opacity
 * Fill
 * Fill opacity
 * Fill rule
@@ -830,6 +881,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 * Gradient stop
 * Gradient stop opacity
 * Gradient stop offset
+* Image stretch
 -->
 
 <!--
@@ -934,6 +986,56 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
   </xsl:choose>
 </xsl:template>
 
+<!--
+  // Object opacity //
+-->
+<xsl:template mode="object_opacity" match="*">
+  <xsl:if test="@opacity or (@style and (contains(@style, ';opacity:') or starts-with(@style, 'opacity:')))">
+    <xsl:variable name="value">
+    <xsl:choose>
+      <xsl:when test="@opacity">
+        <xsl:value-of select="@opacity" />
+      </xsl:when>
+      <xsl:when test="@style and contains(@style, ';opacity:')">
+        <xsl:variable name="Opacity" select="substring-after(@style, ';opacity:')" />
+        <xsl:choose>
+          <xsl:when test="contains($Opacity, ';')">
+            <xsl:value-of select="substring-before($Opacity, ';')" />
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$Opacity" />
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
+      <xsl:when test="@style and starts-with(@style, 'opacity:')">
+        <xsl:variable name="Opacity" select="substring-after(@style, 'opacity:')" />
+        <xsl:choose>
+          <xsl:when test="contains($Opacity, ';')">
+            <xsl:value-of select="substring-before($Opacity, ';')" />
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$Opacity" />
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
+      <xsl:when test="name(..) = 'g' or name(..) = 'svg'">
+        <xsl:apply-templates mode="object_opacity" select="parent::*" />
+      </xsl:when>
+      <xsl:otherwise>1</xsl:otherwise>
+    </xsl:choose>
+    </xsl:variable>
+    <xsl:attribute name="Opacity">
+    <xsl:choose>
+      <xsl:when test="$value &lt; 0">0</xsl:when>
+      <xsl:when test="$value &gt; 1">1</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$value" />
+      </xsl:otherwise>
+    </xsl:choose>
+    </xsl:attribute>
+  </xsl:if>
+</xsl:template>
+
 <!--
   // Fill //
 -->
@@ -1311,7 +1413,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 -->
 <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">
@@ -1579,6 +1681,34 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
   </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 //
 
@@ -1604,33 +1734,27 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 
  <!-- 
   // Text span //
-  SVG: tspan, flowSpan, FXG: span
+  SVG: tspan, flowSpan, XAML: Span
   
-  Not supported in FXG:
+  Not supported in XAML:
   * span position
 -->
 <xsl:template mode="forward" match="*[name(.) = 'tspan'  or name(.) = 'flowSpan']">
-  <span>
+  <Span>
     <xsl:if test="../@xml:space='preserve'">
       <xsl:attribute name="whiteSpaceCollapse">preserve</xsl:attribute>
     </xsl:if>
     <xsl:variable name="fill">
       <xsl:apply-templates mode="fill" select="." />
     </xsl:variable>
-    <xsl:variable name="fill_opacity">
-      <xsl:apply-templates mode="fill_opacity" select="." />
-    </xsl:variable>
     <xsl:if test="starts-with($fill, '#') or (not(starts-with($fill, 'url')) and $fill != '' and $fill != 'none')">
-      <xsl:attribute name="color">
+      <xsl:attribute name="Foreground">
         <xsl:call-template name="template_color">
           <xsl:with-param name="colorspec">
             <xsl:value-of select="$fill" />
           </xsl:with-param>
         </xsl:call-template>
       </xsl:attribute>
-      <xsl:attribute name="textAlpha">
-        <xsl:value-of select="$fill_opacity" />
-      </xsl:attribute>
     </xsl:if>
     <xsl:apply-templates mode="font_size" select="." />
     <xsl:apply-templates mode="font_weight" select="." />
@@ -1644,64 +1768,30 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
     <xsl:if test="text()">
       <xsl:value-of select="text()" />
     </xsl:if>
-  </span>
+  </Span>
 </xsl:template>
 
  <!-- 
   // Text flowPara //
-  SVG: flowPara, flowDiv FXG: p
+  SVG: flowPara, flowDiv XAML: ?
   
-  Not supported in FXG:
-  * paragraph position
 -->
 <xsl:template mode="forward" match="*[name(.) = 'flowPara' or name(.) = 'flowDiv']">
-  <p>
-    <xsl:if test="../@xml:space='preserve'">
-      <xsl:attribute name="whiteSpaceCollapse">preserve</xsl:attribute>
-    </xsl:if>
-    <xsl:variable name="fill">
-      <xsl:apply-templates mode="fill" select="." />
-    </xsl:variable>
-    <xsl:variable name="fill_opacity">
-      <xsl:apply-templates mode="fill_opacity" select="." />
-    </xsl:variable>
-    <xsl:if test="starts-with($fill, '#') or (not(starts-with($fill, 'url')) and $fill != '' and $fill != 'none')">
-      <xsl:attribute name="color">
-        <xsl:call-template name="template_color">
-          <xsl:with-param name="colorspec">
-            <xsl:value-of select="$fill" />
-          </xsl:with-param>
-        </xsl:call-template>
-      </xsl:attribute>
-      <xsl:attribute name="textAlpha">
-        <xsl:value-of select="$fill_opacity" />
-      </xsl:attribute>
-    </xsl:if>
-    <xsl:apply-templates mode="font_size" select="." />
-    <xsl:apply-templates mode="font_weight" select="." />
-    <xsl:apply-templates mode="font_family" select="." />
-    <xsl:apply-templates mode="font_style" select="." />
-    <xsl:apply-templates mode="text_fill" select="." />
-    <xsl:apply-templates mode="text_decoration" select="." />
-    <xsl:apply-templates mode="line_height" select="." />
-    <xsl:apply-templates mode="baseline_shift" select="." />
-
-    <xsl:choose>
-      <xsl:when test="*[name(.) = 'flowSpan']/text()">
-        <xsl:apply-templates mode="forward" />
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:choose>
-          <xsl:when test="@xml:space='preserve'">
-            <xsl:copy-of select="translate(text(), '&#x9;&#xA;&#xD;', ' ')" />
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:copy-of select="normalize-space(translate(text(), '&#x9;&#xA;&#xD;', ' '))" />
-          </xsl:otherwise>
-        </xsl:choose>  
-      </xsl:otherwise>
-    </xsl:choose>
-  </p>
+  <xsl:choose>
+    <xsl:when test="*[name(.) = 'flowSpan']/text()">
+      <xsl:apply-templates mode="forward" />
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="@xml:space='preserve'">
+          <xsl:copy-of select="translate(text(), '&#x9;&#xA;&#xD;', ' ')" />
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:copy-of select="normalize-space(translate(text(), '&#x9;&#xA;&#xD;', ' '))" />
+        </xsl:otherwise>
+      </xsl:choose>  
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 
@@ -1732,11 +1822,12 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
         </xsl:otherwise>
       </xsl:choose>
     </xsl:when>
-    <xsl:when test="name(..) = 'g' or name(..) = 'svg'">
+    <xsl:when test="name(..) = 'g' or name(..) = 'svg' or name(..) = 'text' or name(..) = 'flowPara' or name(..) = 'flowRoot'">
       <xsl:apply-templates mode="get_font_size" select="parent::*"/>
     </xsl:when>
   </xsl:choose>
 </xsl:template>
+
 <!-- 
   // Text font size //
   SVG: font-size, XAML: FontSize
@@ -1867,7 +1958,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 
 <!-- 
   // Text baseline shift //
-  SVG: baseline-shift, FXG: baselineShift
+  SVG: baseline-shift, XAML: BaselineAlignment
 -->
 <xsl:template mode="baseline_shift" match="*">
   <xsl:variable name="value">
@@ -1881,17 +1972,12 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
       <xsl:value-of select="substring-before(substring-after(@style, 'baseline-shift:'), ';')" />
     </xsl:if>   
   </xsl:variable>
-  <xsl:if test="$value != ''">
-    <xsl:attribute name="baselineShift">  
+  <xsl:if test="$value = 'baseline' or $value='super' or $value='sub'">
+    <xsl:attribute name="BaselineAlignment">  
       <xsl:choose>
-        <xsl:when test="$value='baseline'">0</xsl:when>
-        <xsl:when test="$value='super'">superscript</xsl:when>
-        <xsl:when test="$value='sub'">subscript</xsl:when>
-        <xsl:when test="translate($value, '%', '') &lt; -1000">-1000</xsl:when>
-        <xsl:when test="translate($value, '%', '') &gt; 1000">1000</xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="translate($value, '%', '')" />
-        </xsl:otherwise>
+        <xsl:when test="$value='baseline'">Normal</xsl:when>
+        <xsl:when test="$value='super'">Superscript</xsl:when>
+        <xsl:when test="$value='sub'">Subscript</xsl:when>
       </xsl:choose>  
       <xsl:if test="contains($value, '%')">%</xsl:if>
     </xsl:attribute>
@@ -1961,7 +2047,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
   
 <!-- 
   // Text decoration //
-  SVG: text-decoration, FXG: textDecoration, lineThrough 
+  SVG: text-decoration, XAML: TextDecorations 
 -->
 <xsl:template mode="text_decoration" match="*">
   <xsl:variable name="value">
@@ -1975,15 +2061,15 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
       <xsl:value-of select="substring-before(substring-after(@style, 'text-decoration:'), ';')" />
     </xsl:if>   
   </xsl:variable>
-  <xsl:if test="$value != ''">  
-    <xsl:choose>
-      <xsl:when test="$value='underline'">
-        <xsl:attribute name="textDecoration">underline</xsl:attribute>
-      </xsl:when>
-      <xsl:when test="$value='line-through'">
-        <xsl:attribute name="lineThrough">true</xsl:attribute>
-      </xsl:when>
-    </xsl:choose>  
+  <xsl:if test="$value != ''">
+    <xsl:attribute name="TextDecorations">
+      <xsl:choose>
+        <xsl:when test="$value='underline'">Underline</xsl:when>
+        <xsl:when test="$value='line-through'">Strikethrough</xsl:when>
+        <xsl:when test="$value='overline'">Overline</xsl:when>
+        <xsl:otherwise>None</xsl:otherwise>
+      </xsl:choose>  
+    </xsl:attribute>
   </xsl:if>
 </xsl:template>
 
@@ -2019,7 +2105,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
 
 <!-- 
   // Text direction //
-  SVG: direction, unicode-bidi, FXG: direction
+  SVG: direction, unicode-bidi, XAML: FlowDirection
 -->
 <xsl:template mode="direction" match="*">
   <xsl:variable name="value">
@@ -2046,10 +2132,10 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
   </xsl:variable>
 
   <xsl:if test="$value != '' and ($bidi='embed' or $bidi='bidi-override')">  
-    <xsl:attribute name="direction">
+    <xsl:attribute name="FlowDirection">
       <xsl:choose>
-        <xsl:when test="$value='ltr'">ltr</xsl:when>
-        <xsl:when test="$value='rtl'">rtl</xsl:when>
+        <xsl:when test="$value='ltr'">LeftToRight</xsl:when>
+        <xsl:when test="$value='rtl'">RightToLeft</xsl:when>
       </xsl:choose>  
     </xsl:attribute>
   </xsl:if>
@@ -2151,7 +2237,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
   // Text objects //
   SVG: text, XAML: TextBlock
 -->
-<xsl:template mode="forward" match="*[name(.) = 'text']">
+<xsl:template mode="forward" match="*[name(.) = 'text' or name(.) = 'flowRoot']">
   <TextBlock>
     <xsl:apply-templates mode="font_size" select="." />
     <xsl:apply-templates mode="font_weight" select="." />
@@ -2159,7 +2245,14 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
     <xsl:apply-templates mode="font_style" select="." />
     <xsl:apply-templates mode="text_fill" select="." />
     <xsl:apply-templates mode="text_size" select="." />
+    <xsl:apply-templates mode="text_decoration" select="." />
+    <xsl:apply-templates mode="direction" select="." />
     <xsl:apply-templates mode="text_position" select="." />
+    <xsl:if test="name(.) = 'flowRoot'">
+      <xsl:attribute name="TextWrapping">
+        <xsl:value-of select="'Wrap'" />
+      </xsl:attribute>
+    </xsl:if>
     
     <xsl:if test="@text-anchor">
       <xsl:attribute name="HorizontalAlignment">
@@ -2171,15 +2264,21 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
       </xsl:attribute>
     </xsl:if>
     
+    <xsl:apply-templates mode="object_opacity" select="." />
+    
     <xsl:apply-templates mode="id" select="." />
+    <xsl:if test="name(.) = 'flowRoot'">
+      <xsl:apply-templates mode="flow_region" select="*[name(.) = 'flowRegion']/child::node()" />
+    </xsl:if>
     <xsl:apply-templates mode="filter_effect" select="." />
     <xsl:apply-templates mode="desc" select="." />
+    <xsl:apply-templates mode="resources" select="." />
     <xsl:apply-templates mode="clip" select="." />
     <!--xsl:apply-templates mode="transform" select="." /-->
     <!--xsl:apply-templates mode="forward" /-->
     
     <xsl:choose>
-      <xsl:when test="*[name(.) = 'tspan']/text()">
+      <xsl:when test="*[name(.) = 'tspan' or name(.) = 'flowPara' or name(.) = 'flowDiv']/text()">
         <xsl:apply-templates mode="forward" />
       </xsl:when>
       <xsl:otherwise>
@@ -2223,6 +2322,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
         <xsl:value-of select="@y2" />
       </xsl:attribute>
     </xsl:if>
+    
     <xsl:apply-templates mode="id" select="." />
     <xsl:apply-templates mode="template_fill" select="." />
     <xsl:apply-templates mode="template_stroke" select="." />
@@ -2232,7 +2332,9 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
     <xsl:apply-templates mode="stroke_linejoin" select="." />
     <xsl:apply-templates mode="stroke_linecap" select="." />
     <xsl:apply-templates mode="filter_effect" select="." />
+    <xsl:apply-templates mode="object_opacity" select="." />
     <xsl:apply-templates mode="desc" select="." />
+    <xsl:apply-templates mode="resources" select="." />
 
     <xsl:apply-templates mode="transform" select=".">
       <xsl:with-param name="mapped_type" select="'Line'" />
@@ -2306,6 +2408,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
     <xsl:apply-templates mode="stroke_linecap" select="." />
     <xsl:apply-templates mode="filter_effect" select="." />
     <xsl:apply-templates mode="resources" select="." />
+    <xsl:apply-templates mode="object_opacity" select="." />
     <xsl:apply-templates mode="desc" select="." />
     <xsl:apply-templates mode="clip" select="." />
 
@@ -2334,7 +2437,9 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
     <xsl:apply-templates mode="stroke_linejoin" select="." />
     <xsl:apply-templates mode="stroke_linecap" select="." />
     <xsl:apply-templates mode="filter_effect" select="." />
+    <xsl:apply-templates mode="object_opacity" select="." />
     <xsl:apply-templates mode="desc" select="." />
+    <xsl:apply-templates mode="resources" select="." />
 
     <xsl:apply-templates mode="transform" select=".">
       <xsl:with-param name="mapped_type" select="'Polygon'" />
@@ -2361,6 +2466,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
     <xsl:apply-templates mode="stroke_linejoin" select="." />
     <xsl:apply-templates mode="stroke_linecap" select="." />
     <xsl:apply-templates mode="filter_effect" select="." />
+    <xsl:apply-templates mode="object_opacity" select="." />
     <xsl:apply-templates mode="desc" select="." />
 
     <xsl:apply-templates mode="transform" select=".">
@@ -2386,13 +2492,15 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
     <xsl:apply-templates mode="stroke_linejoin" select="." />
     <xsl:apply-templates mode="stroke_linecap" select="." />
     <xsl:apply-templates mode="filter_effect" select="." />
+    <xsl:apply-templates mode="object_opacity" select="." />
     <xsl:apply-templates mode="desc" select="." />
+    <xsl:apply-templates mode="resources" select="." />
 
     <xsl:if test="@d">
       <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>
@@ -2451,7 +2559,9 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
     <xsl:apply-templates mode="stroke_linejoin" select="." />
     <xsl:apply-templates mode="stroke_linecap" select="." />
     <xsl:apply-templates mode="filter_effect" select="." />
+    <xsl:apply-templates mode="object_opacity" select="." />
     <xsl:apply-templates mode="desc" select="." />
+    <xsl:apply-templates mode="resources" select="." />
     <xsl:apply-templates mode="clip" select="." />
 
     <xsl:apply-templates mode="transform" select=".">
@@ -2495,7 +2605,9 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
     <xsl:apply-templates mode="stroke_linejoin" select="." />
     <xsl:apply-templates mode="stroke_linecap" select="." />
     <xsl:apply-templates mode="filter_effect" select="." />
+    <xsl:apply-templates mode="object_opacity" select="." />
     <xsl:apply-templates mode="desc" select="." />
+    <xsl:apply-templates mode="resources" select="." />
     <xsl:apply-templates mode="clip" select="." />
 
     <xsl:apply-templates mode="transform" select=".">
@@ -2548,6 +2660,11 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt">
         </xsl:call-template>
       </xsl:attribute>
     </xsl:if>
+    
+    <xsl:apply-templates mode="image_stretch" select="." />
+    <xsl:apply-templates mode="object_opacity" select="." />
+    <xsl:apply-templates mode="resources" select="." />
+    
     <xsl:apply-templates mode="transform" select=".">
       <xsl:with-param name="mapped_type" select="'Image'" />
     </xsl:apply-templates>