svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2969 88988edb2e93
parent 2962 02ea529fd08c
child 2970 4a9b0df0602a
equal deleted inserted replaced
2968:556ef07a7e31 2969:88988edb2e93
   656   <xsl:template mode="inline_svg" match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']">
   656   <xsl:template mode="inline_svg" match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']">
   657     <xsl:message terminate="yes">
   657     <xsl:message terminate="yes">
   658       <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text>
   658       <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text>
   659     </xsl:message>
   659     </xsl:message>
   660   </xsl:template>
   660   </xsl:template>
   661   <xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages)]//svg:use"/>
   661   <xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages)]/descendant-or-self::svg:use"/>
   662   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="svg:use">
   662   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="svg:use">
   663     <xsl:choose>
   663     <xsl:choose>
   664       <xsl:when test="@id = $to_unlink/@id">
   664       <xsl:when test="@id = $to_unlink/@id">
   665         <xsl:call-template name="unlink_clone"/>
   665         <xsl:call-template name="unlink_clone"/>
   666       </xsl:when>
   666       </xsl:when>
   687     <name>
   687     <name>
   688       <xsl:text>y</xsl:text>
   688       <xsl:text>y</xsl:text>
   689     </name>
   689     </name>
   690   </xsl:variable>
   690   </xsl:variable>
   691   <xsl:variable name="excluded_use_attrs" select="exsl:node-set($_excluded_use_attrs)"/>
   691   <xsl:variable name="excluded_use_attrs" select="exsl:node-set($_excluded_use_attrs)"/>
       
   692   <xsl:variable name="_merge_use_attrs">
       
   693     <name>
       
   694       <xsl:text>transform</xsl:text>
       
   695     </name>
       
   696     <name>
       
   697       <xsl:text>style</xsl:text>
       
   698     </name>
       
   699   </xsl:variable>
       
   700   <xsl:variable name="merge_use_attrs" select="exsl:node-set($_merge_use_attrs)"/>
   692   <xsl:template xmlns="http://www.w3.org/2000/svg" name="unlink_clone">
   701   <xsl:template xmlns="http://www.w3.org/2000/svg" name="unlink_clone">
       
   702     <xsl:variable name="targetid" select="substring-after(@xlink:href,'#')"/>
       
   703     <xsl:variable name="target" select="//svg:*[@id = $targetid]"/>
   693     <g>
   704     <g>
   694       <xsl:for-each select="@*[not(local-name() = $excluded_use_attrs/name)]">
   705       <xsl:choose>
   695         <xsl:attribute name="{name()}">
   706         <xsl:when test="$target[self::svg:g]">
   696           <xsl:value-of select="."/>
   707           <xsl:for-each select="@*[not(local-name() = $excluded_use_attrs/name | $merge_use_attrs)]">
   697         </xsl:attribute>
   708             <xsl:attribute name="{name()}">
   698       </xsl:for-each>
   709               <xsl:value-of select="."/>
   699       <xsl:variable name="targetid" select="substring-after(@xlink:href,'#')"/>
   710             </xsl:attribute>
   700       <xsl:apply-templates mode="unlink_clone" select="//svg:*[@id = $targetid]">
   711           </xsl:for-each>
   701         <xsl:with-param name="seed" select="@id"/>
   712           <xsl:if test="@style | $target/@style">
   702       </xsl:apply-templates>
   713             <xsl:attribute name="style">
       
   714               <xsl:value-of select="@style"/>
       
   715               <xsl:if test="@style and $target/@style">
       
   716                 <xsl:text>;</xsl:text>
       
   717               </xsl:if>
       
   718               <xsl:value-of select="$target/@style"/>
       
   719             </xsl:attribute>
       
   720           </xsl:if>
       
   721           <xsl:if test="@transform | $target/@transform">
       
   722             <xsl:attribute name="transform">
       
   723               <xsl:value-of select="@transform"/>
       
   724               <xsl:if test="@transform and $target/@transform">
       
   725                 <xsl:text> </xsl:text>
       
   726               </xsl:if>
       
   727               <xsl:value-of select="$target/@transform"/>
       
   728             </xsl:attribute>
       
   729           </xsl:if>
       
   730           <xsl:apply-templates mode="unlink_clone" select="$target/*">
       
   731             <xsl:with-param name="seed" select="@id"/>
       
   732           </xsl:apply-templates>
       
   733         </xsl:when>
       
   734         <xsl:otherwise>
       
   735           <xsl:for-each select="@*[not(local-name() = $excluded_use_attrs/name)]">
       
   736             <xsl:attribute name="{name()}">
       
   737               <xsl:value-of select="."/>
       
   738             </xsl:attribute>
       
   739           </xsl:for-each>
       
   740           <xsl:apply-templates mode="unlink_clone" select="$target">
       
   741             <xsl:with-param name="seed" select="@id"/>
       
   742           </xsl:apply-templates>
       
   743         </xsl:otherwise>
       
   744       </xsl:choose>
   703     </g>
   745     </g>
   704   </xsl:template>
   746   </xsl:template>
   705   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="unlink_clone" match="@id">
   747   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="unlink_clone" match="@id">
   706     <xsl:param name="seed"/>
   748     <xsl:param name="seed"/>
   707     <xsl:attribute name="id">
   749     <xsl:attribute name="id">
  1115 </xsl:text>
  1157 </xsl:text>
  1116     <xsl:text>    frequency = 5;
  1158     <xsl:text>    frequency = 5;
  1117 </xsl:text>
  1159 </xsl:text>
  1118     <xsl:text>    init() {
  1160     <xsl:text>    init() {
  1119 </xsl:text>
  1161 </xsl:text>
  1120     <xsl:text>        // TODO : use attributes to allow interaction through svg:use
       
  1121 </xsl:text>
       
  1122     <xsl:text>        // TODO : deal with dragging
       
  1123 </xsl:text>
       
  1124     <xsl:text>        this.element.addEventListener(
  1162     <xsl:text>        this.element.addEventListener(
  1125 </xsl:text>
  1163 </xsl:text>
  1126     <xsl:text>          "mousedown",
  1164     <xsl:text>          "mousedown",
  1127 </xsl:text>
  1165 </xsl:text>
  1128     <xsl:text>          evt =&gt; {
  1166     <xsl:text>          evt =&gt; {
  2627   <xsl:template mode="widget_defs" match="widget[@type='Switch']">
  2665   <xsl:template mode="widget_defs" match="widget[@type='Switch']">
  2628     <xsl:param name="hmi_element"/>
  2666     <xsl:param name="hmi_element"/>
  2629     <xsl:text>    choices: [
  2667     <xsl:text>    choices: [
  2630 </xsl:text>
  2668 </xsl:text>
  2631     <xsl:variable name="regex" select="'^(&quot;[^&quot;].*&quot;|\-?[0-9]+|false|true)(#.*)?$'"/>
  2669     <xsl:variable name="regex" select="'^(&quot;[^&quot;].*&quot;|\-?[0-9]+|false|true)(#.*)?$'"/>
  2632     <xsl:for-each select="$hmi_element/*[regexp:test(@inkscape:label,$regex)]">
  2670     <xsl:for-each select="$result_svg_ns//*[@id = $hmi_element/@id]//*[regexp:test(@inkscape:label,$regex)]">
  2633       <xsl:variable name="literal" select="regexp:match(@inkscape:label,$regex)[2]"/>
  2671       <xsl:variable name="literal" select="regexp:match(@inkscape:label,$regex)[2]"/>
  2634       <xsl:text>        {
  2672       <xsl:text>        {
  2635 </xsl:text>
  2673 </xsl:text>
  2636       <xsl:text>            elt:id("</xsl:text>
  2674       <xsl:text>            elt:id("</xsl:text>
  2637       <xsl:value-of select="@id"/>
  2675       <xsl:value-of select="@id"/>