Laurent@1351: <?xml version="1.0"?>
Laurent@1351: <xsl:stylesheet xmlns:func="http://exslt.org/functions" xmlns:dyn="http://exslt.org/dynamic" xmlns:str="http://exslt.org/strings" xmlns:math="http://exslt.org/math" xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:yml="http://fdik.org/yml" xmlns:set="http://exslt.org/sets" xmlns:ppx="http://www.plcopen.org/xml/tc6_0201" xmlns:ns="instance_tagname_ns" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" extension-element-prefixes="ns" version="1.0" exclude-result-prefixes="ns">
Laurent@1351:   <xsl:output method="xml"/>
Laurent@1351:   <xsl:variable name="space" select="'                                                                                                                                                                                                        '"/>
Laurent@1351:   <xsl:param name="autoindent" select="4"/>
Laurent@1321:   <xsl:param name="instance_path"/>
Laurent@1351:   <xsl:variable name="project">
Laurent@1351:     <xsl:copy-of select="document('project')/project/*"/>
Laurent@1351:   </xsl:variable>
Laurent@1351:   <xsl:variable name="stdlib">
Laurent@1351:     <xsl:copy-of select="document('stdlib')/stdlib/*"/>
Laurent@1351:   </xsl:variable>
Laurent@1351:   <xsl:variable name="extensions">
Laurent@1351:     <xsl:copy-of select="document('extensions')/extensions/*"/>
Laurent@1351:   </xsl:variable>
Laurent@1321:   <xsl:template name="element_name">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1321:     <xsl:param name="path"/>
Laurent@1321:     <xsl:choose>
Laurent@1321:       <xsl:when test="contains($path,'.')">
Laurent@1321:         <xsl:value-of select="substring-before($path,'.')"/>
Laurent@1321:       </xsl:when>
Laurent@1321:       <xsl:otherwise>
Laurent@1321:         <xsl:value-of select="$path"/>
Laurent@1321:       </xsl:otherwise>
Laurent@1321:     </xsl:choose>
Laurent@1321:   </xsl:template>
Laurent@1321:   <xsl:template name="next_path">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1321:     <xsl:param name="path"/>
Laurent@1321:     <xsl:choose>
Laurent@1321:       <xsl:when test="contains($path,'.')">
Laurent@1321:         <xsl:value-of select="substring-after($path,'.')"/>
Laurent@1321:       </xsl:when>
Laurent@1321:     </xsl:choose>
Laurent@1321:   </xsl:template>
Laurent@1321:   <xsl:template match="ppx:project">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1321:     <xsl:variable name="config_name">
Laurent@1321:       <xsl:call-template name="element_name">
Laurent@1321:         <xsl:with-param name="path" select="$instance_path"/>
Laurent@1321:       </xsl:call-template>
Laurent@1321:     </xsl:variable>
Laurent@1321:     <xsl:apply-templates select="ppx:instances/ppx:configurations/ppx:configuration[@name=$config_name]">
Laurent@1351:       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1321:       <xsl:with-param name="element_path">
Laurent@1321:         <xsl:call-template name="next_path">
Laurent@1321:           <xsl:with-param name="path" select="$instance_path"/>
Laurent@1321:         </xsl:call-template>
Laurent@1321:       </xsl:with-param>
Laurent@1321:     </xsl:apply-templates>
Laurent@1321:   </xsl:template>
Laurent@1321:   <xsl:template match="ppx:configuration">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1321:     <xsl:param name="element_path"/>
Laurent@1321:     <xsl:choose>
Laurent@1321:       <xsl:when test="$element_path!=''">
Laurent@1321:         <xsl:variable name="child_name">
Laurent@1351:           <xsl:call-template name="element_name">
Laurent@1351:             <xsl:with-param name="path" select="$element_path"/>
Laurent@1351:           </xsl:call-template>
Laurent@1351:         </xsl:variable>
Laurent@1321:         <xsl:apply-templates select="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:           <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1321:           <xsl:with-param name="element_path">
Laurent@1321:             <xsl:call-template name="next_path">
Laurent@1321:               <xsl:with-param name="path" select="$element_path"/>
Laurent@1321:             </xsl:call-template>
Laurent@1321:           </xsl:with-param>
Laurent@1321:         </xsl:apply-templates>
Laurent@1321:       </xsl:when>
Laurent@1321:       <xsl:otherwise>
Laurent@1351:         <xsl:value-of select="ns:ConfigTagName(@name)"/>
Laurent@1351:       </xsl:otherwise>
Laurent@1351:     </xsl:choose>
Laurent@1351:   </xsl:template>
Laurent@1351:   <xsl:template match="ppx:resource">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1351:     <xsl:param name="element_path"/>
Laurent@1351:     <xsl:choose>
Laurent@1351:       <xsl:when test="$element_path!=''">
Laurent@1351:         <xsl:variable name="child_name">
Laurent@1351:           <xsl:call-template name="element_name">
Laurent@1351:             <xsl:with-param name="path">
Laurent@1351:               <xsl:value-of select="$element_path"/>
Laurent@1351:             </xsl:with-param>
Laurent@1351:           </xsl:call-template>
Laurent@1351:         </xsl:variable>
Laurent@1351:         <xsl:apply-templates select="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:           <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1351:           <xsl:with-param name="element_path">
Laurent@1351:             <xsl:call-template name="next_path">
Laurent@1351:               <xsl:with-param name="path" select="$element_path"/>
Laurent@1351:             </xsl:call-template>
Laurent@1351:           </xsl:with-param>
Laurent@1351:         </xsl:apply-templates>
Laurent@1351:       </xsl:when>
Laurent@1351:       <xsl:otherwise>
Laurent@1351:         <xsl:value-of select="ns:ResourceTagName(ancestor::ppx:configuration/@name, @name)"/>
Laurent@1321:       </xsl:otherwise>
Laurent@1321:     </xsl:choose>
Laurent@1321:   </xsl:template>
Laurent@1321:   <xsl:template match="ppx:pouInstance">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1321:     <xsl:param name="element_path"/>
Laurent@1351:     <xsl:variable name="type_name">
Laurent@1351:       <xsl:value-of select="@typeName"/>
Laurent@1351:     </xsl:variable>
Laurent@1351:     <xsl:apply-templates select="exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                 exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |&#10;                 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |&#10;                 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
Laurent@1351:       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1351:       <xsl:with-param name="element_path" select="$element_path"/>
Laurent@1351:     </xsl:apply-templates>
Laurent@1321:   </xsl:template>
Laurent@1321:   <xsl:template match="ppx:pou">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1351:     <xsl:param name="element_path"/>
Laurent@1351:     <xsl:choose>
Laurent@1351:       <xsl:when test="$element_path!=''">
Laurent@1351:         <xsl:variable name="child_name">
Laurent@1351:           <xsl:call-template name="element_name">
Laurent@1351:             <xsl:with-param name="path" select="$element_path"/>
Laurent@1351:           </xsl:call-template>
Laurent@1351:         </xsl:variable>
Laurent@1351:         <xsl:apply-templates select="ppx:interface/*/ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
Laurent@1351:           <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1351:           <xsl:with-param name="element_path">
Laurent@1351:             <xsl:call-template name="next_path">
Laurent@1351:               <xsl:with-param name="path" select="$element_path"/>
Laurent@1351:             </xsl:call-template>
Laurent@1351:           </xsl:with-param>
Laurent@1351:         </xsl:apply-templates>
Laurent@1351:         <xsl:apply-templates select="ppx:actions/ppx:action[@name=$child_name] | ppx:transitions/ppx:transition[@name=$child_name]">
Laurent@1351:           <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1351:         </xsl:apply-templates>
Laurent@1351:       </xsl:when>
Laurent@1351:       <xsl:otherwise>
Laurent@1351:         <xsl:variable name="name">
Laurent@1351:           <xsl:value-of select="@name"/>
Laurent@1351:         </xsl:variable>
Laurent@1351:         <xsl:value-of select="ns:PouTagName($name)"/>
Laurent@1351:       </xsl:otherwise>
Laurent@1351:     </xsl:choose>
Laurent@1351:   </xsl:template>
Laurent@1351:   <xsl:template match="ppx:action">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1351:     <xsl:value-of select="ns:ActionTagName(ancestor::ppx:pou/@name, @name)"/>
Laurent@1351:   </xsl:template>
Laurent@1351:   <xsl:template match="ppx:transition">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1351:     <xsl:value-of select="ns:TransitionTagName(ancestor::ppx:pou/@name, @name)"/>
Laurent@1351:   </xsl:template>
Laurent@1351:   <xsl:template match="ppx:dataType">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1351:     <xsl:param name="element_path"/>
Laurent@1351:     <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
Laurent@1351:       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1351:       <xsl:with-param name="element_path" select="$element_path"/>
Laurent@1351:     </xsl:apply-templates>
Laurent@1351:   </xsl:template>
Laurent@1351:   <xsl:template match="ppx:derived">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1351:     <xsl:param name="element_path"/>
Laurent@1351:     <xsl:variable name="type_name">
Laurent@1351:       <xsl:value-of select="@name"/>
Laurent@1351:     </xsl:variable>
Laurent@1351:     <xsl:apply-templates select="exsl:node-set($project)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                 exsl:node-set($project)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |&#10;                 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                 exsl:node-set($stdlib)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] |&#10;                 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] |&#10;                 exsl:node-set($extensions)/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
Laurent@1351:       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1351:       <xsl:with-param name="element_path" select="$element_path"/>
Laurent@1351:     </xsl:apply-templates>
Laurent@1351:   </xsl:template>
Laurent@1351:   <xsl:template match="ppx:array">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1351:     <xsl:param name="element_path"/>
Laurent@1351:     <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
Laurent@1351:       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1351:       <xsl:with-param name="element_path" select="$element_path"/>
Laurent@1351:     </xsl:apply-templates>
Laurent@1351:   </xsl:template>
Laurent@1351:   <xsl:template match="ppx:struct">
Laurent@1351:     <xsl:param name="_indent" select="0"/>
Laurent@1321:     <xsl:param name="element_path"/>
Laurent@1321:     <xsl:variable name="child_name">
Laurent@1321:       <xsl:call-template name="element_name">
Laurent@1321:         <xsl:with-param name="path" select="$element_path"/>
Laurent@1321:       </xsl:call-template>
Laurent@1321:     </xsl:variable>
Laurent@1351:     <xsl:apply-templates select="ppx:variable[@name=$child_name]/ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
Laurent@1351:       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
Laurent@1326:       <xsl:with-param name="element_path">
Laurent@1326:         <xsl:call-template name="next_path">
Laurent@1326:           <xsl:with-param name="path" select="$element_path"/>
Laurent@1326:         </xsl:call-template>
Laurent@1326:       </xsl:with-param>
Laurent@1326:     </xsl:apply-templates>
Laurent@1321:   </xsl:template>
Laurent@1351: </xsl:stylesheet>