Edouard@2753: include yslt_noindent.yml2 Edouard@2779: Edouard@2779: // overrides yslt's output function to set CDATA Edouard@2779: decl output(method, cdata-section-elements="script"); Edouard@2753: istylesheet Edouard@2753: /* From Inkscape */ Edouard@2753: xmlns:dc="http://purl.org/dc/elements/1.1/" Edouard@2753: xmlns:cc="http://creativecommons.org/ns#" Edouard@2753: xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" Edouard@2753: xmlns:svg="http://www.w3.org/2000/svg" Edouard@2753: xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" Edouard@2753: xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" Edouard@2790: xmlns:xhtml="http://www.w3.org/1999/xhtml" Edouard@2753: Edouard@2753: /* Our namespace to invoke python code */ Edouard@2753: xmlns:ns="beremiz" Edouard@2753: extension-element-prefixes="ns" Edouard@2753: exclude-result-prefixes="ns" { Edouard@2753: Edouard@2753: /* This retrieves geometry obtained through "inkscape -S" Edouard@2753: * already parsed by python and presented as a list of Edouard@2753: * Edouard@2753: */ Edouard@2753: variable "geometry", "ns:GetSVGGeometry()"; Edouard@2763: variable "hmitree", "ns:GetHMITree()"; Edouard@2790: Edouard@2790: variable "_categories" { Edouard@2790: noindex > HMI_ROOT Edouard@2790: noindex > HMI_LABEL Edouard@2790: noindex > HMI_CLASS Edouard@2790: noindex > HMI_PLC_STATUS Edouard@2790: noindex > HMI_CURRENT_PAGE Edouard@2790: } Edouard@2790: variable "categories", "exsl:node-set($_categories)"; Edouard@2790: //variable "indexed_hmitree", "$hmitree[not(local-name() = $categories/noindex/text())]"; Edouard@2790: variable "indexed_hmitree" apply "$hmitree", mode="index"; Edouard@2790: Edouard@2790: template "node()", mode="index"{ Edouard@2790: param "index", "0"; Edouard@2790: variable "content" { Edouard@2790: choose { Edouard@2790: when "not(local-name() = $categories/noindex)" { Edouard@2790: xsl:copy { Edouard@2790: attrib "index" > «$index» Edouard@2790: foreach "@*" xsl:copy; Edouard@2790: } Edouard@2790: /* no node expected below value nodes */ Edouard@2790: } Edouard@2790: otherwise { Edouard@2790: apply "*[1]", mode="index"{ Edouard@2790: with "index", "$index"; Edouard@2790: } Edouard@2790: } Edouard@2790: } Edouard@2790: } Edouard@2790: Edouard@2790: copy "$content"; Edouard@2790: apply "following-sibling::*[1]", mode="index" { Edouard@2790: with "index", "$index + count(exsl:node-set($content)/*)"; Edouard@2790: } Edouard@2790: } Edouard@2790: Edouard@2753: /* Identity template : Edouard@2753: * - copy every attributes Edouard@2753: * - copy every sub-elements Edouard@2753: */ Edouard@2753: template "@* | node()" { Edouard@2753: /* use real xsl:copy instead copy-of alias from yslt.yml2 */ Edouard@2753: xsl:copy apply "@* | node()"; Edouard@2753: } Edouard@2753: Edouard@2782: variable "mark" > =HMI=\n Edouard@2782: Edouard@2753: /* copy root node and add geometry as comment for a test */ Edouard@2779: template "/" Edouard@2779: html xmlns="http://www.w3.org/1999/xhtml" { Edouard@2779: head; Edouard@2779: body style="margin:0;" { Edouard@2779: xsl:copy { Edouard@2779: comment { Edouard@2779: apply "$geometry", mode="testgeo"; Edouard@2779: } Edouard@2779: comment { Edouard@2779: apply "$hmitree", mode="testtree"; Edouard@2779: } Edouard@2790: comment { Edouard@2790: apply "exsl:node-set($indexed_hmitree)", mode="testtree"; Edouard@2790: } Edouard@2779: apply "@* | node()"; Edouard@2779: } Edouard@2780: script{ Edouard@2788: /* TODO : paste hmitree hash stored in hmi tree root node */ Edouard@2788: Edouard@2790: /* TODO re-enable Edouard@2783: || Edouard@2783: function evaluate_js_from_descriptions() { Edouard@2783: var Page; Edouard@2783: var Input; Edouard@2783: var Display; Edouard@2783: var res = []; Edouard@2783: || Edouard@2782: variable "midmark" > \n«$mark» Edouard@2782: apply """//*[contains(child::svg:desc, $midmark) or \ Edouard@2783: starts-with(child::svg:desc, $mark)]""",2 Edouard@2782: mode="code_from_descs"; Edouard@2783: || Edouard@2783: return res; Edouard@2783: } Edouard@2783: || Edouard@2790: */ Edouard@2782: Edouard@2780: /*TODO add : Edouard@2780: - pages content Edouard@2780: + with ref to elt ? Edouard@2780: - widgets parameters Edouard@2780: */ Edouard@2782: Edouard@2790: || Edouard@2790: var subscriptions = { Edouard@2790: || Edouard@2790: // apply "$hmitree", mode="subscription_"; Edouard@2790: || Edouard@2790: return res; Edouard@2790: } Edouard@2790: || Edouard@2780: include text svghmi.js Edouard@2780: } Edouard@2763: } Edouard@2753: } Edouard@2753: Edouard@2782: template "*", mode="code_from_descs" { Edouard@2783: || Edouard@2783: { Edouard@2783: var path, role, name, priv; Edouard@2783: var id = "«@id»"; Edouard@2783: || Edouard@2783: Edouard@2783: /* if label is used, use it as default name */ Edouard@2789: if "@inkscape:label" Edouard@2783: |> name = "«@inkscape:label»"; Edouard@2783: Edouard@2783: | /* -------------- */ Edouard@2783: Edouard@2783: // this breaks indent, but fixing indent could break string literals Edouard@2782: value "substring-after(svg:desc, $mark)"; Edouard@2783: // nobody reads generated code anyhow... Edouard@2783: Edouard@2783: || Edouard@2783: Edouard@2783: /* -------------- */ Edouard@2783: res.push({ Edouard@2783: path:path, Edouard@2783: role:role, Edouard@2783: name:name, Edouard@2783: priv:priv Edouard@2783: }) Edouard@2783: } Edouard@2783: || Edouard@2782: } Edouard@2782: Edouard@2782: Edouard@2753: template "bbox", mode="testgeo"{ Edouard@2763: | ID: «@Id» x: «@x» y: «@y» w: «@w» h: «@h» Edouard@2763: } Edouard@2763: Edouard@2763: template "*", mode="testtree"{ Edouard@2763: param "indent", "''"; Edouard@2790: > «$indent» «local-name()» Edouard@2790: foreach "@*" > «local-name()»=«.» Edouard@2790: > \n Edouard@2763: apply "*", mode="testtree" { Edouard@2763: with "indent" value "concat($indent,'>')" Edouard@2763: }; Edouard@2753: } Edouard@2753: }