a.binder 9 лет назад
Родитель
Сommit
92ddb6170a

+ 162 - 32
SE/schema/default_db_xml_cache.public/build_recurse_ant.xsl

@@ -14,6 +14,9 @@
     <xsl:strip-space elements="*"/>
     
     
+    <!-- Copyright BIALL-NET sp. z o.o. 2017-03-01 wszelkie prawa zastrzeżone -->
+    <!-- @2017-03-01 modyfikacja dla potrzeb CRM_PROCES_tree - sa bledy-->
+    
     <xsl:include href="escaped_html_to_xml.xsl"/>
     <!--
     <property name="url" value="${url}"/> - to point what is record/table to download
@@ -45,6 +48,8 @@
     
     <xsl:param name="xml_id_parent" select="@xml_id"/>
     <xsl:param name="build_recurse_ant.xsl" required="yes"/>
+    <xsl:param name="temp" select="'temp'"/>
+    <xsl:param name="builds_to_ant.xsl" required="yes"/>
     <!-- second step fist loop - with data -->
     <!--<xsl:param name="wfs_output.xml"/>--> <!-- to be set in second step by ant build generated by this style to fill by its data childs -->
     
@@ -55,12 +60,14 @@
         <xsl:param name="loop_xpath" select="$loop_xpath"/>
         <xsl:param name="loop_xpath_save" select="$loop_xpath_save"/><!-- tutaj zapisal sie build z wezla z parent -->
         <xsl:param name="input_obj_with_xpath" /> <!-- przekazany z template  match="RelatedFeature" mode="after_first_ant_assing_vars_childs" -->
+        <xsl:param name="feature_pos"  select="1"/> <!-- przekazany z  template  match="RelatedFeature" mode="after_first_ant_assing_vars_childs"-->
         <xsl:choose>
             <xsl:when test="name()='RelatedFeature'">
                 <xsl:variable name="RelatedFeatureCount" select="last()"/>
                 <xsl:variable name="RelatedFeaturePos" select="position()"/>
                 <xsl:variable name="featureID_name" select="substring-after($typeName,':')"/>
                 <xsl:message>#58 bylo $loop_xpath=<xsl:value-of select="$loop_xpath"/>; $basedir=<xsl:value-of select="$basedir"/>; </xsl:message>
+                <xsl:variable name="loop_xpath_real" select="$loop_xpath"/>
                 <xsl:variable name="loop_xpath">
                     <xsl:choose>
                         <xsl:when test="$loop_xpath='root'">
@@ -75,9 +82,8 @@
                 <!--<xsl:variable name="wfs_output" select="concat($uuid,'.',$loop_xpath,'_x2f_',$featureID_name)"/>-->
                 <xsl:variable name="wfs_output" select="concat($uuid,'.',$loop_xpath)"/>
                 <!--<xsl:variable name="wfs_output.xml" select="concat($wfs_output,'.',position(),'.xml')"/>-->
-                <xsl:variable name="wfs_output.xml" select="concat($wfs_output,'.',position(),'.xml')"/>
-                
-                <xsl:variable name="wfs_output.dita" select="concat($wfs_output,'.',position(),'.dita.xml')"/>
+                <xsl:variable name="wfs_output.xml" select="concat($wfs_output,'.',position(),'.',$feature_pos,'.xml')"/>
+                <xsl:variable name="wfs_output.dita" select="concat($wfs_output,'.',position(),'.',$feature_pos,'.dita.xml')"/>
                 <!--<xsl:variable name="wfs_output.dita" select="concat($wfs_output,'.',position(),'.','.dita.xml')"/>-->
                 <!-- dane z oczekiwanego template .dita -->
                 <xsl:variable name="xpath_dita" select="@xpath"/>
@@ -106,9 +112,10 @@
                         </xsl:otherwise>
                     </xsl:choose>
                 </xsl:variable>
