build_recurse_ant.xsl 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:gml="http://www.opengis.net/gml"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xmlns:xlink="http://www.w3.org/1999/xlink"
  7. xmlns:p5_default_db="https://biuro.biall-net.pl/wfs/default_db"
  8. xmlns:wfs="http://www.opengis.net/wfs"
  9. xmlns:ogc="http://www.opengis.net/ogc"
  10. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  11. xmlns:p5_tr_map="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/procesy5_translate_map.xsd"
  12. exclude-result-prefixes="xs"
  13. version="2.0">
  14. <xsl:output indent="yes" />
  15. <xsl:strip-space elements="*"/>
  16. <!-- Copyright BIALL-NET sp. z o.o. 2017-03-01 by Arkadiusz Binder wszelkie prawa zastrzeżone -->
  17. <!-- @2017-03-01 modyfikacja dla potrzeb CRM_PROCES_tree - sa bledy-->
  18. <xsl:include href="escaped_html_to_xml.xsl"/>
  19. <!--
  20. <property name="url" value="${url}"/> - to point what is record/table to download
  21. <property name="uuid" value="${uuid}"/> it is automatically also set to enable uinque transaction and to allow to save data with user
  22. <property name="passwordBase64Basic" value="${passwordBase64Basic}"/> - this is also set - to enable communicate with API -
  23. <property name="DwebRootUrl" value="${$webRootUrl}"/> - this is the place where script is localized to easyli to target user GUI by href to generated output -->
  24. <!-- variables to be set first by GUI first_request from executing API (php -> bash)-->
  25. <xsl:param name="uuid" required="yes" /> <!-- pewnie bedziemy ignorowac i dzialac na bazie ${'wfs_output'} ktory juz jest tempfilem -->
  26. <xsl:param name="passwordBase64Basic" required="yes" />
  27. <xsl:param name="url" />
  28. <xsl:param name="webRootUrl" />
  29. <xsl:param name="basedir" required="yes"/> <!-- aktualny katalog gdzie znajduja sie pliki temp -->
  30. <!--<xsl:param name="out_task.dita"/>--> <!-- nazwa temp docelowego zrodla do wykonania pliku pdf -->
  31. <!--<xsl:param name="current_leaf.dita" required="yes"/>--> <!-- nazwa aktualnego przetowarzenia .dita - najpierw main_build_recurse_ant.dita potem przechodzi w 1.1.root_x2f_IN7_DZIENNIK_KORESP.1.dita.xml -->
  32. <!--<xsl:param name="wfs_output" select="concat('temp/wfs_output.',$uuid)"/>-->
  33. <!-- jak parametr jest to znaczy, ze przetwarzamy -->
  34. <xsl:param name="wfs_output" required="no"/> <!-- potem wfs_output.xml jak sciagnie nazwa temp sciagniecia z api xml forsowana przez pierwsze sciagniecie -->
  35. <xsl:param name="api_url" select="'https://biuro.biall-net.pl/SE/version-git/wfs-data.php'"/>
  36. <!--<xsl:param name="namespace_prefix" select="'p5_default_db'"/>-->
  37. <xsl:param name="typeName" required="yes" /> <!-- to be set initially ex: p5_default_db:IN7_DZIENNIK_KORESP -->
  38. <xsl:param name="xpath" required="yes" /> <!-- to be set initially ex: ID -->
  39. <xsl:param name="xpath_value" required="yes" /> <!-- to be set ex: 1000 -->
  40. <xsl:param name="loop_xpath" required="yes"/> <!-- sciezka do zapisywania xmli w przetwarzaniu plikow default root -->
  41. <xsl:param name="loop_xpath_save" required="yes"/> <!-- przekazany z template match="RelatedFeature" mode="after_first_ant_assing_vars_childs" -->
  42. <!-- static project variables as default styles.dita/xsl and names-->
  43. <xsl:param name="main_build_recurse_ant.dita" select="'main_build_recurse_ant.dita'"/>
  44. <xsl:param name="xml_id_parent" select="@xml_id"/>
  45. <xsl:param name="build_recurse_ant.xsl" required="yes"/>
  46. <xsl:param name="temp" select="'temp'"/>
  47. <xsl:param name="builds_to_ant.xsl" required="yes"/>
  48. <!-- second step fist loop - with data -->
  49. <!--<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 -->
  50. <!-- opis dzialania template dla przetwarzania wezlow na podstawie schematu i budowania zagniezdzonego pliku xml z
  51. instancjami na podstawie tego samego schematu
  52. wyzwolenie inicjalizujace z build.xml buduje "wyzwolenie glowne" gdzie na output daje wynikowy build.
  53. system wyzwala dwa etapy
  54. wyzwolenie glowne - do okreslenia zaleznosci wezla i zbudowania zapytania o dane
  55. wyzwolenie after_first_ant_assing_vars - do podstawienia danych z wyzwolenia poprzedniego oraz przygotowania build "dla kolejnego X" do wyzwolenia glownego
  56. wyzwolenie glowne - szuka pierwszego RelatedFeature, ktore zawsze domyslnie jest na poczatku template, potem w nim grzebie - jak znajdzie - wchodzi w dol
  57. w ramach tego wyzwolenia przygotowuje task dla biezecego przygotowania ant_build - mode ant_target
  58. w ramach tego wyzwolenia juz musi przeanalizowac jakie sa dalsze zadania do wyzwolenia "dla kolejnego X' ant_build -
  59. mode place_subant (jest okazja do zrobienia builda) do poprawy zagniezdzenia - co robi na podstawie szukania plikow w kontekscie wyzwolenia after_first_ant_assing_vars
  60. wyzwolenie after_first_ant_assing_vars - to wyzwile
  61. to wyzwolenie podstawia dane do dita.vals.xml w celu zlozenia pliku wyjsciowego
  62. to wyzwolenie powinno juz zrobic ant_buildy "dla kolejnego X'
  63. to wyzwolenie korzysta z apply-templates wyzwolenia glownego, w celu przygotowania ant_build
  64. -->
  65. <xsl:template match="*">
  66. <xsl:param name="typeName" select="$typeName" />
  67. <xsl:param name="xpath" select="$xpath" />
  68. <xsl:param name="xpath_value" select="$xpath_value" />
  69. <xsl:param name="loop_xpath" select="$loop_xpath"/>
  70. <xsl:param name="loop_xpath_save" select="$loop_xpath_save"/><!-- tutaj zapisal sie build z wezla z parent -->
  71. <xsl:param name="input_obj_with_xpath" /> <!-- przekazany z template match="RelatedFeature" mode="after_first_ant_assing_vars_childs" -->
  72. <xsl:param name="feature_pos" select="1"/> <!-- przekazany z template match="RelatedFeature" mode="after_first_ant_assing_vars_childs"-->
  73. <xsl:choose>
  74. <xsl:when test="name()='RelatedFeature'">
  75. <xsl:variable name="RelatedFeatureCount" select="last()"/>
  76. <xsl:variable name="RelatedFeaturePos" select="position()"/>
  77. <xsl:variable name="featureID_name" select="substring-after($typeName,':')"/>
  78. <xsl:message>#58 bylo $loop_xpath=<xsl:value-of select="$loop_xpath"/>; $basedir=<xsl:value-of select="$basedir"/>; </xsl:message>
  79. <xsl:variable name="loop_xpath_real" select="$loop_xpath"/>
  80. <xsl:variable name="loop_xpath">
  81. <xsl:choose>
  82. <xsl:when test="$loop_xpath='root'">
  83. <xsl:value-of select="concat($loop_xpath,'_x2f_.',@xml_id,'.',$featureID_name)"/>
  84. </xsl:when>
  85. <xsl:otherwise><xsl:value-of select="$loop_xpath"/></xsl:otherwise>
  86. </xsl:choose>
  87. </xsl:variable>
  88. <xsl:variable name="typeName_dita" select="@typeName"/>
  89. <xsl:variable name="featureID_name_dita" select="substring-after($typeName_dita,':')"/>
  90. <xsl:variable name="xml_id" select="@xml_id"/>
  91. <!--<xsl:variable name="wfs_output" select="concat($uuid,'.',$loop_xpath,'_x2f_',$featureID_name)"/>-->
  92. <xsl:variable name="wfs_output" select="concat($uuid,'.',$loop_xpath)"/>
  93. <!--<xsl:variable name="wfs_output.xml" select="concat($wfs_output,'.',position(),'.xml')"/>-->
  94. <xsl:variable name="wfs_output.xml" select="concat($wfs_output,'.',position(),'.',$feature_pos,'.xml')"/>
  95. <xsl:variable name="wfs_output.dita" select="concat($wfs_output,'.',position(),'.',$feature_pos,'.dita.xml')"/>
  96. <!--<xsl:variable name="wfs_output.dita" select="concat($wfs_output,'.',position(),'.','.dita.xml')"/>-->
  97. <!-- dane z oczekiwanego template .dita -->
  98. <xsl:variable name="xpath_dita" select="@xpath"/>
  99. <xsl:variable name="xpath_value_dita">
  100. <xsl:choose>
  101. <xsl:when test="@xpath_value">
  102. <!--<xsl:variable name="xpath_value_tokens" select="tokenize(@xpath_value,'/')"/>-->
  103. <!--<xsl:value-of select="'todo zapytanie xpath do przetworzenia'"/>-->
  104. <!--<xsl:copy-of select="$xpath_value_tokens"></xsl:copy-of>-->
  105. <!--<xsl:message>#67 probuje ustalic dla featureID_name=<xsl:value-of select="$featureID_name"/>; wartosc z @xpath_value=<xsl:value-of select="@xpath_value"/>; $input_obj_with_xpath/node()[@xpath="ID_BILLING_OWNER"] =<xsl:value-of select="$input_obj_with_xpath/node()[@xpath='ID_BILLING_OWNER']"/>; </xsl:message>-->
  106. <xsl:message>#67.1 $input_obj_with_xpath: <xsl:copy-of select="$input_obj_with_xpath"/> </xsl:message>
  107. <!--<xsl:variable name="xpath_value_token">-->
  108. <xsl:call-template name="xpath_filter_apply">
  109. <xsl:with-param name="input_obj_with_xpath" select="$input_obj_with_xpath"/>
  110. <xsl:with-param name="xpath" select="@xpath"/>
  111. <xsl:with-param name="xpath_value" select="@xpath_value"/>
  112. </xsl:call-template>
  113. <!--</xsl:variable>-->
  114. <!--<xsl:message>#73 ustalam na <xsl:value-of select="$xpath_value_token/node()[1]/text()"/>;</xsl:message>-->
  115. <!--<xsl:value-of select="$xpath_value_token/node()[1]/text()"/>-->
  116. <!--<xsl:value-of select="$xpath_value_token"/>-->
  117. </xsl:when>
  118. <xsl:otherwise>
  119. <xsl:value-of select="$xpath_value"/><!-- parametr z template narzuca wartosc -->
  120. </xsl:otherwise>
  121. </xsl:choose>
  122. </xsl:variable>
  123. <xsl:message>#71 wstawiam projekt $feature_pos=<xsl:value-of select="$feature_pos"/>; $loop_xpath=<xsl:value-of select="$loop_xpath"/>; </xsl:message>
  124. <project basedir="../." name="get_related_feature{$loop_xpath_real}" default="get_related_feature_run_child_ant{$loop_xpath_real}">
  125. <xsl:comment>RelatedFeatureCount:<xsl:value-of select="count(*)"/></xsl:comment>
  126. <echo> ANT Uruchamiam $feature_pos=<xsl:value-of select="$feature_pos"/>; projekt <xsl:value-of select="$loop_xpath_real"/>; </echo>
  127. <!--<xsl:variable name="typeName" select='replace($typeName,"&quot;","")'/>--><!-- oczyszczenie z apostrofow -->
  128. <xsl:element name="property">
  129. <xsl:attribute name="name" select="'uuid'"/>
  130. <xsl:attribute name="value" select="$uuid"/>
  131. </xsl:element>
  132. <xsl:element name="property">
  133. <xsl:attribute name="name" select="'passwordBase64Basic'"/>
  134. <xsl:attribute name="value" select="$passwordBase64Basic"/>
  135. </xsl:element>
  136. <xsl:element name="property">
  137. <xsl:attribute name="name" select="'url'"/>
  138. <xsl:attribute name="value" select="$url"/>
  139. </xsl:element>
  140. <xsl:element name="property">
  141. <xsl:attribute name="name" select="'webRootUrl'"/>
  142. <xsl:attribute name="value" select="$webRootUrl"/>
  143. </xsl:element>
  144. <xsl:element name="property">
  145. <xsl:attribute name="name" select="'build_recurse_ant.xsl'"/>
  146. <xsl:attribute name="value" select="$build_recurse_ant.xsl"/>
  147. </xsl:element>
  148. <xsl:element name="property">
  149. <xsl:attribute name="name" select="'temp'"/>
  150. <xsl:attribute name="value" select="$temp"/>
  151. </xsl:element>
  152. <xsl:element name="property">
  153. <xsl:attribute name="name" select="'builds_to_ant.xsl'"/>
  154. <xsl:attribute name="value" select="$builds_to_ant.xsl"/>
  155. </xsl:element>
  156. <xsl:comment>
  157. Important variables:
  158. typeName=<xsl:value-of select="$typeName"/>;
  159. xpath=<xsl:value-of select="$xpath"/>;
  160. xpath_value=<xsl:value-of select="$xpath_value"/>;
  161. $passwordBase64Basic=<xsl:value-of select="$passwordBase64Basic"/>
  162. </xsl:comment>
  163. <xsl:apply-templates mode="ant_target" select=".">
  164. <xsl:with-param name="typeName_dita" select="$typeName_dita"/>
  165. <xsl:with-param name="featureID_name_dita" select="$featureID_name_dita"/>
  166. <xsl:with-param name="wfs_output" select="$wfs_output"/>
  167. <xsl:with-param name="wfs_output.xml" select="$wfs_output.xml"/>
  168. <xsl:with-param name="wfs_output.dita" select="$wfs_output.dita"/>
  169. <xsl:with-param name="xpath" select="$xpath"/>
  170. <xsl:with-param name="xpath_dita" select="$xpath_dita"/>
  171. <xsl:with-param name="featureID_name" select="$featureID_name"/>
  172. <xsl:with-param name="xpath_value_dita" select="$xpath_value_dita"/>
  173. <xsl:with-param name="RelatedFeatureCount" select="$RelatedFeatureCount"/>
  174. <xsl:with-param name="RelatedFeaturePos" select="$RelatedFeaturePos"/>
  175. <xsl:with-param name="typeName" select="$typeName"/>
  176. <xsl:with-param name="xpath_value" select="$xpath_value"/>
  177. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  178. <xsl:with-param name="loop_xpath_real" select="$loop_xpath_real"/>
  179. <!--<xsl:with-param name="loop_xpath_save" select="$loop_xpath_save"/>-->
  180. <xsl:with-param name="xml_id" select="$xml_id"/>
  181. <!--<xsl:with-param name="xml_id_parent" select="$xml_id_parent"/>-->
  182. <xsl:with-param name="feature_pos" select="$feature_pos"/>
  183. <xsl:with-param name="input_obj_with_xpath" select="$input_obj_with_xpath"/>
  184. </xsl:apply-templates>
  185. <!-- na koniec przetwarzania kazdego z wezlow, podmieniamy xsl biezacy wezel -->
  186. <xsl:comment>template match="RelatedFeature" mode="after_first_ant_assing_vars_childs"
  187. robi result-document href="build_{$loop_xpath}.{$uuid}.xml
  188. wiec powinnismy uruchomic ant ten plik w ciemno znajac jego nizsze wezly</xsl:comment>
  189. <xsl:variable name="featureID_name_child" select="substring-after($typeName,':')"/>
  190. <xsl:variable name="loop_xpath_child" select="concat($loop_xpath,'_x2f_.',$xml_id,'.',$featureID_name)"/>
  191. <xsl:message>#142 ustalamy $loop_xpath_child=<xsl:value-of select="$loop_xpath_child"/></xsl:message>
  192. <xsl:element name="target">
  193. <xsl:attribute name="name" select="concat('get_related_feature_run_child_ant',$loop_xpath_real)"/>
  194. <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos,$loop_xpath_real)"/>
  195. <!--<xsl:choose>
  196. <xsl:when test=".//(RelatedFeature|RelatedFeatureRoot)">
  197. <xsl:for-each select=".//RelatedFeature[ not(child::node()/name()='RelatedFeature')]">
  198. <xsl:variable name="loop_xpath_child_ant" select="concat($loop_xpath_save,'_x2f_.',@xml_id,'.',$featureID_name)"/>
  199. <xsl:message>#148 ustalamy $loop_xpath_child_ant=<xsl:value-of select="$loop_xpath_child_ant"/></xsl:message>
  200. <!-\- <xsl:element name="target">
  201. <xsl:attribute name="name" select="$loop_xpath_child_ant"/><!-\\-'get_related_feature_run_child_ant'-\\->
  202. <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos)"/>-\->
  203. <!-\-<ant antfile="temp/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.xml" dir="."/>-\->
  204. <ant antfile="temp/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.1.xml" dir="."/>
  205. <!-\-</xsl:element>-\->
  206. <xsl:if test=" position()=last()">
  207. <xsl:comment>Tu task z related</xsl:comment>
  208. </xsl:if>
  209. </xsl:for-each>
  210. </xsl:when>
  211. <xsl:otherwise>
  212. <xsl:comment>#135 nie ma wiecej //RelatedFeature</xsl:comment>
  213. <!-\-<xsl:element name="target">
  214. <xsl:attribute name="name" select="'get_related_feature_run_child_ant'"/>
  215. <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos)"/>
  216. </xsl:element>-\->
  217. </xsl:otherwise>
  218. </xsl:choose>-->
  219. <!-- wstawienie subanta dla biezacych dzieci only -->
  220. <xsl:apply-templates mode="place_subant">
  221. <xsl:with-param name="uuid" select="$uuid"/>
  222. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  223. <xsl:with-param name="loop_xpath_real" select="$loop_xpath_real"/>
  224. </xsl:apply-templates>
  225. </xsl:element>
  226. <!-- na koniec przetwarzania danego zaglebienia uruchamiamy calosc ponownie do kolejnego zaglebienia -->
  227. <!-- task do polaczenia zaglebien -->
  228. <!-- jak nie ma zaglebien to generujemy pdf i dajemy uzytkownikowi linka -->
  229. </project>
  230. </xsl:when>
  231. <xsl:otherwise>
  232. <xsl:apply-templates mode="child_nodes"/>
  233. </xsl:otherwise>
  234. </xsl:choose>
  235. </xsl:template>
  236. <!-- trzeba przetwarzac child_nodes do pierwszego napotkania RelatedFeature -->
  237. <xsl:template mode="child_nodes" match="*">
  238. <xsl:copy-of select="."/>
  239. </xsl:template>
  240. <xsl:template mode="place_subant" match="RelatedFeature">
  241. <xsl:param name="uuid" required="yes"/>
  242. <xsl:param name="loop_xpath" required="yes"/>
  243. <xsl:param name="loop_xpath_real" required="yes"/>
  244. <!-- wygenerujemy liste ant -->
  245. <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>
  246. <fileset id="builds_to_ant{$loop_xpath_real}{@xml_id}" dir="temp" includes="{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.*.xml" />
  247. <property name="builds_to_ant{$loop_xpath_real}{@xml_id}" refid="builds_to_ant{$loop_xpath_real}{@xml_id}"/>
  248. <!--<tempfile property="builds_to_ant.xml" deleteonexit="no" destdir="temp" suffix=".xml" prefix="${uuid}.builds_to_ant-"/>-->
  249. <xsl:element name="tempfile">
  250. <xsl:attribute name="property" select="concat('builds_to_ant.xml',$loop_xpath_real,@xml_id)"/>
  251. <xsl:attribute name="deleteonexit" select="'no'"/>
  252. <xsl:attribute name="destdir" select="'temp'"/>
  253. <xsl:attribute name="suffix" select="'.xml'"/>
  254. <xsl:attribute name="prefix" select="concat('${uuid}.builds_to_ant-',@xml_id,'-')"/>
  255. </xsl:element>
  256. <!--<tempfile property="builds_to_ant_file.xml" deleteonexit="no" destdir="temp" suffix=".xml" prefix="${uuid}.build_to_ant_file-"/>-->
  257. <xsl:element name="tempfile">
  258. <xsl:attribute name="property" select="concat('builds_to_ant_file.xml',$loop_xpath_real,@xml_id)"/>
  259. <xsl:attribute name="deleteonexit" select="'no'"/>
  260. <xsl:attribute name="destdir" select="'temp'"/>
  261. <xsl:attribute name="suffix" select="'.xml'"/>
  262. <xsl:attribute name="prefix" select="concat('${uuid}.build_to_ant_file-',@xml_id,'-')"/>
  263. </xsl:element>
  264. <echo>#235 ant do: builds_to_ant.xml=${builds_to_ant_file.xml} mode="place_subant" match="RelatedFeature" </echo>
  265. <!--<echoxml file="'${builds_to_ant.xml}'"><builds_to_ant>${builds_to_ant}</builds_to_ant></echoxml>-->
  266. <xsl:element name="echoxml">
  267. <xsl:attribute name="file" select="concat('${builds_to_ant.xml',$loop_xpath_real,@xml_id,'}')"/>
  268. <builds_to_ant>${builds_to_ant<xsl:value-of select="concat($loop_xpath_real,@xml_id)"/>}</builds_to_ant>
  269. </xsl:element>
  270. <xsl:element name="xslt">
  271. <xsl:attribute name="basedir" select="'./'"/>
  272. <xsl:attribute name="style" select="$builds_to_ant.xsl"/>
  273. <xsl:attribute name="in" select="concat('${builds_to_ant.xml',$loop_xpath_real,@xml_id,'}')"/>
  274. <xsl:attribute name="destdir" select="'./'"/>
  275. <xsl:attribute name="out" select="concat('${builds_to_ant_file.xml',$loop_xpath_real,@xml_id,'}')"/>
  276. <factory name="net.sf.saxon.TransformerFactoryImpl">
  277. <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
  278. <!--<attribute name="http://saxon.sf.net/feature/initialMode"
  279. value="after_first_ant_assing_vars"/>-->
  280. </factory>
  281. <param name="temp" expression="{$temp}"/>
  282. <param name="loop_xpath_real" expression="{$loop_xpath_real}{@xml_id}"/>
  283. <!--<xsl:element name="param">
  284. <xsl:attribute name="name" select="'default_antfile'"/>
  285. <xsl:attribute name="expression" select="concat($temp,'/',$builds_to_ant_file.xml"/>
  286. </xsl:element>-->
  287. <param name="default_antfile" expression="{$temp}/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.1.xml"/>
  288. <classpath location="/opt/local/share/java/saxon9he.jar"/>
  289. </xsl:element>
  290. <!--<ant antfile="{$temp}/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.1.xml" dir="."/>-->
  291. <xsl:element name="ant">
  292. <xsl:attribute name="antfile" select="concat('${builds_to_ant_file.xml',$loop_xpath_real,@xml_id,'}')"/>
  293. </xsl:element>
  294. <!--<ant antfile="{$temp}/${builds_to_ant_file.xml}" dir="."/>-->
  295. </xsl:template>
  296. <xsl:template mode="place_subant" match="*">
  297. <xsl:param name="uuid" required="yes"/>
  298. <xsl:param name="loop_xpath" required="yes"/>
  299. <xsl:param name="loop_xpath_real" required="yes"/>
  300. <xsl:apply-templates mode="place_subant">
  301. <xsl:with-param name="uuid" select="$uuid"/>
  302. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  303. <xsl:with-param name="loop_xpath_real" select="$loop_xpath_real"/>
  304. </xsl:apply-templates>
  305. </xsl:template>
  306. <xsl:template mode="place_subant" match="text()|comment()"/>
  307. <xsl:template name="xpath_filter_apply"> <!-- do przetworzenia filtra na podstawie danych wezla poprzedniego $input_obj_with_xpath oraz podanych parametrow @xpath i @xpath_value -->
  308. <xsl:param name="input_obj_with_xpath" required="yes"/>
  309. <xsl:param name="xpath" required="yes"/>
  310. <xsl:param name="xpath_value" required="yes"/>
  311. <xsl:variable name="xpath_value_token">
  312. <xsl:for-each select=" tokenize($xpath_value,'/')">
  313. <xsl:message>#341 znalazlem dla=<xsl:value-of select="."/>; ; <xsl:value-of select="$input_obj_with_xpath/node()[@xpath=current()]"/></xsl:message>
  314. <xsl:if test="$input_obj_with_xpath/node()[@xpath=current()]">
  315. <xsl:copy-of select="$input_obj_with_xpath/node()[@xpath=current()]"/>
  316. </xsl:if><!-- todo to jest bledne ale dziala tymczasowo-->
  317. </xsl:for-each>
  318. </xsl:variable>
  319. <xsl:message>#345 ustalam na <xsl:value-of select="$xpath_value_token/node()[1]/text()"/>;</xsl:message>
  320. <!--<xsl:value-of select="$xpath_value_token/node()[1]/text()"/>-->
  321. <xsl:value-of select="$xpath_value_token"/>
  322. </xsl:template>
  323. <xsl:template match="RelatedFeature" mode="ant_target" >
  324. <xsl:param name="typeName_dita" required="yes"/>
  325. <xsl:param name="featureID_name_dita" required="yes"/>
  326. <xsl:param name="wfs_output" required="yes"/>
  327. <xsl:param name="wfs_output.xml" required="yes"/>
  328. <xsl:param name="wfs_output.dita" required="yes"/>
  329. <xsl:param name="xpath_dita" required="yes"/>
  330. <xsl:param name="xpath_value_dita" required="yes"/>
  331. <xsl:param name="xpath" required="yes"/>
  332. <xsl:param name="featureID_name" required="yes"/>
  333. <xsl:param name="RelatedFeatureCount" required="yes"/>
  334. <xsl:param name="RelatedFeaturePos" required="yes"/>
  335. <xsl:param name="typeName" required="yes"/>
  336. <xsl:param name="xpath_value" required="yes"/>
  337. <xsl:param name="loop_xpath" required="yes"/>
  338. <!--<xsl:param name="loop_xpath_save" required="yes"/>-->
  339. <xsl:param name="xml_id" required="yes"/>
  340. <xsl:param name="feature_pos" required="yes"/>
  341. <xsl:param name="loop_xpath_real" required="yes"/>
  342. <xsl:param name="input_obj_with_xpath" required="yes"/>
  343. <xsl:choose>
  344. <xsl:when test="$wfs_output"/>
  345. <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>
  346. </xsl:choose>
  347. <!-- template do przetworzenia dity w celu wykrycia:
  348. <RelatedFeature xpath="ID_BILLING_OWNER" typeName="p5_default_db:BILLING_OWNER">
  349. <ph>Nadawca:</ph><br/>
  350. <ph xpath="name1"/><br/>
  351. <ph xpath="name2"/><br/>
  352. <ph xpath="miasto"/><br/>
  353. <ph xpath="nr_rach"/><br/>
  354. <ph xpath="BILLING_OWNER_EMAIL"/><br/>
  355. </RelatedFeature>
  356. i wyrzucenia z tego pierwszego zadania ANT do otrzymania niezbednego .xml w celu jego podstawienia pod dite
  357. w celu pozniejszego ponownego wyzwolenia tego template az do zakonczenia cyklu finalnego.
  358. Template powinien budować projekt ant do wyzwolenia z odpowiednimi parametrami dalszymi
  359. -->
  360. <!-- sprawdzamy czy template pasuje do zadania wyzwolenia czy xpath=xpath_dita oraz czy typeName=typeName_dita-->
  361. <xsl:choose>
  362. <xsl:when test="string($xpath_dita)= string($xpath) and string($featureID_name)=string($featureID_name_dita)">
  363. <!-- calculate query to api default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:IN7_DZIENNIK_KORESP&SRSNAME=EPSG:3003&featureID=IN7_DZIENNIK_KORESP.1000'-->
  364. <!--<property name="OGC_Filter">%26lt;ogc:Filter%26gt;%26lt;ogc:PropertyIsNull%26gt;%26lt;ogc:PropertyName%26gt;the_geom%26lt;/ogc:PropertyName%26gt;%26lt;/ogc:PropertyIsNull%26gt;%26lt;/ogc:Filter%26gt;</property>-->
  365. <!--<xsl:variable name="OGC_Filter">&amp;Filter=&lt;ogc:Filter&gt;&lt;ogc:PropertyIsEqualTo&gt;&lt;ogc:PropertyName&gt;<xsl:value-of select="$xpath_dita"/>&lt;/ogc:PropertyName&gt;&lt;ogc:Literal&gt;<xsl:value-of select="$xpath_value_dita"/>&lt;/ogc:Literal&gt;&lt;/ogc:PropertyIsEqualTo&gt;&lt;/ogc:Filter&gt;</xsl:variable>-->
  366. <xsl:variable name="OGC_Filter">
  367. <xsl:choose>
  368. <xsl:when test="RelatedFilter"><xsl:message>#406 we are enabling RelatedFilter <xsl:copy-of select="RelatedFilter" copy-namespaces="no"/></xsl:message>&amp;Filter=&lt;ogc:Filter&gt;&lt;ogc:And&gt;&lt;ogc:PropertyIsEqualTo&gt;&lt;ogc:PropertyName&gt;<xsl:value-of select="$xpath_dita"/>&lt;/ogc:PropertyName&gt;&lt;ogc:Literal&gt;<xsl:value-of select="$xpath_value_dita"/>&lt;/ogc:Literal&gt;&lt;/ogc:PropertyIsEqualTo&gt;<xsl:for-each select="RelatedFilter">&lt;ogc:PropertyIsEqualTo&gt;&lt;ogc:PropertyName&gt;<xsl:value-of select="@xpath"/>&lt;/ogc:PropertyName&gt;&lt;ogc:Literal&gt;<xsl:value-of select="@xpath_value"/>&lt;/ogc:Literal&gt;&lt;/ogc:PropertyIsEqualTo&gt;</xsl:for-each>&lt;/ogc:And&gt;&lt;/ogc:Filter&gt;</xsl:when>
  369. <xsl:otherwise>&amp;Filter=&lt;ogc:Filter&gt;&lt;ogc:PropertyIsEqualTo&gt;&lt;ogc:PropertyName&gt;<xsl:value-of select="$xpath_dita"/>&lt;/ogc:PropertyName&gt;&lt;ogc:Literal&gt;<xsl:value-of select="$xpath_value_dita"/>&lt;/ogc:Literal&gt;&lt;/ogc:PropertyIsEqualTo&gt;&lt;/ogc:Filter&gt;</xsl:otherwise>
  370. </xsl:choose>
  371. </xsl:variable>
  372. <xsl:message>#410 final OGC_Filter is <xsl:value-of select="$OGC_Filter"/>; </xsl:message>
  373. <xsl:variable name="url">
  374. <!--<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"/>-->
  375. <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"/>
  376. </xsl:variable>
  377. <xsl:element name="target">
  378. <xsl:attribute name="name" select="concat('get_related_feature.',position(),$loop_xpath_real)"/>
  379. <xsl:choose>
  380. <xsl:when test="$RelatedFeatureCount=$RelatedFeaturePos"/>
  381. <xsl:otherwise>
  382. <xsl:attribute name="depends" select="concat('get_related_feature.',position()-1),$loop_xpath_real"/>
  383. </xsl:otherwise>
  384. </xsl:choose>
  385. <!--<tempfile property="out_task.dita" deleteonexit="no" destdir="temp"/>-->
  386. <!--<tempfile property="wfs_output" deleteonexit="no" destdir="temp" suffix=".xml" />-->
  387. <xsl:element name="exec">
  388. <xsl:attribute name="executable" select="'curl'"/>
  389. <xsl:attribute name="output" select="concat('temp/',$wfs_output.xml)"/>
  390. <xsl:attribute name="errorproperty" select="'wfs_error'"/>
  391. <xsl:attribute name="resultproperty" select="'wfs_result'"/>
  392. <xsl:element name="arg">
  393. <!--<xsl:attribute name="line" select='concat("-H ","&amp;Authorization: Basic ",$passwordBase64Basic," ",$url)'/>-->
  394. <xsl:attribute name="line">-H 'Authorization: Basic <xsl:value-of select="$passwordBase64Basic"/>' "<xsl:value-of select="$url"/>"</xsl:attribute>
  395. </xsl:element>
  396. </xsl:element>
  397. <echo message="ERROR__START"/>
  398. <xsl:element name="echo">
  399. <xsl:attribute name="message">${wfs_error}</xsl:attribute>
  400. </xsl:element>
  401. <echo message="ERROR__END"/>
  402. <xsl:choose>
  403. <xsl:when test="position()=last()">
  404. <xsl:comment>antcall target="build_recurse_ant.<xsl:value-of select="position()+1"/>.xml"</xsl:comment>
  405. </xsl:when>
  406. <xsl:otherwise>
  407. <antcall target="build_recurse_ant.{position()+1}.xml"/>
  408. </xsl:otherwise>
  409. </xsl:choose>
  410. <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>
  411. <xsl:comment> teraz podmieniamy dane z otrzymanego xmla do pliku dita aby potem zrobic polaczony plik w kolejnym wyzwoleniu ant</xsl:comment>
  412. <delete file="temp/{$wfs_output.dita}.vals.dita"/>
  413. <xslt basedir="./" style="{$build_recurse_ant.xsl}" in="temp/{$wfs_output.dita}" destdir="./" out="temp/{$wfs_output.dita}.vals.dita" >
  414. <factory name="net.sf.saxon.TransformerFactoryImpl">
  415. <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
  416. <attribute name="http://saxon.sf.net/feature/initialMode" value="after_first_ant_assing_vars"/>
  417. </factory>
  418. <classpath location="/opt/local/share/java/saxon9he.jar"/>
  419. <param name="wfs_output" expression="{$basedir}/temp/{$wfs_output.xml}"/>
  420. <param name="xpath" expression="{$xpath}" /> <!-- kontrolnie - nie potrzebne -->
  421. <param name="xpath_value" expression="{$xpath_value}" /> <!-- kontrolnie - nie potrzebne -->
  422. <param name="loop_xpath" expression="{$loop_xpath}"/>
  423. <param name="loop_xpath_save" expression="{$loop_xpath_save}"/>
  424. <param name="typeName" expression="{$typeName}"/><!-- kontrolnie - nie potrzebne -->
  425. <param name="uuid" expression="{$uuid}"/>
  426. <param name="basedir" expression="{$basedir}"/>
  427. <param name="build_recurse_ant.xsl" expression="{$build_recurse_ant.xsl}"/>
  428. <param name="passwordBase64Basic" expression="{$passwordBase64Basic}"/>
  429. <param name="feature_pos" expression="{$feature_pos}"/> <!-- aby wsadzic nr wezla do $wfs_output.dita.vals.dita -->
  430. <param name="build_recurse_ant.xsl" expression="{$build_recurse_ant.xsl}"/>
  431. <param name="temp" expression="{$temp}"/>
  432. <param name="builds_to_ant.xsl" expression="{$builds_to_ant.xsl}"/>
  433. </xslt>
  434. </xsl:element>
  435. <!-- zapisujemy wynik naszego biezacego przetwarzania dita element nizej do kolejnego przejechania z ant wyniku dla podstawienia danych -->
  436. <!-- blad - result jest po tym template -->
  437. <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>
  438. <!-- ten plik moze byc raz bo zawiera tylko mape do przeksztalcenia danego wezla -->
  439. <xsl:result-document href="{$wfs_output.dita}">
  440. <xsl:comment>current $feature_pos=<xsl:value-of select="$feature_pos"/>; $loop_xpath=<xsl:value-of select="$loop_xpath"/>;</xsl:comment>
  441. <!--<xsl:copy-of select="."/>-->
  442. <xsl:element name="{name()}">
  443. <xsl:copy-of select="@*"/>
  444. <xsl:attribute name="feature_pos" select="$feature_pos"/>
  445. <xsl:copy-of select="./*" exclude-result-prefixes="#all" copy-namespaces="no"/>
  446. </xsl:element>
  447. </xsl:result-document>
  448. <!--<xsl:choose>
  449. <xsl:when test="$feature_pos=1"><xsl:message>#327 propably first unaviable (<xsl:value-of select="$wfs_output.dita"/>) - writing</xsl:message>
  450. <xsl:result-document href="{$wfs_output.dita}">
  451. <xsl:comment>current $loop_xpath=<xsl:value-of select="$loop_xpath"/>;</xsl:comment>
  452. <xsl:copy-of select="."/></xsl:result-document>
  453. </xsl:when>
  454. <xsl:otherwise>
  455. <xsl:message>#227.1 probably exists file:<xsl:value-of select="$wfs_output.dita"/>; - bypassing </xsl:message>
  456. </xsl:otherwise>
  457. </xsl:choose>-->
  458. </xsl:when>
  459. <xsl:otherwise>
  460. <error>
  461. <xsl:attribute name="xpath" select="$xpath"/>
  462. <xsl:attribute name="xpath_dita" select="$xpath_dita"/>
  463. <xsl:attribute name="xpath_value" select="$xpath_value"/>
  464. <xsl:attribute name="xpath_value_dita" select="$xpath_value_dita"/>
  465. <xsl:attribute name="typeName" select="$typeName"/>
  466. <xsl:attribute name="typeName_dita" select="$typeName_dita"/>
  467. <xsl:attribute name="featureID_name" select="$featureID_name"/>
  468. <xsl:attribute name="featureID_name_dita" select="$featureID_name_dita"/>
  469. <echo message="OUTPUT__START"/>
  470. <echo>
  471. Current template doesnt fit the requested data - TODO search for another template! string($xpath_dita)(<xsl:value-of select="$xpath_dita"/>)= string($xpath)(<xsl:value-of select="$xpath"/>) and string($featureID_name)(<xsl:value-of select="$featureID_name"/>)=string($featureID_name_dita)(<xsl:value-of select="$featureID_name_dita"/>)
  472. </echo>
  473. <echo message="OUTPUT__END"/>
  474. </error>
  475. </xsl:otherwise>
  476. </xsl:choose>
  477. </xsl:template>
  478. <!-- second step from local ant leaf -->
  479. <xsl:template match="RelatedFeature" mode="after_first_ant_assing_vars">
  480. <xsl:param name="loop_xpath" select="$loop_xpath"/>
  481. <RelatedFeatureRoot>
  482. <xsl:message>#228 @xml_id=<xsl:value-of select="@xml_id"/>; templ match RelatedFeature mode after_first_ant_assing_vars dla @typeName=<xsl:value-of select="@typeName"/>; try to open $wfs_output=doc(<xsl:value-of select="$wfs_output"/>); </xsl:message>
  483. <!-- first assign xpath to features from -->
  484. <xsl:variable name="wfs_output_nodes" select="doc($wfs_output)"/>
  485. <xsl:variable name="current_RelatedFeature" select="*"/>
  486. <xsl:variable name="xml_id" select="@xml_id"/>
  487. <!--<input_obj_with_xpath_debug>
  488. <xsl:copy-of select="$wfs_output_nodes"/>
  489. </input_obj_with_xpath_debug>-->
  490. <xsl:message>#354 count($wfs_output_nodes//gml:featureMember) <xsl:value-of select="count($wfs_output_nodes//gml:featureMember)"/></xsl:message>
  491. <!-- tutaj jest blad przetwarzania ze wrzuca po rekordzie do kolumny - trzeba przetworzyc dla kazdego feature member -->
  492. <xsl:for-each select="$wfs_output_nodes//gml:featureMember">
  493. <xsl:variable name="input_obj_with_xpath">
  494. <xsl:apply-templates mode="after_first_ant_assing_xpath" select="node()/*"/> <!-- zeby nie wstawial do xpath nazwy feature - IN7_DZIENNIK_KORESP/ID itp -->
  495. </xsl:variable>
  496. <!--<input_obj_with_xpath_debug>
  497. <xsl:attribute name="xpath" select="$xpath"/>
  498. <!-\-<xsl:attribute name="xpath_dita" select="$xpath_dita"/>-\->
  499. <xsl:attribute name="xpath_value" select="$xpath_value"/>
  500. <!-\-<xsl:attribute name="xpath_value_dita" select="$xpath_value_dita"/>-\->
  501. <xsl:attribute name="typeName" select="$typeName"/>
  502. <!-\-<xsl:attribute name="typeName_dita" select="$typeName_dita"/>-\->
  503. <!-\-<xsl:attribute name="featureID_name" select="$featureID_name"/>-\->
  504. <!-\-<xsl:attribute name="featureID_name_dita" select="$featureID_name_dita"/>-\->
  505. <xsl:copy-of select="$input_obj_with_xpath"/>
  506. </input_obj_with_xpath_debug>-->
  507. <!--<input_node_debug>
  508. <xsl:copy-of select="."/>
  509. </input_node_debug>-->
  510. <xsl:apply-templates mode="after_first_ant_assing_vars_childs" select="$current_RelatedFeature">
  511. <xsl:with-param name="input_obj_with_xpath" select="$input_obj_with_xpath"/>
  512. <xsl:with-param name="xml_id_parent" select="$xml_id"/>
  513. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  514. <xsl:with-param name="feature_pos" select="position()"/><!-- wiecej features z relacji dokladamy pozycje -->
  515. </xsl:apply-templates>
  516. </xsl:for-each>
  517. </RelatedFeatureRoot>
  518. </xsl:template>
  519. <xsl:template match="wfs:FeatureCollection|gml:featureMember" mode="after_first_ant_assing_xpath">
  520. <xsl:apply-templates mode="after_first_ant_assing_xpath"/>
  521. </xsl:template>
  522. <xsl:template mode="after_first_ant_assing_xpath" match="*">
  523. <xsl:param name="curr_xpath"/>
  524. <xsl:param name="loop_xpath" select="$loop_xpath"/>
  525. <xsl:choose>
  526. <xsl:when test="name()=$typeName">
  527. <xsl:apply-templates mode="after_first_ant_assing_xpath">
  528. <xsl:with-param name="curr_xpath" select="$curr_xpath"/>
  529. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  530. </xsl:apply-templates>
  531. </xsl:when>
  532. <xsl:otherwise>
  533. <xsl:variable name="curr_xpath_tmpl">
  534. <xsl:choose>
  535. <xsl:when test="$curr_xpath=''">
  536. <xsl:value-of select="local-name()"/> <!-- bylo local-name() - trzeba dorzucic xpath przechodzacy aby budowal sie w kwestii -->
  537. </xsl:when>
  538. <xsl:otherwise>
  539. <xsl:value-of select="concat($curr_xpath,'/',local-name())"/>
  540. </xsl:otherwise>
  541. </xsl:choose>
  542. </xsl:variable>
  543. <!--<xsl:variable name="curr_xpath_tmpl" select="'asdf'"/>-->
  544. <xsl:element name="{name()}">
  545. <xsl:attribute name="xpath" select="$curr_xpath_tmpl"/>
  546. <xsl:for-each select="@*">
  547. <xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
  548. </xsl:for-each>
  549. <xsl:value-of select="text()"/>
  550. <xsl:apply-templates mode="after_first_ant_assing_xpath">
  551. <xsl:with-param name="curr_xpath" select="$curr_xpath_tmpl"/>
  552. </xsl:apply-templates>
  553. </xsl:element>
  554. </xsl:otherwise>
  555. </xsl:choose>
  556. </xsl:template>
  557. <xsl:template match="text()" mode="after_first_ant_assing_xpath"/>
  558. <!-- przetwarzanie kolejne w celu podstawienia wartosci i wystawienia build dla kolejnych wezlow - problem z obsluga rownorzednie zagniezdzonych wezlow poprzez inne wezly -->
  559. <xsl:template match="*" mode="after_first_ant_assing_vars_childs">
  560. <xsl:param name="xml_id_parent" required="yes"/>
  561. <xsl:param name="loop_xpath" required="yes"/>
  562. <xsl:param name="input_obj_with_xpath" required="yes"/>
  563. <xsl:param name="feature_pos" required="yes"/>
  564. <xsl:for-each select=".">
  565. <xsl:choose>
  566. <!--<xsl:when test="node()='topic'">asdad</xsl:when>-->
  567. <!--<xsl:when test="name()='RelatedFeature'">
  568. <xsl:for-each select="data/apiname[@base='PROCES_INCLUDE']">
  569. <xsl:apply-templates mode="PROCES_INCLUDE">
  570. <xsl:with-param name="ID_PROCES" select="text()"/>
  571. </xsl:apply-templates>
  572. </xsl:for-each>
  573. </xsl:when>-->
  574. <!--<xsl:when test="name()='data-about'">
  575. <xsl:for-each select="data/apiname[@base='PROCES_INCLUDE']">
  576. <xsl:apply-templates mode="PROCES_INCLUDE">
  577. <xsl:with-param name="ID_PROCES" select="text()"/>
  578. </xsl:apply-templates>
  579. </xsl:for-each>
  580. </xsl:when>-->
  581. <xsl:when test="1=2"/>
  582. <xsl:otherwise>
  583. <xsl:element name="{name()}">
  584. <!--<xsl:copy-of select="namespace::node()"/>-->
  585. <xsl:for-each select="@*">
  586. <xsl:choose>
  587. <xsl:when test="name()='xpath'">
  588. <!--<xsl:attribute name="xpath_parsed" select="."/>-->
  589. <!--1:<xsl:value-of select="$parent_obj//node()[@system_cache__appinfo:xpath=$xpath]/text()"/>-->
  590. <!--<xsl:value-of select="$parent_obj//node()[local-name()=$xpath]/text()"/>-->
  591. <!--V:<xsl:value-of select="$xpath"/>-->
  592. </xsl:when>
  593. <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
  594. </xsl:choose>
  595. </xsl:for-each>
  596. <xsl:choose>
  597. <xsl:when test="@xpath">
  598. <!--<xsl:variable name="escaped_html_to_xml">
  599. <xsl:call-template name="system_cache__appinfo:escaped_html_to_xml">
  600. <xsl:with-param name="html" select="$input_obj_with_xpath/node()[local-name()=current()/@xpath]/text()"/>
  601. </xsl:call-template>
  602. </xsl:variable>-->
  603. <xsl:variable name="enter_to_ph">
  604. <xsl:apply-templates mode="enter_to_ph" select="$input_obj_with_xpath/node()[local-name()=current()/@xpath]">
  605. <xsl:with-param name="count" select="count($input_obj_with_xpath/node()[local-name()=current()/@xpath])"/>
  606. <xsl:with-param name="element" select="name()"/>
  607. </xsl:apply-templates>
  608. </xsl:variable>
  609. <xsl:copy-of select="$enter_to_ph"/>
  610. </xsl:when>
  611. </xsl:choose>
  612. <xsl:value-of select="text()"/>
  613. <xsl:apply-templates mode="after_first_ant_assing_vars_childs">
  614. <xsl:with-param name="input_obj_with_xpath" select="$input_obj_with_xpath"/>
  615. <xsl:with-param name="xml_id_parent" select="$xml_id_parent"/>
  616. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  617. <xsl:with-param name="feature_pos" select="$feature_pos"/>
  618. </xsl:apply-templates>
  619. </xsl:element>
  620. </xsl:otherwise>
  621. </xsl:choose>
  622. </xsl:for-each>
  623. </xsl:template>
  624. <xsl:template match="RelatedFeature" mode="after_first_ant_assing_vars_childs">
  625. <xsl:param name="input_obj_with_xpath" required="yes"/>
  626. <xsl:param name="xml_id_parent" required="yes"/>
  627. <xsl:param name="loop_xpath" select="$loop_xpath"/>
  628. <xsl:param name="feature_pos" required="yes"/>
  629. <xsl:message>#411 $feature_pos=<xsl:value-of select="$feature_pos"/>; mode after_first_ant_assing_vars_childs bylo $loop_xpath=<xsl:value-of select="$loop_xpath"/>;</xsl:message>
  630. <!-- jest okazja do zrobienia bilda aby sciagnal rzeczy nizej -->
  631. <xsl:variable name="featureID_name" select="substring-after(@typeName,':')"/>
  632. <xsl:variable name="xml_id" select="@xml_id"/>
  633. <xsl:variable name="loop_xpath" select="concat($loop_xpath,'_x2f_.',$xml_id,'.',$featureID_name)"/>
  634. <!--<xsl:variable name="loop_xpath_save" select="concat($loop_xpath,'_x2f_.',$xml_id,'.',$featureID_name)"/>--> <!-- tutaj zapisal sie build z wezla z parent -->
  635. <!--<debug_358_RelatedFeature>
  636. <xsl:copy-of select="$input_obj_with_xpath"/>
  637. </debug_358_RelatedFeature>-->
  638. <!--<xsl:variable name="feature_pos">
  639. <xsl:choose>
  640. <xsl:when test="$feature_pos=1"/>
  641. <xsl:otherwise><xsl:value-of select="$feature_pos"/></xsl:otherwise>
  642. </xsl:choose>
  643. </xsl:variable>-->
  644. <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>
  645. <xsl:result-document href="{$uuid}.build_{$loop_xpath}.{$feature_pos}.xml">
  646. <xsl:apply-templates select=".">
  647. <xsl:with-param name="typeName" select="@typeName"/>
  648. <xsl:with-param name="xpath" select="@xpath"/>
  649. <xsl:with-param name="xpath_value" select="@xpath_value"/>
  650. <!--<xsl:with-param name="loop_xpath_save" select="$loop_xpath"/>-->
  651. <xsl:with-param name="input_obj_with_xpath" select="$input_obj_with_xpath"/>
  652. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  653. <xsl:with-param name="wfs_output" select="concat($uuid,'.',$loop_xpath)" />
  654. <xsl:with-param name="xml_id_parent" select="$xml_id_parent"/>
  655. <xsl:with-param name="feature_pos" select="$feature_pos"/>
  656. <!--<xsl:with-param name="wfs_output.xml" />-->
  657. </xsl:apply-templates>
  658. </xsl:result-document>
  659. <xsl:element name="RelatedFeature">
  660. <xsl:copy-of select="@*"/>
  661. <xsl:attribute name="featureID_name" select="$featureID_name"/>
  662. <xsl:attribute name="loop_xpath" select="$loop_xpath"/>
  663. </xsl:element>
  664. </xsl:template>
  665. <xsl:template match="text()" mode="after_first_ant_assing_vars_childs"/>
  666. <xsl:template match="comment()" mode="after_first_ant_assing_vars_childs"/>
  667. <!-- pozbieranie do kupy wszystkich xmli i zlozenie dity -->
  668. <xsl:template match="*" mode="enter_to_ph">
  669. <xsl:param name="count"/>
  670. <xsl:param name="element"/>
  671. <xsl:variable name="current" select="."/>
  672. <xsl:variable name="surround_with">
  673. <xsl:choose>
  674. <xsl:when test="$element='p'"><xsl:value-of select="'codeblock'"/></xsl:when>
  675. <xsl:when test="$element='bodydiv'"><xsl:value-of select="'p'"/></xsl:when>
  676. <xsl:otherwise><xsl:value-of select="'codeblock'"/></xsl:otherwise>
  677. </xsl:choose>
  678. </xsl:variable>
  679. <xsl:choose>
  680. <xsl:when test=" contains( text(),'&#13;')">
  681. <xsl:for-each select="tokenize( text(),'&#13;')">
  682. <xsl:element name="{$surround_with}"><!-- to jest przetwarzane jak jest tekst lamany -->
  683. <xsl:value-of select="."/>
  684. </xsl:element>
  685. </xsl:for-each>
  686. </xsl:when>
  687. <xsl:otherwise>
  688. <xsl:choose>
  689. <xsl:when test="$count &gt;1">
  690. <codeblock>
  691. <!--<xsl:attribute name="DDxpath" select="@xpath"/>-->
  692. <!--DN(<xsl:value-of select="$element"/>)-->
  693. <!--count:<xsl:value-of select="$count"/>-->
  694. <xsl:copy-of select=" text()"/>
  695. </codeblock>
  696. </xsl:when>
  697. <xsl:otherwise>
  698. <xsl:apply-templates mode="enter_to_ph_text">
  699. <xsl:with-param name="element" select="$element"/>
  700. </xsl:apply-templates>
  701. <!--<xsl:copy-of select=" text()"/>-->
  702. </xsl:otherwise>
  703. </xsl:choose>
  704. </xsl:otherwise>
  705. </xsl:choose>
  706. </xsl:template>
  707. <!-- dodanie enterow dla tabel w ktorych wyrazy sa dluzsze niz 10 znakow -->
  708. <xsl:template match="text()" mode="enter_to_ph_text">
  709. <xsl:param name="element" required="yes"/>
  710. <xsl:choose>
  711. <xsl:when test="$element='entry'">
  712. <xsl:for-each select="tokenize(.,' ')">
  713. <xsl:value-of select="' '"/>
  714. <xsl:variable name="phrase" select="."/>
  715. <xsl:for-each select="1 to string-length(.)">
  716. <xsl:if test="position() mod 12 = 0"><xsl:value-of select="' -'"/></xsl:if>
  717. <xsl:value-of select="substring($phrase,position(),1)"/>
  718. </xsl:for-each>
  719. </xsl:for-each>
  720. </xsl:when>
  721. <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
  722. </xsl:choose>
  723. </xsl:template>
  724. </xsl:stylesheet>