svghmi/inline_svg.ysl2
branchsvghmi
changeset 2968 556ef07a7e31
parent 2967 fc5fbf087b93
child 2995 7769e7c7f925
--- a/svghmi/inline_svg.ysl2	Thu May 14 17:48:15 2020 +0200
+++ b/svghmi/inline_svg.ysl2	Thu May 14 17:48:58 2020 +0200
@@ -69,15 +69,48 @@
 }
 const "excluded_use_attrs","exsl:node-set($_excluded_use_attrs)";
 
+const "_merge_use_attrs" {
+    name > transform
+    name > style
+}
+const "merge_use_attrs","exsl:node-set($_merge_use_attrs)";
+
 svgfunc "unlink_clone"{
+    const "targetid","substring-after(@xlink:href,'#')";
+    const "target", "//svg:*[@id = $targetid]";
     g{
-        // include non excluded attributes
-        foreach "@*[not(local-name() = $excluded_use_attrs/name)]"
-            attrib "{name()}" > «.»
+        choose {
+            when "$target[self::svg:g]" {
+                foreach "@*[not(local-name() = $excluded_use_attrs/name | $merge_use_attrs)]"
+                    attrib "{name()}" > «.»
 
-        const "targetid","substring-after(@xlink:href,'#')";
-        apply "//svg:*[@id = $targetid]", mode="unlink_clone"{
-            with "seed","@id";
+                if "@style | $target/@style"
+                    attrib "style" {
+                        > «@style»
+                        if "@style and $target/@style" > ;
+                        > «$target/@style»
+                    }
+
+                if "@transform | $target/@transform"
+                    attrib "transform" {
+                        > «@transform»
+                        if "@transform and $target/@transform" >  
+                        > «$target/@transform»
+                    }
+
+                apply "$target/*", mode="unlink_clone"{
+                    with "seed","@id";
+                }
+            }
+            otherwise {
+                // include non excluded attributes
+                foreach "@*[not(local-name() = $excluded_use_attrs/name)]"
+                    attrib "{name()}" > «.»
+
+                apply "$target", mode="unlink_clone"{
+                    with "seed","@id";
+                }
+            }
         }
     }
 }