-                <xsl:message>#71 wstawiam projekt $loop_xpath=<xsl:value-of select="$loop_xpath"/>; </xsl:message>
-                <project basedir="../." name="get_related_feature" default="get_related_feature_run_child_ant">
+                <xsl:message>#71 wstawiam projekt $feature_pos=<xsl:value-of select="$feature_pos"/>; $loop_xpath=<xsl:value-of select="$loop_xpath"/>; </xsl:message>
+                <project basedir="../." name="get_related_feature{$loop_xpath_real}" default="get_related_feature_run_child_ant{$loop_xpath_real}">
                     <xsl:comment>RelatedFeatureCount:<xsl:value-of select="count(*)"/></xsl:comment>
+                    <echo> ANT Uruchamiam $feature_pos=<xsl:value-of select="$feature_pos"/>; projekt <xsl:value-of select="$loop_xpath_real"/>; </echo>
                     <!--<xsl:variable name="typeName" select='replace($typeName,"&quot;","")'/>--><!-- oczyszczenie z apostrofow -->
                     <xsl:element name="property">
                         <xsl:attribute name="name" select="'uuid'"/>
@@ -126,6 +133,18 @@
                         <xsl:attribute name="name" select="'webRootUrl'"/>
                         <xsl:attribute name="value" select="$webRootUrl"/>
                     </xsl:element>
+                    <xsl:element name="property">
+                        <xsl:attribute name="name" select="'build_recurse_ant.xsl'"/>
+                        <xsl:attribute name="value" select="$build_recurse_ant.xsl"/>
+                    </xsl:element>
+                    <xsl:element name="property">
+                        <xsl:attribute name="name" select="'temp'"/>
+                        <xsl:attribute name="value" select="$temp"/>
+                    </xsl:element>
+                    <xsl:element name="property">
+                        <xsl:attribute name="name" select="'builds_to_ant.xsl'"/>
+                        <xsl:attribute name="value" select="$builds_to_ant.xsl"/>
+                    </xsl:element>
                     <xsl:comment>
                         Important variables:
                         typeName=<xsl:value-of select="$typeName"/>;
@@ -133,8 +152,7 @@
                         xpath_value=<xsl:value-of select="$xpath_value"/>;
                         $passwordBase64Basic=<xsl:value-of select="$passwordBase64Basic"/>
                     </xsl:comment>
-                    
-                    
+
                     <xsl:apply-templates mode="ant_target" select=".">
                         <xsl:with-param name="typeName_dita" select="$typeName_dita"/>
                         <xsl:with-param name="featureID_name_dita" select="$featureID_name_dita"/>
@@ -150,9 +168,11 @@
                         <xsl:with-param name="typeName" select="$typeName"/>
                         <xsl:with-param name="xpath_value" select="$xpath_value"/>
                         <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
+                        <xsl:with-param name="loop_xpath_real" select="$loop_xpath_real"/>
                         <!--<xsl:with-param name="loop_xpath_save" select="$loop_xpath_save"/>-->
                         <xsl:with-param name="xml_id" select="$xml_id"/>
                         <!--<xsl:with-param name="xml_id_parent" select="$xml_id_parent"/>-->
+                        <xsl:with-param name="feature_pos"   select="$feature_pos"/>
                     </xsl:apply-templates>
                     <!-- na koniec przetwarzania kazdego z wezlow, podmieniamy xsl biezacy wezel -->
                     
@@ -164,20 +184,20 @@
                     <xsl:variable name="loop_xpath_child" select="concat($loop_xpath,'_x2f_.',$xml_id,'.',$featureID_name)"/>
                     <xsl:message>#142 ustalamy $loop_xpath_child=<xsl:value-of select="$loop_xpath_child"/></xsl:message>
                     <xsl:element name="target">
-                        <xsl:attribute name="name" select="'get_related_feature_run_child_ant'"/>
-                        <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos)"/>
-                    <xsl:choose>
+                        <xsl:attribute name="name" select="concat('get_related_feature_run_child_ant',$loop_xpath_real)"/>
+                        <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos,$loop_xpath_real)"/>
+                    <!--<xsl:choose>
                         <xsl:when test=".//(RelatedFeature|RelatedFeatureRoot)">
-                            <xsl:for-each select=".//RelatedFeature">
+                            <xsl:for-each select=".//RelatedFeature[ not(child::node()/name()='RelatedFeature')]">
                                 <xsl:variable name="loop_xpath_child_ant" select="concat($loop_xpath_save,'_x2f_.',@xml_id,'.',$featureID_name)"/>
                                 <xsl:message>#148 ustalamy $loop_xpath_child_ant=<xsl:value-of select="$loop_xpath_child_ant"/></xsl:message>
