Laurent@1349: <?xml version="1.0"?>
Edouard@2637: <xsl:stylesheet xmlns:ns="beremiz" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:ppx="http://www.plcopen.org/xml/tc6_0201" xmlns:exsl="http://exslt.org/common" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="ns" extension-element-prefixes="ns">
Laurent@1349:   <xsl:output method="xml"/>
edouard@1936:   <xsl:template match="text()"/>
Laurent@1382:   <xsl:template match="ppx:pou[ppx:body]|ppx:transition[ppx:body]|ppx:action[ppx:body]">
edouard@1936:     <xsl:apply-templates select="ppx:body/*[self::ppx:FBD or self::ppx:LD or self::ppx:SFC]/*"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template name="add_instance">
Laurent@1349:     <xsl:param name="type"/>
Laurent@1349:     <xsl:value-of select="ns:AddBlockInstance($type, @localId, ppx:position/@x, ppx:position/@y, @width, @height)"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template name="execution_order">
Laurent@1349:     <xsl:choose>
Laurent@1349:       <xsl:when test="@executionOrderId">
Laurent@1349:         <xsl:value-of select="@executionOrderId"/>
Laurent@1349:       </xsl:when>
Laurent@1349:       <xsl:otherwise>
Laurent@1349:         <xsl:text>0</xsl:text>
Laurent@1349:       </xsl:otherwise>
Laurent@1349:     </xsl:choose>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template name="ConnectionInfos">
Laurent@1349:     <xsl:param name="type"/>
Laurent@1349:     <xsl:param name="negated"/>
Laurent@1349:     <xsl:param name="edge"/>
Laurent@1349:     <xsl:param name="formalParameter"/>
Laurent@1349:     <xsl:value-of select="ns:AddInstanceConnection($type, $formalParameter, $negated, $edge, ppx:relPosition/@x, ppx:relPosition/@y)"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:position">
Laurent@1349:     <xsl:value-of select="ns:AddLinkPoint(@x, @y)"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:connection">
Laurent@1349:     <xsl:value-of select="ns:AddConnectionLink(@refLocalId, @formalParameter)"/>
edouard@1936:     <xsl:apply-templates select="ppx:position"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:connectionPointIn">
Laurent@1349:     <xsl:param name="negated"/>
Laurent@1349:     <xsl:param name="edge"/>
Laurent@1349:     <xsl:param name="formalParameter"/>
Laurent@1349:     <xsl:call-template name="ConnectionInfos">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:text>input</xsl:text>
Laurent@1349:       </xsl:with-param>
Laurent@1349:       <xsl:with-param name="negated">
Laurent@1349:         <xsl:value-of select="$negated"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:       <xsl:with-param name="edge">
Laurent@1349:         <xsl:value-of select="$edge"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:       <xsl:with-param name="formalParameter">
Laurent@1349:         <xsl:value-of select="$formalParameter"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
edouard@1936:     <xsl:apply-templates select="ppx:connection"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:connectionPointOut">
Laurent@1349:     <xsl:param name="negated"/>
Laurent@1349:     <xsl:param name="edge"/>
Laurent@1349:     <xsl:param name="formalParameter"/>
Laurent@1349:     <xsl:call-template name="ConnectionInfos">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:text>output</xsl:text>
Laurent@1349:       </xsl:with-param>
Laurent@1349:       <xsl:with-param name="negated">
Laurent@1349:         <xsl:value-of select="$negated"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:       <xsl:with-param name="edge">
Laurent@1349:         <xsl:value-of select="$edge"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:       <xsl:with-param name="formalParameter">
Laurent@1349:         <xsl:value-of select="$formalParameter"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:connectionPointOutAction">
Laurent@1349:     <xsl:call-template name="ConnectionInfos">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:text>output</xsl:text>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:comment">
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues(ppx:content/xhtml:p/text())"/>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="local-name()"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:block">
Laurent@1349:     <xsl:variable name="execution_order">
Laurent@1349:       <xsl:call-template name="execution_order"/>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues(@instanceName, $execution_order)"/>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="@typeName"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
Laurent@1349:     <xsl:for-each select="ppx:inputVariables/ppx:variable">
Laurent@1349:       <xsl:apply-templates select="ppx:connectionPointIn">
Laurent@1349:         <xsl:with-param name="negated" select="@negated"/>
Laurent@1349:         <xsl:with-param name="edge" select="@edge"/>
Laurent@1349:         <xsl:with-param name="formalParameter" select="@formalParameter"/>
Laurent@1349:       </xsl:apply-templates>
Laurent@1349:     </xsl:for-each>
Laurent@1349:     <xsl:for-each select="ppx:outputVariables/ppx:variable">
Laurent@1349:       <xsl:apply-templates select="ppx:connectionPointOut">
Laurent@1349:         <xsl:with-param name="negated" select="@negated"/>
Laurent@1349:         <xsl:with-param name="edge" select="@edge"/>
Laurent@1349:         <xsl:with-param name="formalParameter" select="@formalParameter"/>
Laurent@1349:       </xsl:apply-templates>
Laurent@1349:     </xsl:for-each>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:derived">
Laurent@1349:     <xsl:value-of select="@name"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:string">
Laurent@1349:     <xsl:text>STRING</xsl:text>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/ppx:wstring">
Laurent@1349:     <xsl:text>WSTRING</xsl:text>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="*[self::ppx:type or self::ppx:baseType or self::ppx:returnType]/*">
Laurent@1349:     <xsl:value-of select="local-name()"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template name="VariableBlockInfos">
Laurent@1349:     <xsl:param name="type"/>
Laurent@1349:     <xsl:variable name="expression">
Laurent@1349:       <xsl:value-of select="ppx:expression/text()"/>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:variable name="value_type">
Laurent@1349:       <xsl:choose>
Laurent@1349:         <xsl:when test="ancestor::ppx:transition[@name=$expression]">
Laurent@1349:           <xsl:text>BOOL</xsl:text>
Laurent@1349:         </xsl:when>
Laurent@1349:         <xsl:when test="ancestor::ppx:pou[@name=$expression]">
edouard@1936:           <xsl:apply-templates select="ancestor::ppx:pou/child::ppx:interface/ppx:returnType"/>
edouard@1936:         </xsl:when>
edouard@1936:         <xsl:otherwise>
edouard@1936:           <xsl:apply-templates select="ancestor::ppx:pou/child::ppx:interface/*/ppx:variable[@name=$expression]/ppx:type"/>
Laurent@1349:         </xsl:otherwise>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:variable name="execution_order">
Laurent@1349:       <xsl:call-template name="execution_order"/>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues($expression, $value_type, $execution_order)"/>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="$type"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
Laurent@1349:     <xsl:apply-templates select="ppx:connectionPointIn">
Laurent@1349:       <xsl:with-param name="negated" select="@negatedIn"/>
Laurent@1349:       <xsl:with-param name="edge" select="@edgeIn"/>
Laurent@1349:     </xsl:apply-templates>
Laurent@1349:     <xsl:apply-templates select="ppx:connectionPointOut">
Laurent@1349:       <xsl:with-param name="negated" select="@negatedOut"/>
Laurent@1349:       <xsl:with-param name="edge" select="@edgeOut"/>
Laurent@1349:     </xsl:apply-templates>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:inVariable">
Laurent@1349:     <xsl:call-template name="VariableBlockInfos">
Laurent@1349:       <xsl:with-param name="type" select="'input'"/>
Laurent@1349:     </xsl:call-template>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:outVariable">
Laurent@1349:     <xsl:call-template name="VariableBlockInfos">
Laurent@1349:       <xsl:with-param name="type" select="'output'"/>
Laurent@1349:     </xsl:call-template>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:inOutVariable">
Laurent@1349:     <xsl:call-template name="VariableBlockInfos">
Laurent@1349:       <xsl:with-param name="type" select="'inout'"/>
Laurent@1349:     </xsl:call-template>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:connector|ppx:continuation">
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues(@name)"/>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="local-name()"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointIn"/>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointOut"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:leftPowerRail|ppx:rightPowerRail">
Laurent@1349:     <xsl:variable name="type" select="local-name()"/>
Laurent@1349:     <xsl:variable name="connectors">
Laurent@1349:       <xsl:choose>
Laurent@1349:         <xsl:when test="$type='leftPowerRail'">
Laurent@1349:           <xsl:value-of select="count(ppx:connectionPointOut)"/>
Laurent@1349:         </xsl:when>
Laurent@1349:         <xsl:otherwise>
Laurent@1349:           <xsl:value-of select="count(ppx:connectionPointIn)"/>
Laurent@1349:         </xsl:otherwise>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues($connectors)"/>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="$type"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
Laurent@1349:     <xsl:choose>
Laurent@1349:       <xsl:when test="$type='leftPowerRail'">
edouard@1936:         <xsl:apply-templates select="ppx:connectionPointOut"/>
Laurent@1349:       </xsl:when>
Laurent@1349:       <xsl:otherwise>
edouard@1936:         <xsl:apply-templates select="ppx:connectionPointIn"/>
Laurent@1349:       </xsl:otherwise>
Laurent@1349:     </xsl:choose>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:contact|ppx:coil">
Laurent@1349:     <xsl:variable name="type" select="local-name()"/>
Laurent@1349:     <xsl:variable name="storage">
Laurent@1349:       <xsl:choose>
Laurent@1349:         <xsl:when test="$type='coil'">
Laurent@1349:           <xsl:value-of select="@storage"/>
Laurent@1349:         </xsl:when>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:variable name="execution_order">
Laurent@1349:       <xsl:call-template name="execution_order"/>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues(ppx:variable/text(), @negated, @edge, $storage, $execution_order)"/>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="$type"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointIn"/>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointOut"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:step">
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues(@name, @initialStep)"/>
Laurent@1349:     <xsl:apply-templates select="ppx:connectionPointOutAction">
Laurent@1349:       <xsl:with-param name="negated" select="@negated"/>
Laurent@1349:     </xsl:apply-templates>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="local-name()"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointIn"/>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointOut"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:transition">
Laurent@1349:     <xsl:variable name="priority">
Laurent@1349:       <xsl:choose>
Laurent@1349:         <xsl:when test="@priority">
Laurent@1349:           <xsl:value-of select="@priority"/>
Laurent@1349:         </xsl:when>
Laurent@1349:         <xsl:otherwise>
Laurent@1349:           <xsl:text>0</xsl:text>
Laurent@1349:         </xsl:otherwise>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:variable name="condition_type">
Laurent@1349:       <xsl:choose>
Laurent@1349:         <xsl:when test="ppx:condition/ppx:connectionPointIn">
Laurent@1349:           <xsl:text>connection</xsl:text>
Laurent@1349:         </xsl:when>
Laurent@1349:         <xsl:when test="ppx:condition/ppx:reference">
Laurent@1349:           <xsl:text>reference</xsl:text>
Laurent@1349:         </xsl:when>
Laurent@1349:         <xsl:when test="ppx:condition/ppx:inline">
Laurent@1349:           <xsl:text>inline</xsl:text>
Laurent@1349:         </xsl:when>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:variable name="condition">
Laurent@1349:       <xsl:choose>
Laurent@1382:         <xsl:when test="ppx:condition/ppx:reference">
Laurent@1349:           <xsl:value-of select="ppx:condition/ppx:reference/@name"/>
Laurent@1349:         </xsl:when>
Laurent@1382:         <xsl:when test="ppx:condition/ppx:inline">
Laurent@1382:           <xsl:value-of select="ppx:condition/ppx:inline/ppx:ST/xhtml:p/text()"/>
Laurent@1349:         </xsl:when>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues($priority, $condition_type, $condition)"/>
Laurent@1349:     <xsl:apply-templates select="ppx:condition/ppx:connectionPointIn">
Laurent@1349:       <xsl:with-param name="negated" select="ppx:condition/@negated"/>
Laurent@1349:     </xsl:apply-templates>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="local-name()"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointIn"/>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointOut"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:selectionDivergence|ppx:selectionConvergence|ppx:simultaneousDivergence|ppx:simultaneousConvergence">
Laurent@1349:     <xsl:variable name="type">
Laurent@1349:       <xsl:value-of select="local-name()"/>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:variable name="connectors">
Laurent@1349:       <xsl:choose>
Laurent@1349:         <xsl:when test="$type='selectionDivergence' or $type='simultaneousDivergence'">
Laurent@1349:           <xsl:value-of select="count(ppx:connectionPointOut)"/>
Laurent@1349:         </xsl:when>
Laurent@1349:         <xsl:otherwise>
Laurent@1349:           <xsl:value-of select="count(ppx:connectionPointIn)"/>
Laurent@1349:         </xsl:otherwise>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues($connectors)"/>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="$type"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointIn"/>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointOut"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:jumpStep">
Laurent@1349:     <xsl:variable name="type">
Laurent@1349:       <xsl:text>jump</xsl:text>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues(@targetName)"/>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="$type"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
edouard@1936:     <xsl:apply-templates select="ppx:connectionPointIn"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:action">
Laurent@1349:     <xsl:variable name="type">
Laurent@1349:       <xsl:choose>
Laurent@1349:         <xsl:when test="ppx:reference">
Laurent@1349:           <xsl:text>reference</xsl:text>
Laurent@1349:         </xsl:when>
Laurent@1349:         <xsl:when test="ppx:inline">
Laurent@1349:           <xsl:text>inline</xsl:text>
Laurent@1349:         </xsl:when>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:variable name="value">
Laurent@1349:       <xsl:choose>
Laurent@1349:         <xsl:when test="ppx:reference">
Laurent@1349:           <xsl:value-of select="ppx:reference/@name"/>
Laurent@1349:         </xsl:when>
Laurent@1349:         <xsl:when test="ppx:inline">
Laurent@1349:           <xsl:value-of select="ppx:inline/ppx:ST/xhtml:p/text()"/>
Laurent@1349:         </xsl:when>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:variable name="qualifier">
Laurent@1349:       <xsl:choose>
Laurent@1349:         <xsl:when test="@qualifier">
Laurent@1349:           <xsl:value-of select="@qualifier"/>
Laurent@1349:         </xsl:when>
Laurent@1349:         <xsl:otherwise>
Laurent@1349:           <xsl:text>N</xsl:text>
Laurent@1349:         </xsl:otherwise>
Laurent@1349:       </xsl:choose>
Laurent@1349:     </xsl:variable>
Laurent@1349:     <xsl:value-of select="ns:AddAction($qualifier, $type, $value, @duration, @indicator)"/>
Laurent@1349:   </xsl:template>
Laurent@1349:   <xsl:template match="ppx:actionBlock">
Laurent@1349:     <xsl:value-of select="ns:SetSpecificValues()"/>
edouard@1936:     <xsl:apply-templates select="ppx:action"/>
Laurent@1349:     <xsl:call-template name="add_instance">
Laurent@1349:       <xsl:with-param name="type">
Laurent@1349:         <xsl:value-of select="local-name()"/>
Laurent@1349:       </xsl:with-param>
Laurent@1349:     </xsl:call-template>
Laurent@1349:     <xsl:apply-templates select="ppx:connectionPointIn">
Laurent@1349:       <xsl:with-param name="negated" select="@negated"/>
Laurent@1349:     </xsl:apply-templates>
Laurent@1349:   </xsl:template>
Laurent@1349: </xsl:stylesheet>