plcopen/instance_tagname.ysl2
branch1.1 Korean release
changeset 1384 02fe382c4511
parent 1351 a546a63ce1bf
child 1936 b85b13b1c2ec
equal deleted inserted replaced
1280:72a826dfcfbb 1384:02fe382c4511
       
     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="instance_tagname_ns" 
       
     5             extension-element-prefixes="ns" 
       
     6             exclude-result-prefixes="ns" {
       
     7     
       
     8     param "instance_path";
       
     9     
       
    10     variable "project" {
       
    11         copy "document('project')/project/*";
       
    12     }
       
    13     
       
    14     variable "stdlib" {
       
    15         copy "document('stdlib')/stdlib/*";
       
    16     }
       
    17     variable "extensions" {
       
    18         copy "document('extensions')/extensions/*";
       
    19     }
       
    20     
       
    21     function "element_name" {
       
    22         param "path";
       
    23         choose {
       
    24             when "contains($path,'.')" > «substring-before($path,'.')»
       
    25             otherwise > «$path»
       
    26         }
       
    27     }
       
    28     
       
    29     function "next_path" {
       
    30         param "path";
       
    31         choose {
       
    32             when "contains($path,'.')" > «substring-after($path,'.')»
       
    33         }
       
    34     }
       
    35     
       
    36     template "ppx:project" {
       
    37         variable "config_name" {
       
    38             call "element_name" {
       
    39                 with "path", "$instance_path";
       
    40             }
       
    41         }
       
    42         apply "ppx:instances/ppx:configurations/ppx:configuration[@name=$config_name]" {
       
    43             with "element_path" {
       
    44                 call "next_path" {
       
    45                     with "path", "$instance_path";
       
    46                 }
       
    47             }
       
    48         }
       
    49     }
       
    50     
       
    51     template "ppx:configuration" {
       
    52         param "element_path";
       
    53         choose {
       
    54             when "$element_path!=''" {
       
    55                 variable "child_name" {
       
    56                     call "element_name" {
       
    57                         with "path", "$element_path";
       
    58                     }
       
    59                 }
       
    60                 apply "ppx:resource[@name=$child_name] | ppx:globalVars/ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
       
    61                     with "element_path" {
       
    62                         call "next_path" {
       
    63                             with "path", "$element_path";
       
    64                         }
       
    65                     }
       
    66                 }
       
    67             }
       
    68             otherwise {
       
    69                 value "ns:ConfigTagName(@name)";
       
    70             }
       
    71         }
       
    72     }
       
    73     
       
    74     template "ppx:resource" {
       
    75         param "element_path";
       
    76         choose {
       
    77             when "$element_path!=''" {
       
    78                 variable "child_name" {
       
    79                     call "element_name" {
       
    80                         with "path" > «$element_path»
       
    81                     }
       
    82                 }
       
    83                 apply "ppx:pouInstance[@name=$child_name] | ppx:task/ppx:pouInstance[@name=$child_name] | ppx:globalVars/ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
       
    84                     with "element_path" {
       
    85                         call "next_path" {
       
    86                             with "path", "$element_path";
       
    87                         }
       
    88                     }
       
    89                 }
       
    90             }
       
    91             otherwise {
       
    92                 value "ns:ResourceTagName(ancestor::ppx:configuration/@name, @name)";
       
    93             }
       
    94         }
       
    95     }
       
    96     
       
    97     template "ppx:pouInstance" {
       
    98         param "element_path";
       
    99         variable "type_name" > «@typeName»
       
   100         apply """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
   101                  exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
       
   102                  exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
   103                  exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
       
   104                  exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
   105                  exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
       
   106             with "element_path", "$element_path";
       
   107         }
       
   108     }
       
   109     
       
   110     template "ppx:pou" {
       
   111         param "element_path";
       
   112         choose {
       
   113             when "$element_path!=''" {
       
   114                 variable "child_name" {
       
   115                     call "element_name" {
       
   116                         with "path", "$element_path";
       
   117                     }
       
   118                 }
       
   119                 apply "ppx:interface/*/ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
       
   120                     with "element_path" {
       
   121                         call "next_path" {
       
   122                             with "path", "$element_path";
       
   123                         }
       
   124                     }
       
   125                 }
       
   126                 apply "ppx:actions/ppx:action[@name=$child_name] | ppx:transitions/ppx:transition[@name=$child_name]";
       
   127             }
       
   128             otherwise {
       
   129                 variable "name" > «@name»
       
   130                 value "ns:PouTagName($name)";
       
   131             }
       
   132         }
       
   133     }
       
   134     
       
   135     template "ppx:action" {
       
   136         value "ns:ActionTagName(ancestor::ppx:pou/@name, @name)";
       
   137     }
       
   138     
       
   139     template "ppx:transition" {
       
   140         value "ns:TransitionTagName(ancestor::ppx:pou/@name, @name)";
       
   141     }
       
   142     
       
   143     template "ppx:dataType" {
       
   144         param "element_path";
       
   145         apply "ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
       
   146             with "element_path", "$element_path";
       
   147         }
       
   148     }
       
   149     
       
   150     template "ppx:derived" {
       
   151         param "element_path";
       
   152         variable "type_name" > «@name»
       
   153         apply """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
   154                  exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
       
   155                  exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
   156                  exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
       
   157                  exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
       
   158                  exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
       
   159             with "element_path", "$element_path";
       
   160         }
       
   161     }
       
   162     
       
   163     template "ppx:array" {
       
   164         param "element_path";
       
   165         apply "ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
       
   166             with "element_path", "$element_path";
       
   167         }
       
   168     }
       
   169     
       
   170     template "ppx:struct" {
       
   171         param "element_path";
       
   172         variable "child_name" {
       
   173             call "element_name" {
       
   174                 with "path", "$element_path";
       
   175             }
       
   176         }
       
   177         apply "ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
       
   178             with "element_path" {
       
   179                 call "next_path" {
       
   180                     with "path", "$element_path";
       
   181                 }
       
   182             }
       
   183         }
       
   184     }
       
   185     
       
   186 }