-                               <!-- <xsl:element name="target">
-                                    <xsl:attribute name="name" select="$loop_xpath_child_ant"/><!-\-'get_related_feature_run_child_ant'-\->
-                                    <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos)"/>-->
-                                <!--<ant antfile="temp/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.xml" dir="."/>-->
-                                <ant antfile="temp/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.xml" dir="."/>
+                               <!-\- <xsl:element name="target">
+                                    <xsl:attribute name="name" select="$loop_xpath_child_ant"/><!-\\-'get_related_feature_run_child_ant'-\\->
+                                    <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos)"/>-\->
+                                <!-\-<ant antfile="temp/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.xml" dir="."/>-\->
+                                <ant antfile="temp/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.1.xml" dir="."/>
                                 
-                                <!--</xsl:element>-->
+                                <!-\-</xsl:element>-\->
                                 <xsl:if test=" position()=last()">
                                     <xsl:comment>Tu task z related</xsl:comment>
                                 </xsl:if>
@@ -185,19 +205,24 @@
                         </xsl:when>
                         <xsl:otherwise>
                             <xsl:comment>#135 nie ma wiecej //RelatedFeature</xsl:comment>
-                            <!--<xsl:element name="target">
+                            <!-\-<xsl:element name="target">
                                 <xsl:attribute name="name" select="'get_related_feature_run_child_ant'"/>
                                 <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos)"/>
-                            </xsl:element>-->
+                            </xsl:element>-\->
                         </xsl:otherwise>
-                    </xsl:choose>
+                    </xsl:choose>-->
+                        <!-- wstawienie subanta dla biezacych dzieci only -->
+                        <xsl:apply-templates mode="place_subant">
+                            <xsl:with-param name="uuid" select="$uuid"/>
+                            <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
+                            <xsl:with-param name="loop_xpath_real" select="$loop_xpath_real"/>
+                        </xsl:apply-templates>
                     </xsl:element>
                     <!-- na koniec przetwarzania danego zaglebienia uruchamiamy calosc ponownie do kolejnego zaglebienia -->
                     
                     <!-- task do polaczenia zaglebien -->
                     
                     <!-- jak nie ma zaglebien to generujemy pdf i dajemy uzytkownikowi linka  -->
-                    
                 </project>
             </xsl:when>
             <xsl:otherwise>
@@ -207,6 +232,81 @@
     </xsl:template>
     
     
