Laurent@1351: include yslt.yml2
Laurent@1351: estylesheet xmlns:ppx="http://www.plcopen.org/xml/tc6_0201"
Laurent@1351:             xmlns:xhtml="http://www.w3.org/1999/xhtml"
Laurent@1351:             xmlns:ns="instance_tagname_ns" 
Laurent@1351:             extension-element-prefixes="ns" 
Laurent@1351:             exclude-result-prefixes="ns" {
Laurent@1351:     
Laurent@1351:     param "instance_path";
Laurent@1351:     
Laurent@1351:     variable "project" {
Laurent@1351:         copy "document('project')/project/*";
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     variable "stdlib" {
Laurent@1351:         copy "document('stdlib')/stdlib/*";
Laurent@1351:     }
Laurent@1351:     variable "extensions" {
Laurent@1351:         copy "document('extensions')/extensions/*";
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     function "element_name" {
Laurent@1351:         param "path";
Laurent@1351:         choose {
Laurent@1351:             when "contains($path,'.')" > «substring-before($path,'.')»
Laurent@1351:             otherwise > «$path»
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     function "next_path" {
Laurent@1351:         param "path";
Laurent@1351:         choose {
Laurent@1351:             when "contains($path,'.')" > «substring-after($path,'.')»
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:project" {
Laurent@1351:         variable "config_name" {
Laurent@1351:             call "element_name" {
Laurent@1351:                 with "path", "$instance_path";
Laurent@1351:             }
Laurent@1351:         }
Laurent@1351:         apply "ppx:instances/ppx:configurations/ppx:configuration[@name=$config_name]" {
Laurent@1351:             with "element_path" {
Laurent@1351:                 call "next_path" {
Laurent@1351:                     with "path", "$instance_path";
Laurent@1351:                 }
Laurent@1351:             }
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:configuration" {
Laurent@1351:         param "element_path";
Laurent@1351:         choose {
Laurent@1351:             when "$element_path!=''" {
Laurent@1351:                 variable "child_name" {
Laurent@1351:                     call "element_name" {
Laurent@1351:                         with "path", "$element_path";
Laurent@1351:                     }
Laurent@1351:                 }
Laurent@1351:                 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]" {
Laurent@1351:                     with "element_path" {
Laurent@1351:                         call "next_path" {
Laurent@1351:                             with "path", "$element_path";
Laurent@1351:                         }
Laurent@1351:                     }
Laurent@1351:                 }
Laurent@1351:             }
Laurent@1351:             otherwise {
Laurent@1351:                 value "ns:ConfigTagName(@name)";
Laurent@1351:             }
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:resource" {
Laurent@1351:         param "element_path";
Laurent@1351:         choose {
Laurent@1351:             when "$element_path!=''" {
Laurent@1351:                 variable "child_name" {
Laurent@1351:                     call "element_name" {
Laurent@1351:                         with "path" > «$element_path»
Laurent@1351:                     }
Laurent@1351:                 }
Laurent@1351:                 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]" {
Laurent@1351:                     with "element_path" {
Laurent@1351:                         call "next_path" {
Laurent@1351:                             with "path", "$element_path";
Laurent@1351:                         }
Laurent@1351:                     }
Laurent@1351:                 }
Laurent@1351:             }
Laurent@1351:             otherwise {
Laurent@1351:                 value "ns:ResourceTagName(ancestor::ppx:configuration/@name, @name)";
Laurent@1351:             }
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:pouInstance" {
Laurent@1351:         param "element_path";
Laurent@1351:         variable "type_name" > «@typeName»
Laurent@1351:         apply """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
Laurent@1351:                  exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
Laurent@1351:                  exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
Laurent@1351:                  exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
Laurent@1351:                  exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
Laurent@1351:                  exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
Laurent@1351:             with "element_path", "$element_path";
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:pou" {
Laurent@1351:         param "element_path";
Laurent@1351:         choose {
Laurent@1351:             when "$element_path!=''" {
Laurent@1351:                 variable "child_name" {
Laurent@1351:                     call "element_name" {
Laurent@1351:                         with "path", "$element_path";
Laurent@1351:                     }
Laurent@1351:                 }
Laurent@1351:                 apply "ppx:interface/*/ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
Laurent@1351:                     with "element_path" {
Laurent@1351:                         call "next_path" {
Laurent@1351:                             with "path", "$element_path";
Laurent@1351:                         }
Laurent@1351:                     }
Laurent@1351:                 }
Laurent@1351:                 apply "ppx:actions/ppx:action[@name=$child_name] | ppx:transitions/ppx:transition[@name=$child_name]";
Laurent@1351:             }
Laurent@1351:             otherwise {
Laurent@1351:                 variable "name" > «@name»
Laurent@1351:                 value "ns:PouTagName($name)";
Laurent@1351:             }
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:action" {
Laurent@1351:         value "ns:ActionTagName(ancestor::ppx:pou/@name, @name)";
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:transition" {
Laurent@1351:         value "ns:TransitionTagName(ancestor::ppx:pou/@name, @name)";
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:dataType" {
Laurent@1351:         param "element_path";
Laurent@1351:         apply "ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
Laurent@1351:             with "element_path", "$element_path";
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:derived" {
Laurent@1351:         param "element_path";
Laurent@1351:         variable "type_name" > «@name»
Laurent@1351:         apply """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
Laurent@1351:                  exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
Laurent@1351:                  exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
Laurent@1351:                  exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |
Laurent@1351:                  exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
Laurent@1351:                  exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
Laurent@1351:             with "element_path", "$element_path";
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:array" {
Laurent@1351:         param "element_path";
Laurent@1351:         apply "ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
Laurent@1351:             with "element_path", "$element_path";
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351:     template "ppx:struct" {
Laurent@1351:         param "element_path";
Laurent@1351:         variable "child_name" {
Laurent@1351:             call "element_name" {
Laurent@1351:                 with "path", "$element_path";
Laurent@1351:             }
Laurent@1351:         }
Laurent@1351:         apply "ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
Laurent@1351:             with "element_path" {
Laurent@1351:                 call "next_path" {
Laurent@1351:                     with "path", "$element_path";
Laurent@1351:                 }
Laurent@1351:             }
Laurent@1351:         }
Laurent@1351:     }
Laurent@1351:     
Laurent@1351: }