svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2879 58e6a91dc37f
parent 2878 bec552270ad1
child 2881 3bb49f93d48c
equal deleted inserted replaced
2878:bec552270ad1 2879:58e6a91dc37f
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2 <xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:str="http://exslt.org/strings" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0" exclude-result-prefixes="ns str regexp exsl func dyn">
     2 <xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" xmlns:str="http://exslt.org/strings" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0" exclude-result-prefixes="ns str regexp exsl func dyn">
     3   <xsl:output method="xml" cdata-section-elements="xhtml:script"/>
     3   <xsl:output method="xml" cdata-section-elements="xhtml:script"/>
       
     4   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     4   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     5   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     5   <xsl:variable name="_categories">
     6   <xsl:variable name="_categories">
     6     <noindex>
     7     <noindex>
     7       <xsl:text>HMI_ROOT</xsl:text>
     8       <xsl:text>HMI_ROOT</xsl:text>
     8     </noindex>
     9     </noindex>
   164   </xsl:template>
   165   </xsl:template>
   165   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
   166   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
   166   <xsl:template name="debug_geometry">
   167   <xsl:template name="debug_geometry">
   167     <xsl:text>ID, x, y, w, h
   168     <xsl:text>ID, x, y, w, h
   168 </xsl:text>
   169 </xsl:text>
   169     <xsl:for-each select="$geometry[@Id = $hmi_elements/@id]">
   170     <xsl:for-each select="$geometry">
   170       <xsl:text> </xsl:text>
   171       <xsl:text> </xsl:text>
   171       <xsl:value-of select="@Id"/>
   172       <xsl:value-of select="@Id"/>
   172       <xsl:text> </xsl:text>
   173       <xsl:text> </xsl:text>
   173       <xsl:value-of select="@x"/>
   174       <xsl:value-of select="@x"/>
   174       <xsl:text> </xsl:text>
   175       <xsl:text> </xsl:text>
   225     <xsl:variable name="groups" select="/svg:svg | //svg:g"/>
   226     <xsl:variable name="groups" select="/svg:svg | //svg:g"/>
   226     <xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/>
   227     <xsl:variable name="g" select="$geometry[@Id = $elt/@id]"/>
   227     <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/>
   228     <xsl:variable name="candidates" select="$geometry[@Id != $elt/@id]"/>
   228     <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or &#10;                          (not(@Id = $groups/@id) and (func:intersect($g, .) &gt; 0 ))]"/>
   229     <func:result select="$candidates[(@Id = $groups/@id and (func:intersect($g, .) = 9)) or &#10;                          (not(@Id = $groups/@id) and (func:intersect($g, .) &gt; 0 ))]"/>
   229   </func:function>
   230   </func:function>
   230   <xsl:variable name="svg_root_id" select="/svg:svg/@id"/>
       
   231   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
       
   232   <xsl:variable name="hmi_pages" select="$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"/>
   231   <xsl:variable name="hmi_pages" select="$hmi_elements[func:parselabel(@inkscape:label)/widget/@type = 'Page']"/>
   233   <xsl:variable name="default_page">
   232   <xsl:variable name="default_page">
   234     <xsl:choose>
   233     <xsl:choose>
   235       <xsl:when test="count($hmi_pages) &gt; 1">
   234       <xsl:when test="count($hmi_pages) &gt; 1">
   236         <xsl:variable name="Home_page" select="$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']"/>
   235         <xsl:variable name="Home_page" select="$hmi_pages[func:parselabel(@inkscape:label)/widget/arg[1]/@value = 'Home']"/>
   566 </xsl:text>
   565 </xsl:text>
   567       <xsl:call-template name="debug_unlink"/>
   566       <xsl:call-template name="debug_unlink"/>
   568       <xsl:text>
   567       <xsl:text>
   569 </xsl:text>
   568 </xsl:text>
   570     </xsl:comment>
   569     </xsl:comment>
   571     <xsl:comment>
       
   572       <xsl:text>Unlinked :
       
   573 </xsl:text>
       
   574       <xsl:for-each select="$to_unlink">
       
   575         <xsl:value-of select="@id"/>
       
   576         <xsl:text>
       
   577 </xsl:text>
       
   578       </xsl:for-each>
       
   579     </xsl:comment>
       
   580     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
   570     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
   581       <head/>
   571       <head/>
   582       <body style="margin:0;overflow:hidden;">
   572       <body style="margin:0;overflow:hidden;">
   583         <xsl:copy-of select="$result_svg"/>
   573         <xsl:copy-of select="$result_svg"/>
   584         <script>
   574         <script>
   729     <xsl:text>var default_page = "</xsl:text>
   719     <xsl:text>var default_page = "</xsl:text>
   730     <xsl:value-of select="$default_page"/>
   720     <xsl:value-of select="$default_page"/>
   731     <xsl:text>";
   721     <xsl:text>";
   732 </xsl:text>
   722 </xsl:text>
   733     <xsl:text>var svg_root = id("</xsl:text>
   723     <xsl:text>var svg_root = id("</xsl:text>
   734     <xsl:value-of select="$svg_root_id"/>
   724     <xsl:value-of select="/svg:svg/@id"/>
   735     <xsl:text>");
   725     <xsl:text>");
   736 </xsl:text>
   726 </xsl:text>
   737     <xsl:text>// svghmi.js
   727     <xsl:text>// svghmi.js
   738 </xsl:text>
   728 </xsl:text>
   739     <xsl:text>
   729     <xsl:text>