+    
+    <xsl:template mode="place_subant" match="RelatedFeature">
+        <xsl:param name="uuid" required="yes"/>
+        <xsl:param name="loop_xpath" required="yes"/>
+        <xsl:param name="loop_xpath_real" required="yes"/>
+        <!-- wygenerujemy liste ant -->
+        
+        <echo> #235 ant szukam fileset id=builds_to_ant w <xsl:value-of select="concat($uuid,'.build_',$loop_xpath,'_x2f_.',@xml_id,'.',substring-after(@typeName,':'),'.*.xml')"/> </echo>
+        <fileset id="builds_to_ant{$loop_xpath_real}" dir="temp" includes="{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.*.xml" />
+        
+        <property name="builds_to_ant{$loop_xpath_real}" refid="builds_to_ant{$loop_xpath_real}"/>
+        <!--<tempfile property="builds_to_ant.xml" deleteonexit="no" destdir="temp" suffix=".xml" prefix="${uuid}.builds_to_ant-"/>-->
+        <xsl:element name="tempfile">
+            <xsl:attribute name="property" select="concat('builds_to_ant.xml',$loop_xpath_real)"/>
+            <xsl:attribute name="deleteonexit" select="'no'"/>
+            <xsl:attribute name="destdir" select="'temp'"/>
+            <xsl:attribute name="suffix" select="'.xml'"/>
+            <xsl:attribute name="prefix" select="'${uuid}.builds_to_ant-'"/>
+        </xsl:element>
+        <!--<tempfile property="builds_to_ant_file.xml" deleteonexit="no" destdir="temp" suffix=".xml" prefix="${uuid}.build_to_ant_file-"/>-->
+        <xsl:element name="tempfile">
+            <xsl:attribute name="property" select="concat('builds_to_ant_file.xml',$loop_xpath_real)"/>
+            <xsl:attribute name="deleteonexit" select="'no'"/>
+            <xsl:attribute name="destdir" select="'temp'"/>
+            <xsl:attribute name="suffix" select="'.xml'"/>
+            <xsl:attribute name="prefix" select="'${uuid}.build_to_ant_file-'"/>
+        </xsl:element>
+        <echo>#235 ant do: builds_to_ant.xml=${builds_to_ant_file.xml} mode="place_subant" match="RelatedFeature" </echo>
+        <!--<echoxml file="'${builds_to_ant.xml}'"><builds_to_ant>${builds_to_ant}</builds_to_ant></echoxml>-->
+        <xsl:element name="echoxml">
+            <xsl:attribute name="file" select="concat('${builds_to_ant.xml',$loop_xpath_real,'}')"/>
+            <builds_to_ant>${builds_to_ant<xsl:value-of select="$loop_xpath_real"/>}</builds_to_ant>
+        </xsl:element>
+        <xsl:element name="xslt">
+            <xsl:attribute name="basedir" select="'./'"/>
+            <xsl:attribute name="style" select="$builds_to_ant.xsl"/>
+            <xsl:attribute name="in" select="concat('${builds_to_ant.xml',$loop_xpath_real,'}')"/>
+            <xsl:attribute name="destdir" select="'./'"/>
+            <xsl:attribute name="out" select="concat('${builds_to_ant_file.xml',$loop_xpath_real,'}')"/>
+            <factory name="net.sf.saxon.TransformerFactoryImpl">
+                <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
+                <!--<attribute name="http://saxon.sf.net/feature/initialMode"
+               value="after_first_ant_assing_vars"/>-->
+            </factory>
+            
+            <param name="temp" expression="{$temp}"/>
+            <param name="loop_xpath_real" expression="{$loop_xpath_real}"/>
+            <!--<xsl:element name="param">
+                <xsl:attribute name="name" select="'default_antfile'"/>
+                <xsl:attribute name="expression" select="concat($temp,'/',$builds_to_ant_file.xml"/>
+            </xsl:element>-->
+            <param name="default_antfile" expression="{$temp}/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.1.xml"/>
+            <classpath location="/opt/local/share/java/saxon9he.jar"/>
+        </xsl:element>
+        
+        <!--<ant antfile="{$temp}/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.1.xml" dir="."/>-->
+        
+        <xsl:element name="ant">
+            <xsl:attribute name="antfile" select="concat('${builds_to_ant_file.xml',$loop_xpath_real,'}')"/>
+        </xsl:element>
+        <!--<ant antfile="{$temp}/${builds_to_ant_file.xml}" dir="."/>-->
+        
+    </xsl:template>
+    <xsl:template mode="place_subant" match="*">
+        <xsl:param name="uuid" required="yes"/>
+        <xsl:param name="loop_xpath" required="yes"/>
+        <xsl:param name="loop_xpath_real" required="yes"/>
+        <xsl:apply-templates mode="place_subant">
+            <xsl:with-param name="uuid" select="$uuid"/>
+            <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
+            <xsl:with-param name="loop_xpath_real" select="$loop_xpath_real"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    <xsl:template mode="place_subant" match="text()|comment()"/>
+    
     <xsl:template mode="child_nodes" match="*">
         <xsl:copy-of select="."/>
     </xsl:template>
@@ -229,6 +329,8 @@
         <xsl:param name="loop_xpath"  required="yes"/>
         <!--<xsl:param name="loop_xpath_save"  required="yes"/>-->
         <xsl:param name="xml_id"  required="yes"/>
+        <xsl:param name="feature_pos"   required="yes"/>
+        <xsl:param name="loop_xpath_real" required="yes"/>
         <xsl:choose>
             <xsl:when test="$wfs_output"/>
             <xsl:otherwise><xsl:message terminate="yes">Not required param wfs_output - nazwa temp sciagniecia z api xml forsowana przez pierwsze sciagniecie - to set by next parraler step in ant build  </xsl:message></xsl:otherwise>
