--- a/svghmi/gen_index_xhtml.xslt Thu Aug 27 09:59:35 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt Thu Aug 27 14:34:00 2020 +0200
@@ -3587,10 +3587,22 @@
</xsl:variable>
<func:result select="$widget_elts[@id=$eltid]/@inkscape:label"/>
</func:function>
+ <xsl:template mode="json_table_render_except_comments" match="svg:*">
+ <xsl:param name="expressions"/>
+ <xsl:param name="widget_elts"/>
+ <xsl:variable name="label" select="func:filter_non_widget_label(., $widget_elts)"/>
+ <xsl:if test="not(starts-with($label,'#'))">
+ <xsl:apply-templates mode="json_table_render" select=".">
+ <xsl:with-param name="expressions" select="$expressions"/>
+ <xsl:with-param name="widget_elts" select="$widget_elts"/>
+ <xsl:with-param name="label" select="$label"/>
+ </xsl:apply-templates>
+ </xsl:if>
+ </xsl:template>
<xsl:template mode="json_table_render" match="svg:*">
<xsl:param name="expressions"/>
<xsl:param name="widget_elts"/>
- <xsl:variable name="label" select="func:filter_non_widget_label(., $widget_elts)"/>
+ <xsl:param name="label"/>
<xsl:apply-templates mode="json_table_elt_render" select=".">
<xsl:with-param name="expressions" select="func:json_expressions($expressions, $label)"/>
</xsl:apply-templates>
@@ -3598,6 +3610,7 @@
<xsl:template mode="json_table_render" match="svg:g">
<xsl:param name="expressions"/>
<xsl:param name="widget_elts"/>
+ <xsl:param name="label"/>
<xsl:variable name="gid" select="@id"/>
<xsl:variable name="varprefix">
<xsl:text>obj_</xsl:text>
@@ -3648,8 +3661,7 @@
<xsl:value-of select="@style"/>
<xsl:text>");
</xsl:text>
- <xsl:variable name="label" select="func:filter_non_widget_label(., $widget_elts)"/>
- <xsl:apply-templates mode="json_table_render" select="*">
+ <xsl:apply-templates mode="json_table_render_except_comments" select="*">
<xsl:with-param name="expressions" select="func:json_expressions(exsl:node-set($new_expressions), $label)"/>
<xsl:with-param name="widget_elts" select="$widget_elts"/>
</xsl:apply-templates>
@@ -3692,7 +3704,7 @@
</xsl:text>
<xsl:text> console.log(range,position,jdata);
</xsl:text>
- <xsl:apply-templates mode="json_table_render" select="$data_elt/*">
+ <xsl:apply-templates mode="json_table_render_except_comments" select="$data_elt">
<xsl:with-param name="expressions" select="$initexpr_ns"/>
<xsl:with-param name="widget_elts" select="$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*"/>
</xsl:apply-templates>
--- a/svghmi/widget_jsontable.ysl2 Thu Aug 27 09:59:35 2020 +0200
+++ b/svghmi/widget_jsontable.ysl2 Thu Aug 27 14:34:00 2020 +0200
@@ -70,7 +70,7 @@
choose {
when "contains($suffix,'=')" {
const "name", "substring-before($suffix,'=')";
- if "$expr/@name[. != $name]"
+ if "$expr/@name[. != $name]"
error > JsonTable : missplaced '=' or inconsistent names in Json data expressions.
attrib "name" value "$name";
attrib "content" > «$expr/@content»«substring-after($suffix,'=')»
@@ -144,18 +144,32 @@
result "$widget_elts[@id=$eltid]/@inkscape:label";
}
+template "svg:*", mode="json_table_render_except_comments"{
+ param "expressions";
+ param "widget_elts";
+
+ const "label", "func:filter_non_widget_label(., $widget_elts)";
+ // filter out "# commented" elements
+ if "not(starts-with($label,'#'))"
+ apply ".", mode="json_table_render"{
+ with "expressions", "$expressions";
+ with "widget_elts", "$widget_elts";
+ with "label", "$label";
+ }
+}
+
template "svg:*", mode="json_table_render" {
param "expressions";
param "widget_elts";
- const "label", "func:filter_non_widget_label(., $widget_elts)";
- apply ".", mode="json_table_elt_render" {
+ param "label";
+ apply ".", mode="json_table_elt_render"
with "expressions", "func:json_expressions($expressions, $label)";
- }
}
template "svg:g", mode="json_table_render" {
param "expressions";
param "widget_elts";
+ param "label";
const "gid", "@id";
// use intermediate variables for optimization
@@ -179,8 +193,7 @@
// revert hiding in case it did happen before
| id("«@id»").setAttribute("style", "«@style»");
- const "label", "func:filter_non_widget_label(., $widget_elts)";
- apply "*", mode="json_table_render" {
+ apply "*", mode="json_table_render_except_comments" {
with "expressions", "func:json_expressions(exsl:node-set($new_expressions), $label)";
with "widget_elts", "$widget_elts";
}
@@ -200,7 +213,7 @@
| this.apply_hmi_value(1, range);
| this.apply_hmi_value(2, position);
| console.log(range,position,jdata);
- apply "$data_elt/*", mode="json_table_render" {
+ apply "$data_elt", mode="json_table_render_except_comments" {
with "expressions","$initexpr_ns";
with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*";
}