svghmi/parse_labels.ysl2
changeset 3579 c5070b6973ba
parent 3503 49fcd5d62139
child 3592 b2bdb8b433e0
equal deleted inserted replaced
3578:d74eb1be6abe 3579:c5070b6973ba
    13 //      path value="path4" index="path4" type="HMI_LOCAL";
    13 //      path value="path4" index="path4" type="HMI_LOCAL";
    14 //  }
    14 //  }
    15 //
    15 //
    16 const "pathregex",!"'^([^\[,]+)(\[[^\]]+\])?([-.\d,]*)$'"!;
    16 const "pathregex",!"'^([^\[,]+)(\[[^\]]+\])?([-.\d,]*)$'"!;
    17 
    17 
       
    18 const "newline" |
       
    19 const "twonewlines", "concat($newline,$newline)";
       
    20 
    18 template "*", mode="parselabel"
    21 template "*", mode="parselabel"
    19 {
    22 {
    20     const "label","@inkscape:label";
    23     const "part","@inkscape:label";
       
    24     const "desc", "svg:desc";
       
    25 
       
    26     // add svg:desc field if continuation "\" marker is found at the end of label
       
    27     const "len","string-length($part)";
       
    28     const "has_continuation", "substring($part,$len,1)='\\'";
       
    29     const "label" choose{
       
    30         when "$has_continuation" {
       
    31            const "_continuation", "substring-before($desc, $twonewlines)";
       
    32            const "continuation" choose {
       
    33                when "$_continuation" value "$_continuation";
       
    34                otherwise value "$desc";
       
    35            }
       
    36            value "concat(substring($part,1,$len - 1),translate($continuation,$newline,''))";
       
    37         }
       
    38         otherwise value "$part";
       
    39     }
       
    40 
    21     const "id","@id";
    41     const "id","@id";
    22 
    42 
    23     const "description", "substring-after($label,'HMI:')";
    43     const "description", "substring-after($label,'HMI:')";
    24 
    44 
    25     const "_args", "substring-before($description,'@')";
    45     const "_args", "substring-before($description,'@')";
    98                         }
   118                         }
    99                     }
   119                     }
   100                 }
   120                 }
   101             }
   121             }
   102         }
   122         }
   103         if "svg:desc" desc value "svg:desc/text()";
   123         choose{
       
   124             when "$has_continuation" {
       
   125                const "_continuation", "substring-after($desc, $twonewlines)";
       
   126                if "$_continuation"
       
   127                        desc value "$_continuation";
       
   128             }
       
   129             otherwise
       
   130                 if "$desc" desc value "$desc/text()";
       
   131         }
   104     }
   132     }
   105 }
   133 }
   106 
   134 
   107 
   135 
   108 // Templates to generate label back from parsed tree
   136 // Templates to generate label back from parsed tree