@@ -261,13 +363,12 @@
                          <!--<xsl:value-of select="$api_url"/>/default_db/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;TYPENAME=<xsl:value-of select="$typeName_dita"/>&amp;SRSNAME=EPSG:3003&amp;featureID=<xsl:value-of select="$featureID_name_dita"/>.<xsl:value-of select="$xpath_value_dita"/>-->
                          <xsl:value-of select="$api_url"/>/default_db/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;TYPENAME=<xsl:value-of select="$typeName_dita"/>&amp;SRSNAME=EPSG:3003<xsl:value-of select="$OGC_Filter"/>
                      </xsl:variable>
-
                             <xsl:element name="target">
-                                <xsl:attribute name="name" select="concat('get_related_feature.',position())"/>
+                                <xsl:attribute name="name" select="concat('get_related_feature.',position(),$loop_xpath_real)"/>
                                 <xsl:choose>
                                     <xsl:when test="$RelatedFeatureCount=$RelatedFeaturePos"/>
                                     <xsl:otherwise>
-                                        <xsl:attribute name="depends" select="concat('get_related_feature.',position()-1)"/>
+                                        <xsl:attribute name="depends" select="concat('get_related_feature.',position()-1),$loop_xpath_real"/>
                                     </xsl:otherwise>
                                 </xsl:choose>
                                 
@@ -298,7 +399,7 @@
                                     </xsl:choose>
                                     <echo> related .dita.xml template is: $wfs_output.dita=<xsl:value-of select="$wfs_output.dita"/>; do przetwarzania na podstawie: $wfs_output.xml=<xsl:value-of select="$wfs_output.xml"/>;</echo>
                                     <xsl:comment> teraz podmieniamy dane z otrzymanego xmla do pliku dita aby potem zrobic polaczony plik  w kolejnym wyzwoleniu ant</xsl:comment>
-                                    <!--<delete file="temp/{$wfs_output.dita}.vals.dita"/>-->
+                                    <delete file="temp/{$wfs_output.dita}.vals.dita"/>
                                     <xslt basedir="./" style="{$build_recurse_ant.xsl}" in="temp/{$wfs_output.dita}"  destdir="./" out="temp/{$wfs_output.dita}.vals.dita" >
                                             <factory name="net.sf.saxon.TransformerFactoryImpl">    
                                                 <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
@@ -315,15 +416,36 @@
                                             <param name="basedir" expression="{$basedir}"/>
                                             <param name="build_recurse_ant.xsl" expression="{$build_recurse_ant.xsl}"/>
                                             <param name="passwordBase64Basic" expression="{$passwordBase64Basic}"/>
+                                            <param name="feature_pos" expression="{$feature_pos}"/> <!-- aby wsadzic nr wezla do $wfs_output.dita.vals.dita -->
+                                            <param name="build_recurse_ant.xsl" expression="{$build_recurse_ant.xsl}"/>
+                                            <param name="temp" expression="{$temp}"/>
+                                            <param name="builds_to_ant.xsl" expression="{$builds_to_ant.xsl}"/>
                                     </xslt>
                             </xsl:element>
                         <!-- zapisujemy wynik naszego biezacego przetwarzania dita element nizej do kolejnego przejechania z ant wyniku dla podstawienia danych  -->
                         <!-- blad - result jest po tym template -->
