Fixed bugs with pou variable infos computation stylesheet
authorLaurent Bessard
Wed, 16 Oct 2013 23:54:44 +0200
changeset 1368 e567e4bee11f
parent 1367 324767a092dc
child 1369 9bd4c783c98d
Fixed bugs with pou variable infos computation stylesheet
PLCControler.py
plcopen/variables_infos.xslt
plcopen/variables_infos.ysl2
--- a/PLCControler.py	Wed Oct 16 11:36:22 2013 +0200
+++ b/PLCControler.py	Wed Oct 16 23:54:44 2013 +0200
@@ -270,7 +270,6 @@
         self.TagName = self.Controller.ComputeConfigurationResourceName(args[0][0], args[1][0])
 
     def PouTagName(self, context, *args):
-        #print "PouTagName", etree.tostring(args[0][0])
         self.TagName = self.Controller.ComputePouName(args[0][0])
 
     def ActionTagName(self, context, *args):
@@ -1323,8 +1322,7 @@
         factory = VariablesInfosFactory(variables)
         
         parser = etree.XMLParser()
-        if tree:
-            parser.resolvers.add(LibraryResolver(self, debug))
+        parser.resolvers.add(LibraryResolver(self, debug))
         
         variables_infos_xslt_tree = etree.XSLT(
             etree.parse(
--- a/plcopen/variables_infos.xslt	Wed Oct 16 11:36:22 2013 +0200
+++ b/plcopen/variables_infos.xslt	Wed Oct 16 23:54:44 2013 +0200
@@ -8,25 +8,13 @@
     <xsl:param name="_indent" select="0"/>
   </xsl:template>
   <xsl:variable name="project">
-    <xsl:choose>
-      <xsl:when test="$tree='True'">
-        <xsl:copy-of select="document('project')/project/*"/>
-      </xsl:when>
-    </xsl:choose>
+    <xsl:copy-of select="document('project')/project/*"/>
   </xsl:variable>
   <xsl:variable name="stdlib">
-    <xsl:choose>
-      <xsl:when test="$tree='True'">
-        <xsl:copy-of select="document('stdlib')/stdlib/*"/>
-      </xsl:when>
-    </xsl:choose>
+    <xsl:copy-of select="document('stdlib')/stdlib/*"/>
   </xsl:variable>
   <xsl:variable name="extensions">
-    <xsl:choose>
-      <xsl:when test="$tree='True'">
-        <xsl:copy-of select="document('extensions')/extensions/*"/>
-      </xsl:when>
-    </xsl:choose>
+    <xsl:copy-of select="document('extensions')/extensions/*"/>
   </xsl:variable>
   <xsl:template match="ppx:configuration">
     <xsl:param name="_indent" select="0"/>
@@ -161,7 +149,7 @@
     <xsl:variable name="name">
       <xsl:value-of select="@name"/>
     </xsl:variable>
-    <xsl:value-of select="ns:AddTree($name)"/>
+    <xsl:value-of select="ns:AddTree()"/>
     <xsl:apply-templates mode="var_type" select="ppx:type">
       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
     </xsl:apply-templates>
@@ -199,7 +187,13 @@
       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
     </xsl:apply-templates>
     <xsl:for-each select="ppx:dimension">
-      <xsl:value-of select="ns:AddDimension(@lower, @upper)"/>
+      <xsl:variable name="lower">
+        <xsl:value-of select="@lower"/>
+      </xsl:variable>
+      <xsl:variable name="upper">
+        <xsl:value-of select="@upper"/>
+      </xsl:variable>
+      <xsl:value-of select="ns:AddDimension($lower, $upper)"/>
     </xsl:for-each>
   </xsl:template>
   <xsl:template mode="var_type" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string">
@@ -225,7 +219,9 @@
   </xsl:template>
   <xsl:template mode="var_edit" match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived">
     <xsl:param name="_indent" select="0"/>
-    <xsl:variable name="type_name" select="@name"/>
+    <xsl:variable name="type_name">
+      <xsl:value-of select="@name"/>
+    </xsl:variable>
     <xsl:variable name="pou_infos">
       <xsl:copy-of select="exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                    exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                    exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"/>
     </xsl:variable>
--- a/plcopen/variables_infos.ysl2	Wed Oct 16 11:36:22 2013 +0200
+++ b/plcopen/variables_infos.ysl2	Wed Oct 16 23:54:44 2013 +0200
@@ -10,26 +10,14 @@
     template "text()";
     
     variable "project" {
-        choose {
-            when "$tree='True'" {
-                copy "document('project')/project/*";
-            }
-        }
+        copy "document('project')/project/*";
     }
     
     variable "stdlib" {
-        choose {
-            when "$tree='True'" {
-                copy "document('stdlib')/stdlib/*";
-            }
-        }
+        copy "document('stdlib')/stdlib/*";
     }
     variable "extensions" {
-        choose {
-            when "$tree='True'" {
-                copy "document('extensions')/extensions/*";
-            }
-        }
+        copy "document('extensions')/extensions/*";
     }
     
     template "ppx:configuration" {
@@ -124,7 +112,7 @@
     
     template "ppx:variable", mode="var_type" {
         variable "name" > «@name»
-        value "ns:AddTree($name)";
+        value "ns:AddTree()";
         apply "ppx:type", mode="var_type";
         value "ns:AddVarToTree($name)";
     }
@@ -155,7 +143,9 @@
     template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:array", mode="var_type" {
         apply "ppx:baseType", mode="var_type";
         foreach "ppx:dimension" {
-            value "ns:AddDimension(@lower, @upper)";
+            variable "lower" > «@lower»
+            variable "upper" > «@upper»
+            value "ns:AddDimension($lower, $upper)";
         }
     }
     
@@ -175,7 +165,7 @@
     }
     
     template "*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived", mode="var_edit" {
-        variable "type_name", "@name";
+        variable "type_name" > «@name»
         variable "pou_infos" {
             copy """exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |
                     exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |