svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2782 723e420dfe72
parent 2779 75c6a31caca6
child 2783 5ee6967f721d
equal deleted inserted replaced
2781:fbdd0fd8ee4f 2782:723e420dfe72
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2 <xsl:stylesheet xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/1999/xhtml" xmlns:exsl="http://exslt.org/common" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" extension-element-prefixes="ns" version="1.0" exclude-result-prefixes="ns">
     2 <xsl:stylesheet xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns="beremiz" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/1999/xhtml" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" exclude-result-prefixes="ns" extension-element-prefixes="ns" version="1.0">
     3   <xsl:output method="xml" cdata-section-elements="script"/>
     3   <xsl:output method="xml" cdata-section-elements="script"/>
     4   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
     4   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
     5   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     5   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     6   <xsl:template match="@* | node()">
     6   <xsl:template match="@* | node()">
     7     <xsl:copy>
     7     <xsl:copy>
     8       <xsl:apply-templates select="@* | node()"/>
     8       <xsl:apply-templates select="@* | node()"/>
     9     </xsl:copy>
     9     </xsl:copy>
    10   </xsl:template>
    10   </xsl:template>
       
    11   <xsl:variable name="mark">
       
    12     <xsl:text>=HMI=
       
    13 </xsl:text>
       
    14   </xsl:variable>
    11   <xsl:template match="/">
    15   <xsl:template match="/">
    12     <html xmlns="http://www.w3.org/1999/xhtml">
    16     <html xmlns="http://www.w3.org/1999/xhtml">
    13       <head/>
    17       <head/>
    14       <body style="margin:0;">
    18       <body style="margin:0;">
    15         <xsl:copy>
    19         <xsl:copy>
    20             <xsl:apply-templates mode="testtree" select="$hmitree"/>
    24             <xsl:apply-templates mode="testtree" select="$hmitree"/>
    21           </xsl:comment>
    25           </xsl:comment>
    22           <xsl:apply-templates select="@* | node()"/>
    26           <xsl:apply-templates select="@* | node()"/>
    23         </xsl:copy>
    27         </xsl:copy>
    24         <script>
    28         <script>
       
    29           <xsl:variable name="midmark">
       
    30             <xsl:text>
       
    31 </xsl:text>
       
    32             <xsl:value-of select="$mark"/>
       
    33           </xsl:variable>
       
    34           <xsl:apply-templates mode="code_from_descs" select="//*[contains(child::svg:desc, $midmark) or                                starts-with(child::svg:desc, $mark)]"/>
       
    35           <xsl:text>
       
    36 </xsl:text>
    25           <xsl:text>(function(){
    37           <xsl:text>(function(){
    26 </xsl:text>
    38 </xsl:text>
    27           <xsl:text>    var relative_URI = window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws');
    39           <xsl:text>    var relative_URI = window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws');
    28 </xsl:text>
    40 </xsl:text>
    29           <xsl:text>    var ws = new WebSocket(relative_URI);
    41           <xsl:text>    var ws = new WebSocket(relative_URI);
    45           <xsl:text>})();
    57           <xsl:text>})();
    46 </xsl:text>
    58 </xsl:text>
    47         </script>
    59         </script>
    48       </body>
    60       </body>
    49     </html>
    61     </html>
       
    62   </xsl:template>
       
    63   <xsl:template mode="code_from_descs" match="*">
       
    64     <xsl:text>function js_</xsl:text>
       
    65     <xsl:value-of select="@id"/>
       
    66     <xsl:text>() {
       
    67 </xsl:text>
       
    68     <xsl:text>var path, role, path, priv;
       
    69 </xsl:text>
       
    70     <xsl:text>
       
    71 </xsl:text>
       
    72     <xsl:value-of select="substring-after(svg:desc, $mark)"/>
       
    73     <xsl:text>
       
    74 </xsl:text>
       
    75     <xsl:text>}
       
    76 </xsl:text>
       
    77     <xsl:text>
       
    78 </xsl:text>
    50   </xsl:template>
    79   </xsl:template>
    51   <xsl:template mode="testgeo" match="bbox">
    80   <xsl:template mode="testgeo" match="bbox">
    52     <xsl:text>ID: </xsl:text>
    81     <xsl:text>ID: </xsl:text>
    53     <xsl:value-of select="@Id"/>
    82     <xsl:value-of select="@Id"/>
    54     <xsl:text> x: </xsl:text>
    83     <xsl:text> x: </xsl:text>