-                     <xsl:message>#276  $xml_id=<xsl:value-of select="$xml_id"/>; writing $wfs_output.dita to <xsl:value-of select="$wfs_output.dita"/>;</xsl:message>
-                     <xsl:result-document href="{$wfs_output.dita}">
-                         <xsl:comment>current $loop_xpath=<xsl:value-of select="$loop_xpath"/>;</xsl:comment>
-                         <xsl:copy-of select="."/></xsl:result-document>
-                 </xsl:when>
+                        <xsl:message>#276  $feature_pos=<xsl:value-of select="$feature_pos"/>; $xml_id=<xsl:value-of select="$xml_id"/>; writing $wfs_output.dita to <xsl:value-of select="$wfs_output.dita"/>;</xsl:message>
+                             <!-- ten plik moze byc raz bo zawiera tylko mape do przeksztalcenia danego wezla -->
+                            <xsl:result-document href="{$wfs_output.dita}">
+                                <xsl:comment>current $feature_pos=<xsl:value-of select="$feature_pos"/>; $loop_xpath=<xsl:value-of select="$loop_xpath"/>;</xsl:comment>
+                                <!--<xsl:copy-of select="."/>-->
+                                <xsl:element name="{name()}">
+                                    <xsl:copy-of select="@*"/>
+                                    <xsl:attribute name="feature_pos" select="$feature_pos"/>
+                                    <xsl:copy-of select="./*" exclude-result-prefixes="#all" copy-namespaces="no"/>
+                                </xsl:element>
+                            </xsl:result-document>
+                            <!--<xsl:choose>
+                                <xsl:when test="$feature_pos=1"><xsl:message>#327 propably first unaviable (<xsl:value-of select="$wfs_output.dita"/>) - writing</xsl:message>
+                                    <xsl:result-document href="{$wfs_output.dita}">
+                                        <xsl:comment>current $loop_xpath=<xsl:value-of select="$loop_xpath"/>;</xsl:comment>
+                                        <xsl:copy-of select="."/></xsl:result-document>
+                                </xsl:when>
+                                <xsl:otherwise>
+                                    <xsl:message>#227.1 probably exists file:<xsl:value-of select="$wfs_output.dita"/>; - bypassing </xsl:message>
+                                </xsl:otherwise>
+                            </xsl:choose>-->
+                     </xsl:when>
                  <xsl:otherwise>
                      <error>
                          <xsl:attribute name="xpath" select="$xpath"/>
@@ -443,8 +565,15 @@
         <!--<debug_358_RelatedFeature>
             <xsl:copy-of select="$input_obj_with_xpath"/>
         </debug_358_RelatedFeature>-->
-        <xsl:message>#389  jest okazja do zrobienia bilda $xml_id_parent=<xsl:value-of select="$xml_id_parent"/>; $xml_id=<xsl:value-of select="$xml_id"/>;  result-document=<xsl:value-of select="concat($uuid,'.build_',$loop_xpath,'.xml')"/> match=RelatedFeature mode=after_first_ant_assing_vars_childs  </xsl:message>
-        <xsl:result-document href="{$uuid}.build_{$loop_xpath}.xml">
+        <!--<xsl:variable name="feature_pos">
+            <xsl:choose>
+                <xsl:when test="$feature_pos=1"/>
+                <xsl:otherwise><xsl:value-of select="$feature_pos"/></xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>-->
+        <xsl:message>#389  jest okazja do zrobienia bilda $feature_pos=<xsl:value-of select="$feature_pos"/> $xml_id_parent=<xsl:value-of select="$xml_id_parent"/>; $xml_id=<xsl:value-of select="$xml_id"/>;  result-document=<xsl:value-of select="concat($uuid,'.build_',$loop_xpath,'.xml')"/> match=RelatedFeature mode=after_first_ant_assing_vars_childs  </xsl:message>
+            
+        <xsl:result-document href="{$uuid}.build_{$loop_xpath}.{$feature_pos}.xml">
             <xsl:apply-templates select=".">
                 <xsl:with-param name="typeName" select="@typeName"/>
                 <xsl:with-param name="xpath" select="@xpath"/>
@@ -454,6 +583,7 @@
                 <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
                 <xsl:with-param name="wfs_output" select="concat($uuid,'.',$loop_xpath)" />
                 <xsl:with-param name="xml_id_parent" select="$xml_id_parent"/>
+                <xsl:with-param name="feature_pos"   select="$feature_pos"/>
                 <!--<xsl:with-param name="wfs_output.xml" />-->
             </xsl:apply-templates>
         </xsl:result-document>

+ 96 - 13
SE/schema/default_db_xml_cache.public/build_recurse_ant_merge_dita_from_temp.xsl

@@ -13,57 +13,140 @@
     
     <xsl:param name="uuid" required="yes"/>
     <xsl:param name="basedir" required="yes"/>
