svghmi/inline_svg.ysl2
branchsvghmi
changeset 2968 556ef07a7e31
parent 2967 fc5fbf087b93
child 2995 7769e7c7f925
equal deleted inserted replaced
2967:fc5fbf087b93 2968:556ef07a7e31
    67     name > x
    67     name > x
    68     name > y
    68     name > y
    69 }
    69 }
    70 const "excluded_use_attrs","exsl:node-set($_excluded_use_attrs)";
    70 const "excluded_use_attrs","exsl:node-set($_excluded_use_attrs)";
    71 
    71 
       
    72 const "_merge_use_attrs" {
       
    73     name > transform
       
    74     name > style
       
    75 }
       
    76 const "merge_use_attrs","exsl:node-set($_merge_use_attrs)";
       
    77 
    72 svgfunc "unlink_clone"{
    78 svgfunc "unlink_clone"{
       
    79     const "targetid","substring-after(@xlink:href,'#')";
       
    80     const "target", "//svg:*[@id = $targetid]";
    73     g{
    81     g{
    74         // include non excluded attributes
    82         choose {
    75         foreach "@*[not(local-name() = $excluded_use_attrs/name)]"
    83             when "$target[self::svg:g]" {
    76             attrib "{name()}" > «.»
    84                 foreach "@*[not(local-name() = $excluded_use_attrs/name | $merge_use_attrs)]"
       
    85                     attrib "{name()}" > «.»
    77 
    86 
    78         const "targetid","substring-after(@xlink:href,'#')";
    87                 if "@style | $target/@style"
    79         apply "//svg:*[@id = $targetid]", mode="unlink_clone"{
    88                     attrib "style" {
    80             with "seed","@id";
    89                         > «@style»
       
    90                         if "@style and $target/@style" > ;
       
    91                         > «$target/@style»
       
    92                     }
       
    93 
       
    94                 if "@transform | $target/@transform"
       
    95                     attrib "transform" {
       
    96                         > «@transform»
       
    97                         if "@transform and $target/@transform" >  
       
    98                         > «$target/@transform»
       
    99                     }
       
   100 
       
   101                 apply "$target/*", mode="unlink_clone"{
       
   102                     with "seed","@id";
       
   103                 }
       
   104             }
       
   105             otherwise {
       
   106                 // include non excluded attributes
       
   107                 foreach "@*[not(local-name() = $excluded_use_attrs/name)]"
       
   108                     attrib "{name()}" > «.»
       
   109 
       
   110                 apply "$target", mode="unlink_clone"{
       
   111                     with "seed","@id";
       
   112                 }
       
   113             }
    81         }
   114         }
    82     }
   115     }
    83 }
   116 }
    84 
   117 
    85 // clone unlinking is really similar to deep-copy
   118 // clone unlinking is really similar to deep-copy