Better writing of some xpath added in previous commits about XSLT optimization.
authorEdouard Tisserant
Mon, 19 Feb 2018 15:15:36 +0100
changeset 1949 c266fbaae0f6
parent 1948 b9a3f771aaab
child 1950 752ec68da94d
Better writing of some xpath added in previous commits about XSLT optimization.
plcopen/instances_path.xslt
plcopen/instances_path.ysl2
plcopen/pou_variables.xslt
plcopen/pou_variables.ysl2
--- a/plcopen/instances_path.xslt	Mon Feb 19 15:14:30 2018 +0100
+++ b/plcopen/instances_path.xslt	Mon Feb 19 15:15:36 2018 +0100
@@ -6,7 +6,7 @@
   <xsl:variable name="project" select="ns:GetProject()"/>
   <xsl:variable name="stdlib" select="ns:GetStdLibs()"/>
   <xsl:variable name="extensions" select="ns:GetExtensions()"/>
-  <xsl:variable name="all" select="$project | $stdlib | $extensions"/>
+  <xsl:variable name="all_types" select="($project | $stdlib | $extensions)/ppx:types"/>
   <xsl:template match="ppx:project">
     <xsl:apply-templates select="ppx:instances/ppx:configurations/ppx:configuration"/>
   </xsl:template>
@@ -45,7 +45,7 @@
         <xsl:variable name="type_name">
           <xsl:value-of select="@typeName"/>
         </xsl:variable>
-        <xsl:apply-templates select="$all/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |                          $all/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
+        <xsl:apply-templates select="$all_types/ppx:pous/ppx:pou[@name=$type_name] |                          $all_types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
           <xsl:with-param name="instance_path">
             <xsl:value-of select="$pou_instance_path"/>
           </xsl:with-param>
@@ -92,7 +92,7 @@
         <xsl:variable name="type_name">
           <xsl:value-of select="@name"/>
         </xsl:variable>
-        <xsl:apply-templates select="$all/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |                          $all/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
+        <xsl:apply-templates select="$all_types/ppx:pous/ppx:pou[@name=$type_name] |                          $all_types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
           <xsl:with-param name="instance_path">
             <xsl:value-of select="$variable_path"/>
           </xsl:with-param>
--- a/plcopen/instances_path.ysl2	Mon Feb 19 15:14:30 2018 +0100
+++ b/plcopen/instances_path.ysl2	Mon Feb 19 15:15:36 2018 +0100
@@ -15,8 +15,7 @@
 
     variable "extensions", "ns:GetExtensions()";
 
-    variable "all", "$project | $stdlib | $extensions";
-    
+    variable "all_types", "($project | $stdlib | $extensions)/ppx:types";
 
     template "ppx:project" {
         apply "ppx:instances/ppx:configurations/ppx:configuration";
@@ -45,8 +44,8 @@
             }
             otherwise {
                 variable "type_name" > «@typeName»
-                apply """$all/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | \
-                         $all/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
+                apply """$all_types/ppx:pous/ppx:pou[@name=$type_name] | \
+                         $all_types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
                     with "instance_path" > «$pou_instance_path»
                 }
             }
@@ -83,8 +82,8 @@
             }
             otherwise {
                 variable "type_name" > «@name»
-                apply """$all/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | \
-                         $all/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
+                apply """$all_types/ppx:pous/ppx:pou[@name=$type_name] | \
+                         $all_types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" {
                     with "instance_path" > «$variable_path»
                 }
             }
--- a/plcopen/pou_variables.xslt	Mon Feb 19 15:14:30 2018 +0100
+++ b/plcopen/pou_variables.xslt	Mon Feb 19 15:15:36 2018 +0100
@@ -9,7 +9,7 @@
   <xsl:variable name="project" select="ns:GetProject()"/>
   <xsl:variable name="stdlib" select="ns:GetStdLibs()"/>
   <xsl:variable name="extensions" select="ns:GetExtensions()"/>
-  <xsl:variable name="all" select="$project | $stdlib | $extensions"/>
+  <xsl:variable name="all_types" select="($project | $stdlib | $extensions)/ppx:types"/>
   <xsl:template name="add_root">
     <xsl:param name="class"/>
     <xsl:param name="type"/>
@@ -205,7 +205,7 @@
   <xsl:template mode="var_class" match="*[self::ppx:type or self::ppx:baseType]/ppx:derived">
     <xsl:param name="default_class"/>
     <xsl:variable name="type_name" select="@name"/>
-    <xsl:variable name="pou_infos" select="$all/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"/>
+    <xsl:variable name="pou_infos" select="$all_types/ppx:pous/ppx:pou[@name=$type_name]"/>
     <xsl:choose>
       <xsl:when test="$pou_infos">
         <xsl:apply-templates mode="var_class" select="$pou_infos"/>
@@ -264,7 +264,7 @@
   </xsl:template>
   <xsl:template mode="var_debug" match="*[self::ppx:type or self::ppx:baseType]/ppx:derived">
     <xsl:variable name="type_name" select="@name"/>
-    <xsl:variable name="datatype_infos" select="             $project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |             $all/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]         "/>
+    <xsl:variable name="datatype_infos" select="             $project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |             $all_types/ppx:dataTypes/ppx:dataType[@name=$type_name]         "/>
     <xsl:choose>
       <xsl:when test="$datatype_infos">
         <xsl:apply-templates mode="var_debug" select="$datatype_infos"/>
--- a/plcopen/pou_variables.ysl2	Mon Feb 19 15:14:30 2018 +0100
+++ b/plcopen/pou_variables.ysl2	Mon Feb 19 15:15:36 2018 +0100
@@ -17,7 +17,7 @@
 
     variable "extensions", "ns:GetExtensions()";
 
-    variable "all", "$project | $stdlib | $extensions";
+    variable "all_types", "($project | $stdlib | $extensions)/ppx:types";
     
     function "add_root" {
         param "class";
@@ -173,7 +173,7 @@
     template "*[self::ppx:type or self::ppx:baseType]/ppx:derived", mode="var_class" {
         param "default_class";
         variable "type_name", "@name";
-        variable "pou_infos", "$all/ppx:types/ppx:pous/ppx:pou[@name=$type_name]";
+        variable "pou_infos", "$all_types/ppx:pous/ppx:pou[@name=$type_name]";
         choose {
             when "$pou_infos" {
                 apply "$pou_infos", mode="var_class";
@@ -239,7 +239,7 @@
         variable "type_name", "@name";
         variable "datatype_infos", """ \
             $project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | \
-            $all/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] \
+            $all_types/ppx:dataTypes/ppx:dataType[@name=$type_name] \
         """;
         choose {
             when "$datatype_infos" {