+    <xsl:param name="temp" required="yes"/>
     
     <!-- template do zlaczenia wszystkich xmli z danymi z dita 
     description="z plikow temp/$uuid.* buduje $out_task.dita " -->
     
     
+    
+    
+    <xsl:template name="get_childs_rows">
+        <xsl:param name="element-filename"  required="yes"/> <!-- prezes1.root_x2f_.d1e1.CRM_PROCES_x2f_.d1e46.CRM_WSKAZNIK_x2f_.d1e51.CRM_LISTA_ZASOBOW.1. -->
+        <xsl:param name="path2collection" select="concat($temp,'/')"/> <!-- $basedir,'/' -->
+        <xsl:variable name="path">
+            <xsl:value-of select="concat($path2collection,'?select=',$element-filename,'*.dita.xml.vals.dita')"/> <!-- $element-filename,'-->
+        </xsl:variable>
+        <xsl:message>#30 otwieram kolekcje $path=<xsl:value-of select="$path"/>; </xsl:message>
+        
+        <!--<xsl:variable name="docs" select="collection($path)"/>-->
+        <!--<xsl:variable name="docs" select="collection($path)"/>-->
+        <!--<xsl:for-each select="$docs">
+            <xsl:message>#35 test - cos jest <xsl:value-of select="name()"/></xsl:message>
+            <xsl:copy-of select="."/>
+        </xsl:for-each>-->
+        <xsl:copy-of select="collection($path)"/>
+
+    </xsl:template>
+    
+    
+    
+    <xsl:template match="*" mode="root">
+        <xsl:param name="loop_xpath"/>
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="@*"/>
+            <xsl:apply-templates>
+                <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
+            </xsl:apply-templates>
+        </xsl:element>
+    </xsl:template>
+    
+    
     <xsl:template match="RelatedFeature">
         <!-- podstawamy dane z xml na podstawie path -->
         <xsl:param name="loop_xpath" select="'root'"/>
+        <xsl:param name="feature_pos_child"  select="1"/> <!-- pierwsze wyzwolenie narzuca 1 - kolejne sa z related -->
+        <xsl:variable name="xml_id" select="@xml_id"/>
         <xsl:variable name="RelatedFeaturePos" select="position()"/>
         <xsl:variable name="featureID_name" select="substring-after(@typeName,':')"/>
-        <xsl:variable name="xml_id" select="@xml_id"/>
+        
         <xsl:variable name="loop_xpath" select="concat($loop_xpath,'_x2f_.',$xml_id,'.',$featureID_name)"/>
 
-        <xsl:message>#26 odpalam loop_xpath=<xsl:value-of select="$loop_xpath"/>.dita.xml.vals.dita;</xsl:message>
+        <xsl:message>#26 odpalam $feature_pos_child=<xsl:value-of select="$feature_pos_child"/>; loop_xpath=<xsl:value-of select="$loop_xpath"/>.dita.xml.vals.dita;</xsl:message>
         <!--<debug26>
             Will try to put file=<xsl:value-of select="concat($uuid,'.',$loop_xpath,$featureID_name,'.',$RelatedFeaturePos,'.dita.xml.vals.dita')"/>;
         </debug26>-->
-        <xsl:variable name="dita_fragment" select="doc(concat($basedir,'/temp/',$uuid,'.',$loop_xpath,'.',$RelatedFeaturePos,'.dita.xml.vals.dita'))"/>
+        <!--<xsl:variable name="dita_fragment" select="doc(concat($basedir,'/temp/',$uuid,'.',$loop_xpath,'.',$RelatedFeaturePos,'.dita.xml.vals.dita'))"/>-->
         
