--- a/svghmi/gen_dnd_widget_svg.xslt Wed Sep 14 14:59:18 2022 +0200
+++ b/svghmi/gen_dnd_widget_svg.xslt Wed Sep 14 15:02:43 2022 +0200
@@ -4,18 +4,18 @@
<xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
<xsl:variable name="widgetparams" select="ns:GetWidgetParams()"/>
<xsl:variable name="indexed_hmitree" select="/.."/>
- <xsl:variable name="pathregex" select="'^([^\[,]+)(\[[^\]]+\])?([-.\d,]*)$'"/>
+ <xsl:variable name="pathregex" select="'^(\w+=)?([^,=]+)([-.\d,]*)$'"/>
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>
<xsl:variable name="twonewlines" select="concat($newline,$newline)"/>
<xsl:template mode="parselabel" match="*">
- <xsl:variable name="part" select="@inkscape:label"/>
+ <xsl:variable name="label" select="@inkscape:label"/>
<xsl:variable name="desc" select="svg:desc"/>
- <xsl:variable name="len" select="string-length($part)"/>
- <xsl:variable name="has_continuation" select="substring($part,$len,1)='\'"/>
- <xsl:variable name="label">
+ <xsl:variable name="len" select="string-length($label)"/>
+ <xsl:variable name="has_continuation" select="substring($label,$len,1)='\'"/>
+ <xsl:variable name="full_decl">
<xsl:choose>
<xsl:when test="$has_continuation">
<xsl:variable name="_continuation" select="substring-before($desc, $twonewlines)"/>
@@ -29,23 +29,23 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
- <xsl:value-of select="concat(substring($part,1,$len - 1),translate($continuation,$newline,''))"/>
+ <xsl:value-of select="concat(substring($label,1,$len - 1),translate($continuation,$newline,''))"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="$part"/>
+ <xsl:value-of select="$label"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="id" select="@id"/>
- <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
- <xsl:variable name="_args" select="substring-before($description,'@')"/>
+ <xsl:variable name="declaration" select="substring-after($full_decl,'HMI:')"/>
+ <xsl:variable name="_args" select="substring-before($declaration,'@')"/>
<xsl:variable name="args">
<xsl:choose>
<xsl:when test="$_args">
<xsl:value-of select="$_args"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="$description"/>
+ <xsl:value-of select="$declaration"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
@@ -86,7 +86,7 @@
<xsl:text>Widget id:</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text> label:</xsl:text>
- <xsl:value-of select="$label"/>
+ <xsl:value-of select="$full_decl"/>
<xsl:text> has wrong syntax of frequency forcing </xsl:text>
<xsl:value-of select="$freq"/>
</xsl:message>
@@ -95,6 +95,25 @@
<xsl:value-of select="$freq"/>
</xsl:attribute>
</xsl:if>
+ <xsl:variable name="tail" select="substring-after($declaration,'@')"/>
+ <xsl:variable name="taillen" select="string-length($tail)"/>
+ <xsl:variable name="has_enable" select="contains($tail, '#')"/>
+ <xsl:variable name="paths">
+ <xsl:choose>
+ <xsl:when test="$has_enable">
+ <xsl:value-of select="substring-before($tail,'#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$tail"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:if test="$has_enable">
+ <xsl:variable name="enable_expr" select="substring-after($tail,'#')"/>
+ <xsl:attribute name="enable_expr">
+ <xsl:value-of select="$enable_expr"/>
+ </xsl:attribute>
+ </xsl:if>
<xsl:for-each select="str:split(substring-after($args, ':'), ':')">
<arg>
<xsl:attribute name="value">
@@ -102,21 +121,29 @@
</xsl:attribute>
</arg>
</xsl:for-each>
- <xsl:variable name="paths" select="substring-after($description,'@')"/>
<xsl:for-each select="str:split($paths, '@')">
<xsl:if test="string-length(.) > 0">
<path>
<xsl:variable name="path_match" select="regexp:match(.,$pathregex)"/>
+ <xsl:variable name="pathassign" select="substring-before($path_match[2],'=')"/>
<xsl:variable name="pathminmax" select="str:split($path_match[4],',')"/>
- <xsl:variable name="path" select="$path_match[2]"/>
- <xsl:variable name="path_accepts" select="$path_match[3]"/>
+ <xsl:variable name="path" select="$path_match[3]"/>
<xsl:variable name="pathminmaxcount" select="count($pathminmax)"/>
+ <xsl:if test="not($path)">
+ <xsl:message terminate="yes">
+ <xsl:text>Widget id:</xsl:text>
+ <xsl:value-of select="$id"/>
+ <xsl:text> label:</xsl:text>
+ <xsl:value-of select="$full_decl"/>
+ <xsl:text> has wrong syntax</xsl:text>
+ </xsl:message>
+ </xsl:if>
<xsl:attribute name="value">
<xsl:value-of select="$path"/>
</xsl:attribute>
- <xsl:if test="string-length($path_accepts)">
- <xsl:attribute name="accepts">
- <xsl:value-of select="$path_accepts"/>
+ <xsl:if test="$pathassign">
+ <xsl:attribute name="assign">
+ <xsl:value-of select="$pathassign"/>
</xsl:attribute>
</xsl:if>
<xsl:choose>
@@ -133,7 +160,7 @@
<xsl:text>Widget id:</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text> label:</xsl:text>
- <xsl:value-of select="$label"/>
+ <xsl:value-of select="$full_decl"/>
<xsl:text> has wrong syntax of path section </xsl:text>
<xsl:value-of select="$pathminmax"/>
</xsl:message>
@@ -159,7 +186,7 @@
<xsl:text>Widget id:</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text> label:</xsl:text>
- <xsl:value-of select="$label"/>
+ <xsl:value-of select="$full_decl"/>
<xsl:text> path section </xsl:text>
<xsl:value-of select="$pathminmax"/>
<xsl:text> use min and max on non mumeric value</xsl:text>