plcopen/instances_path.ysl2
changeset 1350 7280349a3375
child 1352 9ec4ac8e2955
equal deleted inserted replaced
1349:be6c3a036844 1350:7280349a3375
       
     1 include yslt.yml2
       
     2 estylesheet xmlns:ppx="http://www.plcopen.org/xml/tc6_0201"
       
     3             xmlns:xhtml="http://www.w3.org/1999/xhtml"
       
     4             xmlns:ns="instances_ns" 
       
     5             extension-element-prefixes="ns" 
       
     6             exclude-result-prefixes="ns" {
       
     7     
       
     8     param "instance_type";
       
     9     
       
    10     template "text()";
       
    11     
       
    12     variable "project" {
       
    13         copy "document('project')/project/*";
       
    14     }
       
    15     
       
    16     variable "stdlib" {
       
    17         copy "document('stdlib')/stdlib/*";
       
    18     }
       
    19     variable "extensions" {
       
    20         copy "document('extensions')/extensions/*";
       
    21     }
       
    22     
       
    23     template "ppx:project" {
       
    24         instances {
       
    25             apply "ppx:instances/ppx:configurations/ppx:configuration";
       
    26         }
       
    27     }
       
    28     
       
    29     template "ppx:configuration" {
       
    30         apply "ppx:globalVars/ppx:variable[ppx:type/ppx:derived] | ppx:resource" {
       
    31             with "parent_path" > «@name»
       
    32         }
       
    33     }
       
    34     
       
    35     template "ppx:resource" {
       
    36         param "parent_path";
       
    37         variable "resource_path" > «$parent_path».«@name»
       
    38         apply "ppx:globalVars/ppx:variable[ppx:type/ppx:derived] | ppx:pouInstance | ppx:task/ppx:pouInstance" {
       
    39             with "parent_path" > «$resource_path»
       
    40         }
       
    41     }
       
    42     
       
    43     template "ppx:pouInstance" {
       
    44         param "parent_path";
       
    45         variable "pou_instance_path" > «$parent_path».«@name»
       
    46         choose {
       
    47             when "@typeName=$instance_type" {
       
    48                 value "ns:AddInstance($pou_instance_path)";
       
    49             }
       
    50             otherwise {
       
    51                 variable "type_name" > «@typeName»
       
    52                 apply """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
    53                          exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
       
    54                          exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
    55                          exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
       
    56                          exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
    57                          exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
       
    58                     with "instance_path" > «$pou_instance_path»
       
    59                 }
       
    60             }
       
    61         }
       
    62     }
       
    63     
       
    64     template "ppx:pou" {
       
    65         param "instance_path";
       
    66         apply "ppx:interface/*/ppx:variable[ppx:type/ppx:derived]" {
       
    67             with "parent_path" > «$instance_path»
       
    68         }
       
    69     }
       
    70     
       
    71     template "ppx:dataType" {
       
    72         param "instance_path";
       
    73         apply "ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
       
    74             with "parent_path" > «$instance_path»
       
    75         }
       
    76     }
       
    77     
       
    78     template "ppx:variable" {
       
    79         param "parent_path";
       
    80         variable "variable_path" > «$parent_path».«@name»
       
    81         apply "ppx:type/ppx:derived" {
       
    82             with "variable_path" > «$variable_path»
       
    83         }
       
    84     }
       
    85     
       
    86     template "ppx:derived" {
       
    87         param "variable_path";
       
    88         choose {
       
    89             when "@name=$instance_type" {
       
    90                 value "ns:AddInstance($variable_path)";
       
    91             }
       
    92             otherwise {
       
    93                 variable "type_name" > «@name»
       
    94                 apply """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
    95                          exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
       
    96                          exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
    97                          exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
       
    98                          exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
    99                          exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
       
   100                     with "instance_path" > «$variable_path»
       
   101                 }
       
   102             }
       
   103         }
       
   104     }
       
   105     
       
   106     template "ppx:struct" {
       
   107         param "variable_path";
       
   108         foreach "ppx:variable[ppx:type/ppx:derived or ppx:type/ppx:struct or ppx:type/ppx:array]" {
       
   109             variable "element_path" > «$variable_path».«@name»
       
   110         }
       
   111         apply "ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
       
   112             with "variable_path" > «$element_path»
       
   113         }
       
   114     }
       
   115     
       
   116     template "ppx:array" {
       
   117         param "variable_path";
       
   118         apply "ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
       
   119             with "variable_path" > «$variable_path»
       
   120         }
       
   121     }
       
   122     
       
   123     template "pou_instance" {
       
   124         apply {
       
   125             with "instance_path" > «@pou_path»
       
   126         }
       
   127     }
       
   128     
       
   129     template "datatype_instance" {
       
   130         apply {
       
   131             with "instance_path" > «@datatype_path»
       
   132         }
       
   133     }
       
   134     
       
   135 }