-        <xsl:apply-templates mode="RelatedFeature" select="$dita_fragment/RelatedFeatureRoot/*">
-            <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
-        </xsl:apply-templates>
+        <xsl:variable name="dita_fragment">
+            <xsl:choose>
+                <xsl:when test=" doc-available(concat($basedir,'/',$temp,'/',$uuid,'.',$loop_xpath,'.',$RelatedFeaturePos,'.',$feature_pos_child,'.dita.xml.vals.dita'))">
+                    <xsl:copy-of select="doc(concat($basedir,'/',$temp,'/',$uuid,'.',$loop_xpath,'.',$RelatedFeaturePos,'.',$feature_pos_child,'.dita.xml.vals.dita'))"/>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:comment>#78 INFO no Related leaf xml file <xsl:value-of select="concat($basedir,'/temp/',$uuid,'.',$loop_xpath,'.',$RelatedFeaturePos,'.',$feature_pos_child,'.dita.xml.vals.dita')"/>;</xsl:comment>
+                    <xsl:message>#78 INFO no Related leaf xml file <xsl:value-of select="concat($basedir,'/temp/',$uuid,'.',$loop_xpath,'.',$RelatedFeaturePos,'.',$feature_pos_child,'.dita.xml.vals.dita')"/></xsl:message>
+                </xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        <!--<xsl:variable name="dita_fragment" select="doc(concat($basedir,'/temp/',$uuid,'.',$loop_xpath,'.',$RelatedFeaturePos,'.',$feature_pos_child,'.dita.xml.vals.dita'))"/>-->
+        <!--<xsl:variable name="dita_fragment">
+            <xsl:call-template name="get_childs_rows">
+                <xsl:with-param name="element-filename" select="concat($uuid,'.',$loop_xpath,'.',$RelatedFeaturePos,'.')"/>
+            </xsl:call-template>
+        </xsl:variable>-->
+         
+        <!--<debug_RelatedFeature>
+            <xsl:copy-of select="$dita_fragment"/>
+        </debug_RelatedFeature>-->
+        
+        <xsl:for-each select="$dita_fragment">
+            <xsl:apply-templates mode="RelatedFeature" select="$dita_fragment/RelatedFeatureRoot/*">
+                <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
+            </xsl:apply-templates>
+        </xsl:for-each>
     </xsl:template>
     
-    <xsl:template mode="RelatedFeature" match="RelatedFeature">
+    <xsl:template mode="RelatedFeature" match="*">
         <xsl:param name="loop_xpath" required="yes"/>
-        <xsl:apply-templates select=".">
-            <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
-        </xsl:apply-templates>
+        <!--<xsl:element name="{name()}">-->
+            <!--<xsl:copy-of select="@*"/>-->
+            <!--<xsl:apply-templates select="@*"/>-->
+            <xsl:message>#94 ustalam $feature_pos_child=<xsl:value-of select="position()"/>; dla <xsl:value-of select="name()"/></xsl:message>
+            <xsl:apply-templates mode="RelatedFeatureChild" select=".">
+                <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
+                <xsl:with-param name="feature_pos_child" select="position()"/>
+            </xsl:apply-templates>
+        <!--</xsl:element>-->
     </xsl:template>
     
-    <xsl:template mode="RelatedFeature" match="*">
+    <xsl:template mode="RelatedFeatureChild" match="*">
         <xsl:param name="loop_xpath" required="yes"/>
+        <xsl:param name="feature_pos_child" required="yes"/>
         <xsl:element name="{name()}">
             <!--<xsl:copy-of select="@*"/>-->
             <xsl:apply-templates select="@*"/>
-            <xsl:apply-templates mode="RelatedFeature">
+            <xsl:apply-templates mode="RelatedFeatureChild">
                 <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
+                <xsl:with-param name="feature_pos_child" select="$feature_pos_child"/>
             </xsl:apply-templates>
         </xsl:element>
     </xsl:template>
     
+    <xsl:template mode="RelatedFeatureChild" match="RelatedFeature">
+        <xsl:param name="loop_xpath" required="yes"/>
+        <xsl:param name="feature_pos_child" required="yes"/>
+        <xsl:apply-templates select=".">
+            <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
+            <xsl:with-param name="feature_pos_child" select="$feature_pos_child"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    
+    
     
   
     
-    <xsl:template match="*">
+    
+    
+    <xsl:template match="*" >
         <xsl:param name="loop_xpath"/>
+        <xsl:param name="feature_pos_child" required="yes"/>
         <xsl:element name="{name()}">
             <xsl:copy-of select="@*"/>
             <xsl:apply-templates>
                 <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
+                <xsl:with-param name="feature_pos_child" select="$feature_pos_child"/>
             </xsl:apply-templates>
         </xsl:element>
     </xsl:template>