svghmi/gen_dnd_widget_svg.xslt
branchwxPython4
changeset 3582 7dcd0de97e6f
parent 3507 e87a2daace80
child 3615 5c983ead9db0
equal deleted inserted replaced
3581:5a0f7fcf9a8f 3582:7dcd0de97e6f
     3   <xsl:output method="xml"/>
     3   <xsl:output method="xml"/>
     4   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     4   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     5   <xsl:variable name="widgetparams" select="ns:GetWidgetParams()"/>
     5   <xsl:variable name="widgetparams" select="ns:GetWidgetParams()"/>
     6   <xsl:variable name="indexed_hmitree" select="/.."/>
     6   <xsl:variable name="indexed_hmitree" select="/.."/>
     7   <xsl:variable name="pathregex" select="'^([^\[,]+)(\[[^\]]+\])?([-.\d,]*)$'"/>
     7   <xsl:variable name="pathregex" select="'^([^\[,]+)(\[[^\]]+\])?([-.\d,]*)$'"/>
       
     8   <xsl:variable name="newline">
       
     9     <xsl:text>
       
    10 </xsl:text>
       
    11   </xsl:variable>
       
    12   <xsl:variable name="twonewlines" select="concat($newline,$newline)"/>
     8   <xsl:template mode="parselabel" match="*">
    13   <xsl:template mode="parselabel" match="*">
     9     <xsl:variable name="label" select="@inkscape:label"/>
    14     <xsl:variable name="part" select="@inkscape:label"/>
       
    15     <xsl:variable name="desc" select="svg:desc"/>
       
    16     <xsl:variable name="len" select="string-length($part)"/>
       
    17     <xsl:variable name="has_continuation" select="substring($part,$len,1)='\'"/>
       
    18     <xsl:variable name="label">
       
    19       <xsl:choose>
       
    20         <xsl:when test="$has_continuation">
       
    21           <xsl:variable name="_continuation" select="substring-before($desc, $twonewlines)"/>
       
    22           <xsl:variable name="continuation">
       
    23             <xsl:choose>
       
    24               <xsl:when test="$_continuation">
       
    25                 <xsl:value-of select="$_continuation"/>
       
    26               </xsl:when>
       
    27               <xsl:otherwise>
       
    28                 <xsl:value-of select="$desc"/>
       
    29               </xsl:otherwise>
       
    30             </xsl:choose>
       
    31           </xsl:variable>
       
    32           <xsl:value-of select="concat(substring($part,1,$len - 1),translate($continuation,$newline,''))"/>
       
    33         </xsl:when>
       
    34         <xsl:otherwise>
       
    35           <xsl:value-of select="$part"/>
       
    36         </xsl:otherwise>
       
    37       </xsl:choose>
       
    38     </xsl:variable>
    10     <xsl:variable name="id" select="@id"/>
    39     <xsl:variable name="id" select="@id"/>
    11     <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
    40     <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
    12     <xsl:variable name="_args" select="substring-before($description,'@')"/>
    41     <xsl:variable name="_args" select="substring-before($description,'@')"/>
    13     <xsl:variable name="args">
    42     <xsl:variable name="args">
    14       <xsl:choose>
    43       <xsl:choose>
   148                 </xsl:choose>
   177                 </xsl:choose>
   149               </xsl:if>
   178               </xsl:if>
   150             </path>
   179             </path>
   151           </xsl:if>
   180           </xsl:if>
   152         </xsl:for-each>
   181         </xsl:for-each>
   153         <xsl:if test="svg:desc">
   182         <xsl:choose>
   154           <desc>
   183           <xsl:when test="$has_continuation">
   155             <xsl:value-of select="svg:desc/text()"/>
   184             <xsl:variable name="_continuation" select="substring-after($desc, $twonewlines)"/>
   156           </desc>
   185             <xsl:if test="$_continuation">
   157         </xsl:if>
   186               <desc>
       
   187                 <xsl:value-of select="$_continuation"/>
       
   188               </desc>
       
   189             </xsl:if>
       
   190           </xsl:when>
       
   191           <xsl:otherwise>
       
   192             <xsl:if test="$desc">
       
   193               <desc>
       
   194                 <xsl:value-of select="$desc/text()"/>
       
   195               </desc>
       
   196             </xsl:if>
       
   197           </xsl:otherwise>
       
   198         </xsl:choose>
   158       </widget>
   199       </widget>
   159     </xsl:if>
   200     </xsl:if>
   160   </xsl:template>
   201   </xsl:template>
   161   <xsl:template mode="genlabel" match="arg">
   202   <xsl:template mode="genlabel" match="arg">
   162     <xsl:text>:</xsl:text>
   203     <xsl:text>:</xsl:text>