Laurent@1347: include yslt.yml2 Laurent@1347: estylesheet xmlns:ppx="http://www.plcopen.org/xml/tc6_0201" Laurent@1347: xmlns:xhtml="http://www.w3.org/1999/xhtml" Laurent@1347: xmlns:ns="var_infos_ns" Laurent@1347: extension-element-prefixes="ns" Laurent@1347: exclude-result-prefixes="ns" { Laurent@1347: Laurent@1347: param "tree"; Laurent@1347: Laurent@1347: template "text()"; Laurent@1347: Laurent@1347: variable "project" { Laurent@1347: choose { Laurent@1347: when "$tree='True'" { Laurent@1347: copy "document('project')/project/*"; Laurent@1347: } Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: variable "stdlib" { Laurent@1347: choose { Laurent@1347: when "$tree='True'" { Laurent@1347: copy "document('stdlib')/stdlib/*"; Laurent@1347: } Laurent@1347: } Laurent@1347: } Laurent@1347: variable "extensions" { Laurent@1347: choose { Laurent@1347: when "$tree='True'" { Laurent@1347: copy "document('extensions')/extensions/*"; Laurent@1347: } Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:returnType" { Laurent@1347: value "ns:AddTree()"; Laurent@1347: apply; Laurent@1347: } Laurent@1347: Laurent@1347: function "variables_infos" { Laurent@1347: param "var_class"; Laurent@1347: variable "var_option" { Laurent@1347: choose { Laurent@1347: when "@constant='true' or @constant='1'" > Constant Laurent@1347: when "@retain='true' or @retain='1'" > Retain Laurent@1347: when "@nonretain='true' or @nonretain='1'" > Non-Retain Laurent@1347: } Laurent@1347: } Laurent@1347: foreach "ppx:variable" { Laurent@1347: variable "initial_value" { Laurent@1347: apply "ppx:initialValue"; Laurent@1347: } Laurent@1347: variable "edit" { Laurent@1347: choose { Laurent@1347: when "$var_class='Global' or $var_class='External'" > true Laurent@1347: otherwise { Laurent@1347: apply "ppx:type", mode="var_edit"; Laurent@1347: } Laurent@1347: } Laurent@1347: } Laurent@1347: value "ns:AddTree()"; Laurent@1347: apply "ppx:type"; Laurent@1347: value "ns:AddVariable(@name, $var_class, $var_option, @address, $initial_value, $edit, ppx:documentation/xhtml:p/text())"; Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:localVars" { Laurent@1347: call "variables_infos" { Laurent@1347: with "var_class" > Local Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:globalVars" { Laurent@1347: call "variables_infos" { Laurent@1347: with "var_class" > Global Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:externalVars" { Laurent@1347: call "variables_infos" { Laurent@1347: with "var_class" > External Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:tempVars" { Laurent@1347: call "variables_infos" { Laurent@1347: with "var_class" > Temp Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:inputVars" { Laurent@1347: call "variables_infos" { Laurent@1347: with "var_class" > Input Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:outputVars" { Laurent@1347: call "variables_infos" { Laurent@1347: with "var_class" > Output Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:inOutVars" { Laurent@1347: call "variables_infos" { Laurent@1347: with "var_class" > InOut Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:pou" { Laurent@1347: apply "ppx:interface/*[self::ppx:inputVars or self::ppx:inOutVars or self::ppx:outputVars]/ppx:variable"; Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:variable" { Laurent@1347: variable "name" > «@name» Laurent@1347: value "ns:AddTree($name)"; Laurent@1347: apply "ppx:type"; Laurent@1347: value "ns:AddVarToTree($name)"; Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:dataType" { Laurent@1347: apply "ppx:baseType"; Laurent@1347: } Laurent@1347: Laurent@1347: template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:struct" { Laurent@1347: apply "ppx:variable"; Laurent@1347: } Laurent@1347: Laurent@1347: template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived" { Laurent@1347: variable "type_name" > «@name» Laurent@1347: choose { Laurent@1347: when "$tree='True'" { Laurent@1347: apply """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | Laurent@1347: exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] | Laurent@1347: exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | Laurent@1347: exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] | Laurent@1347: exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | Laurent@1347: exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]"""; Laurent@1347: } Laurent@1347: } Laurent@1347: value "ns:SetType($type_name)"; Laurent@1347: } Laurent@1347: Laurent@1347: template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:array" { Laurent@1347: apply "ppx:baseType"; Laurent@1347: foreach "ppx:dimension" { Laurent@1347: value "ns:AddDimension(@lower, @upper)"; Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string" { Laurent@1347: variable "name" > STRING Laurent@1347: value "ns:SetType($name)"; Laurent@1347: } Laurent@1347: Laurent@1347: template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring" { Laurent@1347: variable "name" > WSTRING Laurent@1347: value "ns:SetType($name)"; Laurent@1347: } Laurent@1347: Laurent@1347: template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*" { Laurent@1347: variable "name" > «local-name()» Laurent@1347: value "ns:SetType($name)"; Laurent@1347: } Laurent@1347: Laurent@1347: template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived", mode="var_edit" { Laurent@1347: variable "type_name", "@name"; Laurent@1347: variable "pou_infos" { Laurent@1347: copy """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | Laurent@1347: exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | Laurent@1347: exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"""; Laurent@1347: } Laurent@1347: choose { Laurent@1347: when "$pou_infos != ''" > false Laurent@1347: otherwise > true Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*", mode="var_edit" { Laurent@1347: > true Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:value" { Laurent@1347: choose { Laurent@1347: when "@repetitionValue" { Laurent@1347: > «@repetitionValue»( Laurent@1347: apply; Laurent@1347: > ) Laurent@1347: } Laurent@1347: when "@member" { Laurent@1347: > «@member» := Laurent@1347: apply; Laurent@1347: } Laurent@1347: otherwise { Laurent@1347: apply; Laurent@1347: } Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:simpleValue" { Laurent@1347: > «@value» Laurent@1347: } Laurent@1347: Laurent@1347: function "complex_type_value" { Laurent@1347: param "start_bracket"; Laurent@1347: param "end_bracket"; Laurent@1359: > «$start_bracket» Laurent@1347: foreach "ppx:value" { Laurent@1347: apply "."; Laurent@1347: choose { Laurent@1347: when "position()!=last()" > , Laurent@1347: } Laurent@1347: } Laurent@1359: > «$end_bracket» Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:arrayValue" { Laurent@1347: call "complex_type_value" { Laurent@1347: with "start_bracket" > [ Laurent@1347: with "end_bracket" > ] Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: template "ppx:structValue" { Laurent@1347: call "complex_type_value" { Laurent@1347: with "start_bracket" > ( Laurent@1347: with "end_bracket" > ) Laurent@1347: } Laurent@1347: } Laurent@1347: Laurent@1347: } Laurent@1347: Laurent@1347: Laurent@1347: