328 // ensure that coordinate in CSV file generated by inkscape match svg default unit |
329 // ensure that coordinate in CSV file generated by inkscape match svg default unit |
329 template "sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']", mode="inline_svg" { |
330 template "sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']", mode="inline_svg" { |
330 error > All units must be set to "px" in Inkscape's document properties |
331 error > All units must be set to "px" in Inkscape's document properties |
331 } |
332 } |
332 |
333 |
333 |
334 |
334 //// Commented out before implementing runtime DOM remove/append on page switch - would have side effect |
335 //////////////// Clone Unlinking |
335 //// |
336 |
336 //// /* clone unlinkink until widget for better perf with webkit */ |
337 // svg:use (inkscape's clones) inside a widgets are |
337 //// svgtmpl "svg:use", mode="inline_svg" |
338 // replaced by real elements they refer in order to : |
338 //// { |
339 // - allow finding "needle" element in "meter" widget, |
339 //// g{ |
340 // even if "needle" is in a group refered by a svg use. |
340 //// attrib "style" > «@style» |
341 // - if "needle" is visible through a svg:use for |
341 //// attrib "transform" > «@transform» |
342 // each instance of the widget, then needle would show |
342 //// /* keep same id and label in case it is a widget */ |
343 // the same position in all instances |
343 //// //attrib "inkscape:label","@inkscape:label"; |
344 // |
344 //// attrib "id" > «@id» |
345 // For now, clone unlinkink applies to descendants of all widget except HMI:Page |
345 //// const "targetid","substring-after(@xlink:href,'#')"; |
346 // TODO: narrow application of clone unlinking to active elements, |
346 //// apply "//svg:*[@id = $targetid]", mode="unlink_clone"; |
347 // while keeping static decoration cloned |
347 //// } |
348 const "to_unlink", "$hmi_elements[not(@id = $hmi_pages)]//svg:use"; |
348 //// } |
349 svgtmpl "svg:use", mode="inline_svg" |
349 //// svgtmpl "@*", mode="unlink_clone" xsl:copy; |
350 { |
350 //// svgtmpl "svg:*", mode="unlink_clone" { |
351 choose { |
351 //// choose { |
352 when "@id = $to_unlink/@id" |
352 //// when "@id = $hmi_elements/@id" { |
353 call "unlink_clone"; |
353 //// use{ |
354 otherwise |
354 //// attrib "xlink:href" > «concat('#',@id)» |
355 xsl:copy apply "@* | node()", mode="inline_svg"; |
355 //// } |
356 } |
356 //// } |
357 } |
357 //// otherwise { |
358 |
358 //// xsl:copy apply "@* | node()", mode="unlink_clone"; |
359 // to unlink a clone, an group containing a copy of target element is created |
359 //// } |
360 // that way, style and transforms can be preserved |
360 //// } |
361 const "_excluded_use_attrs" { |
361 //// } |
362 name > href |
362 |
363 name > width |
363 // template "svg:use/@style", mode="inline_svg"{ |
364 name > height |
364 // attrib "style" > all:initial; |
365 name > x |
365 // //«.» |
366 name > y |
366 // } |
367 } |
367 |
368 const "excluded_use_attrs","exsl:node-set($_excluded_use_attrs)"; |
368 // template "svg:*[concat('#',@id) = //svg:use/@xlink:href]/@style", mode="inline_svg"{ |
369 |
369 // attrib "style" > all:unset; |
370 svgfunc "unlink_clone"{ |
370 // //«.» |
371 g{ |
371 // } |
372 // include non excluded attributes |
|
373 foreach "@*[not(local-name() = $excluded_use_attrs/name)]" |
|
374 attrib "{name()}" > «.» |
|
375 |
|
376 const "targetid","substring-after(@xlink:href,'#')"; |
|
377 apply "//svg:*[@id = $targetid]", mode="unlink_clone"{ |
|
378 with "seed","@id"; |
|
379 } |
|
380 } |
|
381 } |
|
382 |
|
383 // clone unlinking is really similar to deep-copy |
|
384 // all nodes are sytematically copied |
|
385 svgtmpl "@id", mode="unlink_clone" { |
|
386 param "seed"; |
|
387 attrib "id" > «$seed»_«.» |
|
388 } |
|
389 |
|
390 svgtmpl "@*", mode="unlink_clone" xsl:copy; |
|
391 |
|
392 // copying widgets would have unwanted effect |
|
393 // instead widget is refered through a svg:use. |
|
394 svgtmpl "svg:*", mode="unlink_clone" { |
|
395 param "seed"; |
|
396 choose { |
|
397 // node recursive copy ends when finding a widget |
|
398 when "@id = $hmi_elements/@id" { |
|
399 // place a clone instead of copying |
|
400 use{ |
|
401 attrib "xlink:href" > «concat('#',@id)» |
|
402 } |
|
403 } |
|
404 otherwise { |
|
405 xsl:copy apply "@* | node()", mode="unlink_clone" { |
|
406 with "seed","$seed"; |
|
407 } |
|
408 } |
|
409 } |
|
410 } |
372 |
411 |
373 /*const "mark" > =HMI=\n*/ |
412 /*const "mark" > =HMI=\n*/ |
|
413 |
|
414 const "result_svg" apply "/", mode="inline_svg"; |
|
415 const "result_svg_ns", "exsl:node-set($result_svg)"; |
374 |
416 |
375 /* copy root node and add geometry as comment for a test */ |
417 /* copy root node and add geometry as comment for a test */ |
376 template "/" { |
418 template "/" { |
377 comment > Made with SVGHMI. https://beremiz.org |
419 comment > Made with SVGHMI. https://beremiz.org |
378 /* DEBUG DATA */ |
420 /* DEBUG DATA */ |
620 param "mandatory","'yes'"; |
668 param "mandatory","'yes'"; |
621 param "hmi_element"; |
669 param "hmi_element"; |
622 const "widget_type","@type"; |
670 const "widget_type","@type"; |
623 foreach "str:split($labels)" { |
671 foreach "str:split($labels)" { |
624 const "name","."; |
672 const "name","."; |
625 const "elt_id","$hmi_element//*[@inkscape:label=$name][1]/@id"; |
673 const "elt_id","$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]/@id"; |
626 choose { |
674 choose { |
627 when "not($elt_id)" { |
675 when "not($elt_id)" { |
628 if "$mandatory='yes'" { |
676 if "$mandatory='yes'" { |
629 // TODO FIXME error > «$widget_type» widget must have a «$name» element |
677 // TODO FIXME error > «$widget_type» widget must have a «$name» element |
630 warning > «$widget_type» widget must have a «$name» element |
678 warning > «$widget_type» widget must have a «$name» element |