build_recurse_ant_old.xsl 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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. exclude-result-prefixes="xs"
  12. version="2.0">
  13. <xsl:output indent="yes" />
  14. <xsl:strip-space elements="*"/>
  15. <xsl:include href="escaped_html_to_xml.xsl"/>
  16. <!--
  17. <property name="url" value="${url}"/> - to point what is record/table to download
  18. <property name="uuid" value="${uuid}"/> it is automatically also set to enable uinque transaction and to allow to save data with user
  19. <property name="passwordBase64Basic" value="${passwordBase64Basic}"/> - this is also set - to enable communicate with API -
  20. <property name="DwebRootUrl" value="${$webRootUrl}"/> - this is the place where script is localized to easyli to target user GUI by href to generated output -->
  21. <!-- variables to be set first by GUI first_request from executing API (php -> bash)-->
  22. <xsl:param name="uuid" required="yes" /> <!-- pewnie bedziemy ignorowac i dzialac na bazie ${'wfs_output'} ktory juz jest tempfilem -->
  23. <xsl:param name="passwordBase64Basic" required="yes" />
  24. <xsl:param name="url" />
  25. <xsl:param name="webRootUrl" />
  26. <xsl:param name="basedir" required="yes"/> <!-- aktualny katalog gdzie znajduja sie pliki temp -->
  27. <!--<xsl:param name="out_task.dita"/>--> <!-- nazwa temp docelowego zrodla do wykonania pliku pdf -->
  28. <!--<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 -->
  29. <!--<xsl:param name="wfs_output" select="concat('temp/wfs_output.',$uuid)"/>-->
  30. <!-- jak parametr jest to znaczy, ze przetwarzamy -->
  31. <xsl:param name="wfs_output" required="no"/> <!-- potem wfs_output.xml jak sciagnie nazwa temp sciagniecia z api xml forsowana przez pierwsze sciagniecie -->
  32. <xsl:param name="api_url" select="'https://biuro.biall-net.pl/SE/version-git/wfs-data.php'"/>
  33. <!--<xsl:param name="namespace_prefix" select="'p5_default_db'"/>-->
  34. <xsl:param name="typeName" required="yes" /> <!-- to be set initially ex: p5_default_db:IN7_DZIENNIK_KORESP -->
  35. <xsl:param name="xpath" required="yes" /> <!-- to be set initially ex: ID -->
  36. <xsl:param name="xpath_value" required="yes" /> <!-- to be set ex: 1000 -->
  37. <xsl:param name="loop_xpath" required="yes"/> <!-- sciezka do zapisywania xmli w przetwarzaniu plikow default root -->
  38. <xsl:param name="loop_xpath_save" required="yes"/> <!-- przekazany z template match="RelatedFeature" mode="after_first_ant_assing_vars_childs" -->
  39. <!-- static project variables as default styles.dita/xsl and names-->
  40. <xsl:param name="main_build_recurse_ant.dita" select="'main_build_recurse_ant.dita'"/>
  41. <xsl:param name="xml_id_parent" select="@xml_id"/>
  42. <xsl:param name="build_recurse_ant.xsl" required="yes"/>
  43. <!-- second step fist loop - with data -->
  44. <!--<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 -->
  45. <xsl:template match="*">
  46. <xsl:param name="typeName" select="$typeName" />
  47. <xsl:param name="xpath" select="$xpath" />
  48. <xsl:param name="xpath_value" select="$xpath_value" />
  49. <xsl:param name="loop_xpath" select="$loop_xpath"/>
  50. <xsl:param name="loop_xpath_save" select="$loop_xpath_save"/><!-- tutaj zapisal sie build z wezla z parent -->
  51. <xsl:param name="input_obj_with_xpath" /> <!-- przekazany z template match="RelatedFeature" mode="after_first_ant_assing_vars_childs" -->
  52. <xsl:choose>
  53. <xsl:when test="name()='RelatedFeature'">
  54. <xsl:variable name="RelatedFeatureCount" select="last()"/>
  55. <xsl:variable name="RelatedFeaturePos" select="position()"/>
  56. <xsl:variable name="featureID_name" select="substring-after($typeName,':')"/>
  57. <xsl:message>#58 bylo $loop_xpath=<xsl:value-of select="$loop_xpath"/>; $basedir=<xsl:value-of select="$basedir"/>; </xsl:message>
  58. <xsl:variable name="loop_xpath">
  59. <xsl:choose>
  60. <xsl:when test="$loop_xpath='root'">
  61. <xsl:value-of select="concat($loop_xpath,'_x2f_.',@xml_id,'.',$featureID_name)"/>
  62. </xsl:when>
  63. <xsl:otherwise><xsl:value-of select="$loop_xpath"/></xsl:otherwise>
  64. </xsl:choose>
  65. </xsl:variable>
  66. <xsl:variable name="typeName_dita" select="@typeName"/>
  67. <xsl:variable name="featureID_name_dita" select="substring-after($typeName_dita,':')"/>
  68. <xsl:variable name="xml_id" select="@xml_id"/>
  69. <!--<xsl:variable name="wfs_output" select="concat($uuid,'.',$loop_xpath,'_x2f_',$featureID_name)"/>-->
  70. <xsl:variable name="wfs_output" select="concat($uuid,'.',$loop_xpath)"/>
  71. <!--<xsl:variable name="wfs_output.xml" select="concat($wfs_output,'.',position(),'.xml')"/>-->
  72. <xsl:variable name="wfs_output.xml" select="concat($wfs_output,'.',position(),'.xml')"/>
  73. <xsl:variable name="wfs_output.dita" select="concat($wfs_output,'.',position(),'.dita.xml')"/>
  74. <!--<xsl:variable name="wfs_output.dita" select="concat($wfs_output,'.',position(),'.','.dita.xml')"/>-->
  75. <!-- dane z oczekiwanego template .dita -->
  76. <xsl:variable name="xpath_dita" select="@xpath"/>
  77. <xsl:variable name="xpath_value_dita">
  78. <xsl:choose>
  79. <xsl:when test="@xpath_value">
  80. <!--<xsl:variable name="xpath_value_tokens" select="tokenize(@xpath_value,'/')"/>-->
  81. <!--<xsl:value-of select="'todo zapytanie xpath do przetworzenia'"/>-->
  82. <!--<xsl:copy-of select="$xpath_value_tokens"></xsl:copy-of>-->
  83. <!--<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>-->
  84. <xsl:message>#67.1 $input_obj_with_xpath: <xsl:copy-of select="$input_obj_with_xpath"/> </xsl:message>
  85. <xsl:variable name="xpath_value_token">
  86. <xsl:for-each select=" tokenize(@xpath_value,'/')">
  87. <xsl:message>#70 znalazlem dla=<xsl:value-of select="."/>; ; <xsl:value-of select="$input_obj_with_xpath/node()[@xpath=current()]"/></xsl:message>
  88. <xsl:if test="$input_obj_with_xpath/node()[@xpath=current()]">
  89. <xsl:copy-of select="$input_obj_with_xpath/node()[@xpath=current()]"/>
  90. </xsl:if><!-- todo to jest bledne ale dziala tymczasowo-->
  91. </xsl:for-each>
  92. </xsl:variable>
  93. <xsl:message>#73 ustalam na <xsl:value-of select="$xpath_value_token/node()[1]/text()"/>;</xsl:message>
  94. <!--<xsl:value-of select="$xpath_value_token/node()[1]/text()"/>-->
  95. <xsl:value-of select="$xpath_value_token"/>
  96. </xsl:when>
  97. <xsl:otherwise>
  98. <xsl:value-of select="$xpath_value"/><!-- parametr z template narzuca wartosc -->
  99. </xsl:otherwise>
  100. </xsl:choose>
  101. </xsl:variable>
  102. <xsl:message>#71 wstawiam projekt $loop_xpath=<xsl:value-of select="$loop_xpath"/>; </xsl:message>
  103. <project basedir="../." name="get_related_feature" default="get_related_feature_run_child_ant">
  104. <xsl:comment>RelatedFeatureCount:<xsl:value-of select="count(*)"/></xsl:comment>
  105. <!--<xsl:variable name="typeName" select='replace($typeName,"&quot;","")'/>--><!-- oczyszczenie z apostrofow -->
  106. <xsl:element name="property">
  107. <xsl:attribute name="name" select="'uuid'"/>
  108. <xsl:attribute name="value" select="$uuid"/>
  109. </xsl:element>
  110. <xsl:element name="property">
  111. <xsl:attribute name="name" select="'passwordBase64Basic'"/>
  112. <xsl:attribute name="value" select="$passwordBase64Basic"/>
  113. </xsl:element>
  114. <xsl:element name="property">
  115. <xsl:attribute name="name" select="'url'"/>
  116. <xsl:attribute name="value" select="$url"/>
  117. </xsl:element>
  118. <xsl:element name="property">
  119. <xsl:attribute name="name" select="'webRootUrl'"/>
  120. <xsl:attribute name="value" select="$webRootUrl"/>
  121. </xsl:element>
  122. <xsl:comment>
  123. Important variables:
  124. typeName=<xsl:value-of select="$typeName"/>;
  125. xpath=<xsl:value-of select="$xpath"/>;
  126. xpath_value=<xsl:value-of select="$xpath_value"/>;
  127. $passwordBase64Basic=<xsl:value-of select="$passwordBase64Basic"/>
  128. </xsl:comment>
  129. <xsl:apply-templates mode="ant_target" select=".">
  130. <xsl:with-param name="typeName_dita" select="$typeName_dita"/>
  131. <xsl:with-param name="featureID_name_dita" select="$featureID_name_dita"/>
  132. <xsl:with-param name="wfs_output" select="$wfs_output"/>
  133. <xsl:with-param name="wfs_output.xml" select="$wfs_output.xml"/>
  134. <xsl:with-param name="wfs_output.dita" select="$wfs_output.dita"/>
  135. <xsl:with-param name="xpath" select="$xpath"/>
  136. <xsl:with-param name="xpath_dita" select="$xpath_dita"/>
  137. <xsl:with-param name="featureID_name" select="$featureID_name"/>
  138. <xsl:with-param name="xpath_value_dita" select="$xpath_value_dita"/>
  139. <xsl:with-param name="RelatedFeatureCount" select="$RelatedFeatureCount"/>
  140. <xsl:with-param name="RelatedFeaturePos" select="$RelatedFeaturePos"/>
  141. <xsl:with-param name="typeName" select="$typeName"/>
  142. <xsl:with-param name="xpath_value" select="$xpath_value"/>
  143. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  144. <!--<xsl:with-param name="loop_xpath_save" select="$loop_xpath_save"/>-->
  145. <xsl:with-param name="xml_id" select="$xml_id"/>
  146. <!--<xsl:with-param name="xml_id_parent" select="$xml_id_parent"/>-->
  147. </xsl:apply-templates>
  148. <!-- na koniec przetwarzania kazdego z wezlow, podmieniamy xsl biezacy wezel -->
  149. <xsl:comment>template match="RelatedFeature" mode="after_first_ant_assing_vars_childs"
  150. robi result-document href="build_{$loop_xpath}.{$uuid}.xml
  151. wiec powinnismy uruchomic ant ten plik w ciemno znajac jego nizsze wezly</xsl:comment>
  152. <xsl:variable name="featureID_name_child" select="substring-after($typeName,':')"/>
  153. <xsl:variable name="loop_xpath_child" select="concat($loop_xpath,'_x2f_.',$xml_id,'.',$featureID_name)"/>
  154. <xsl:message>#142 ustalamy $loop_xpath_child=<xsl:value-of select="$loop_xpath_child"/></xsl:message>
  155. <xsl:element name="target">
  156. <xsl:attribute name="name" select="'get_related_feature_run_child_ant'"/>
  157. <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos)"/>
  158. <xsl:choose>
  159. <xsl:when test=".//(RelatedFeature|RelatedFeatureRoot)">
  160. <xsl:for-each select=".//RelatedFeature">
  161. <xsl:variable name="loop_xpath_child_ant" select="concat($loop_xpath_save,'_x2f_.',@xml_id,'.',$featureID_name)"/>
  162. <xsl:message>#148 ustalamy $loop_xpath_child_ant=<xsl:value-of select="$loop_xpath_child_ant"/></xsl:message>
  163. <!-- <xsl:element name="target">
  164. <xsl:attribute name="name" select="$loop_xpath_child_ant"/><!-\-'get_related_feature_run_child_ant'-\->
  165. <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos)"/>-->
  166. <!--<ant antfile="temp/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.xml" dir="."/>-->
  167. <ant antfile="temp/{$uuid}.build_{$loop_xpath}_x2f_.{@xml_id}.{ substring-after(@typeName,':') }.xml" dir="."/>
  168. <!--</xsl:element>-->
  169. <xsl:if test=" position()=last()">
  170. <xsl:comment>Tu task z related</xsl:comment>
  171. </xsl:if>
  172. </xsl:for-each>
  173. </xsl:when>
  174. <xsl:otherwise>
  175. <xsl:comment>#135 nie ma wiecej //RelatedFeature</xsl:comment>
  176. <!--<xsl:element name="target">
  177. <xsl:attribute name="name" select="'get_related_feature_run_child_ant'"/>
  178. <xsl:attribute name="depends" select="concat('get_related_feature.',$RelatedFeaturePos)"/>
  179. </xsl:element>-->
  180. </xsl:otherwise>
  181. </xsl:choose>
  182. </xsl:element>
  183. <!-- na koniec przetwarzania danego zaglebienia uruchamiamy calosc ponownie do kolejnego zaglebienia -->
  184. <!-- task do polaczenia zaglebien -->
  185. <!-- jak nie ma zaglebien to generujemy pdf i dajemy uzytkownikowi linka -->
  186. </project>
  187. </xsl:when>
  188. <xsl:otherwise>
  189. <xsl:apply-templates mode="child_nodes"/>
  190. </xsl:otherwise>
  191. </xsl:choose>
  192. </xsl:template>
  193. <xsl:template mode="child_nodes" match="*">
  194. <xsl:copy-of select="."/>
  195. </xsl:template>
  196. <xsl:template match="RelatedFeature" mode="ant_target" >
  197. <xsl:param name="typeName_dita" required="yes"/>
  198. <xsl:param name="featureID_name_dita" required="yes"/>
  199. <xsl:param name="wfs_output" required="yes"/>
  200. <xsl:param name="wfs_output.xml" required="yes"/>
  201. <xsl:param name="wfs_output.dita" required="yes"/>
  202. <xsl:param name="xpath_dita" required="yes"/>
  203. <xsl:param name="xpath_value_dita" required="yes"/>
  204. <xsl:param name="xpath" required="yes"/>
  205. <xsl:param name="featureID_name" required="yes"/>
  206. <xsl:param name="RelatedFeatureCount" required="yes"/>
  207. <xsl:param name="RelatedFeaturePos" required="yes"/>
  208. <xsl:param name="typeName" required="yes"/>
  209. <xsl:param name="xpath_value" required="yes"/>
  210. <xsl:param name="loop_xpath" required="yes"/>
  211. <!--<xsl:param name="loop_xpath_save" required="yes"/>-->
  212. <xsl:param name="xml_id" required="yes"/>
  213. <xsl:choose>
  214. <xsl:when test="$wfs_output"/>
  215. <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>
  216. </xsl:choose>
  217. <!-- template do przetworzenia dity w celu wykrycia:
  218. <RelatedFeature xpath="ID_BILLING_OWNER" typeName="p5_default_db:BILLING_OWNER">
  219. <ph>Nadawca:</ph><br/>
  220. <ph xpath="name1"/><br/>
  221. <ph xpath="name2"/><br/>
  222. <ph xpath="miasto"/><br/>
  223. <ph xpath="nr_rach"/><br/>
  224. <ph xpath="BILLING_OWNER_EMAIL"/><br/>
  225. </RelatedFeature>
  226. i wyrzucenia z tego pierwszego zadania ANT do otrzymania niezbednego .xml w celu jego podstawienia pod dite
  227. w celu pozniejszego ponownego wyzwolenia tego template az do zakonczenia cyklu finalnego.
  228. Template powinien budować projekt ant do wyzwolenia z odpowiednimi parametrami dalszymi
  229. -->
  230. <!-- sprawdzamy czy template pasuje do zadania wyzwolenia czy xpath=xpath_dita oraz czy typeName=typeName_dita-->
  231. <xsl:choose>
  232. <xsl:when test="string($xpath_dita)= string($xpath) and string($featureID_name)=string($featureID_name_dita)">
  233. <!-- 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'-->
  234. <!--<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>-->
  235. <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>
  236. <xsl:variable name="url">
  237. <!--<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"/>-->
  238. <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"/>
  239. </xsl:variable>
  240. <xsl:element name="target">
  241. <xsl:attribute name="name" select="concat('get_related_feature.',position())"/>
  242. <xsl:choose>
  243. <xsl:when test="$RelatedFeatureCount=$RelatedFeaturePos"/>
  244. <xsl:otherwise>
  245. <xsl:attribute name="depends" select="concat('get_related_feature.',position()-1)"/>
  246. </xsl:otherwise>
  247. </xsl:choose>
  248. <!--<tempfile property="out_task.dita" deleteonexit="no" destdir="temp"/>-->
  249. <!--<tempfile property="wfs_output" deleteonexit="no" destdir="temp" suffix=".xml" />-->
  250. <xsl:element name="exec">
  251. <xsl:attribute name="executable" select="'curl'"/>
  252. <xsl:attribute name="output" select="concat('temp/',$wfs_output.xml)"/>
  253. <xsl:attribute name="errorproperty" select="'wfs_error'"/>
  254. <xsl:attribute name="resultproperty" select="'wfs_result'"/>
  255. <xsl:element name="arg">
  256. <!--<xsl:attribute name="line" select='concat("-H ","&amp;Authorization: Basic ",$passwordBase64Basic," ",$url)'/>-->
  257. <xsl:attribute name="line">-H 'Authorization: Basic <xsl:value-of select="$passwordBase64Basic"/>' "<xsl:value-of select="$url"/>"</xsl:attribute>
  258. </xsl:element>
  259. </xsl:element>
  260. <echo message="ERROR__START"/>
  261. <xsl:element name="echo">
  262. <xsl:attribute name="message">${wfs_error}</xsl:attribute>
  263. </xsl:element>
  264. <echo message="ERROR__END"/>
  265. <xsl:choose>
  266. <xsl:when test="position()=last()">
  267. <xsl:comment>antcall target="build_recurse_ant.<xsl:value-of select="position()+1"/>.xml"</xsl:comment>
  268. </xsl:when>
  269. <xsl:otherwise>
  270. <antcall target="build_recurse_ant.{position()+1}.xml"/>
  271. </xsl:otherwise>
  272. </xsl:choose>
  273. <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>
  274. <xsl:comment> teraz podmieniamy dane z otrzymanego xmla do pliku dita aby potem zrobic polaczony plik w kolejnym wyzwoleniu ant</xsl:comment>
  275. <!--<delete file="temp/{$wfs_output.dita}.vals.dita"/>-->
  276. <xslt basedir="./" style="{$build_recurse_ant.xsl}" in="temp/{$wfs_output.dita}" destdir="./" out="temp/{$wfs_output.dita}.vals.dita" >
  277. <factory name="net.sf.saxon.TransformerFactoryImpl">
  278. <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
  279. <attribute name="http://saxon.sf.net/feature/initialMode" value="after_first_ant_assing_vars"/>
  280. </factory>
  281. <classpath location="/opt/local/share/java/saxon9he.jar"/>
  282. <param name="wfs_output" expression="{$basedir}/temp/{$wfs_output.xml}"/>
  283. <param name="xpath" expression="{$xpath}" /> <!-- kontrolnie - nie potrzebne -->
  284. <param name="xpath_value" expression="{$xpath_value}" /> <!-- kontrolnie - nie potrzebne -->
  285. <param name="loop_xpath" expression="{$loop_xpath}"/>
  286. <param name="loop_xpath_save" expression="{$loop_xpath_save}"/>
  287. <param name="typeName" expression="{$typeName}"/><!-- kontrolnie - nie potrzebne -->
  288. <param name="uuid" expression="{$uuid}"/>
  289. <param name="basedir" expression="{$basedir}"/>
  290. <param name="build_recurse_ant.xsl" expression="{$build_recurse_ant.xsl}"/>
  291. <param name="passwordBase64Basic" expression="{$passwordBase64Basic}"/>
  292. </xslt>
  293. </xsl:element>
  294. <!-- zapisujemy wynik naszego biezacego przetwarzania dita element nizej do kolejnego przejechania z ant wyniku dla podstawienia danych -->
  295. <!-- blad - result jest po tym template -->
  296. <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>
  297. <xsl:result-document href="{$wfs_output.dita}">
  298. <xsl:comment>current $loop_xpath=<xsl:value-of select="$loop_xpath"/>;</xsl:comment>
  299. <xsl:copy-of select="."/></xsl:result-document>
  300. </xsl:when>
  301. <xsl:otherwise>
  302. <error>
  303. <xsl:attribute name="xpath" select="$xpath"/>
  304. <xsl:attribute name="xpath_dita" select="$xpath_dita"/>
  305. <xsl:attribute name="xpath_value" select="$xpath_value"/>
  306. <xsl:attribute name="xpath_value_dita" select="$xpath_value_dita"/>
  307. <xsl:attribute name="typeName" select="$typeName"/>
  308. <xsl:attribute name="typeName_dita" select="$typeName_dita"/>
  309. <xsl:attribute name="featureID_name" select="$featureID_name"/>
  310. <xsl:attribute name="featureID_name_dita" select="$featureID_name_dita"/>
  311. Current template doesnt fit the requested data - TODO search for another template!
  312. </error>
  313. </xsl:otherwise>
  314. </xsl:choose>
  315. </xsl:template>
  316. <!-- second step from local ant leaf -->
  317. <xsl:template match="RelatedFeature" mode="after_first_ant_assing_vars">
  318. <xsl:param name="loop_xpath" select="$loop_xpath"/>
  319. <RelatedFeatureRoot>
  320. <xsl:message>#228 try to open $wfs_output=doc(<xsl:value-of select="$wfs_output"/>); @xml_id=<xsl:value-of select="@xml_id"/>; templ match RelatedFeature mode after_first_ant_assing_vars dla @typeName=<xsl:value-of select="@typeName"/>;</xsl:message>
  321. <!-- first assign xpath to features from -->
  322. <xsl:variable name="wfs_output_nodes" select="doc($wfs_output)"/>
  323. <xsl:variable name="current_RelatedFeature" select="*"/>
  324. <xsl:variable name="xml_id" select="@xml_id"/>
  325. <!--<input_obj_with_xpath_debug>
  326. <xsl:copy-of select="$wfs_output_nodes"/>
  327. </input_obj_with_xpath_debug>-->
  328. <xsl:message>#354 count($wfs_output_nodes//gml:featureMember) <xsl:value-of select="count($wfs_output_nodes//gml:featureMember)"/></xsl:message>
  329. <!-- tutaj jest blad przetwarzania ze wrzuca po rekordzie do kolumny - trzeba przetworzyc dla kazdego feature member -->
  330. <xsl:for-each select="$wfs_output_nodes//gml:featureMember">
  331. <xsl:variable name="input_obj_with_xpath">
  332. <xsl:apply-templates mode="after_first_ant_assing_xpath" select="node()/*"/> <!-- zeby nie wstawial do xpath nazwy feature - IN7_DZIENNIK_KORESP/ID itp -->
  333. </xsl:variable>
  334. <!--<input_obj_with_xpath_debug>
  335. <xsl:attribute name="xpath" select="$xpath"/>
  336. <!-\-<xsl:attribute name="xpath_dita" select="$xpath_dita"/>-\->
  337. <xsl:attribute name="xpath_value" select="$xpath_value"/>
  338. <!-\-<xsl:attribute name="xpath_value_dita" select="$xpath_value_dita"/>-\->
  339. <xsl:attribute name="typeName" select="$typeName"/>
  340. <!-\-<xsl:attribute name="typeName_dita" select="$typeName_dita"/>-\->
  341. <!-\-<xsl:attribute name="featureID_name" select="$featureID_name"/>-\->
  342. <!-\-<xsl:attribute name="featureID_name_dita" select="$featureID_name_dita"/>-\->
  343. <xsl:copy-of select="$input_obj_with_xpath"/>
  344. </input_obj_with_xpath_debug>-->
  345. <!--<input_node_debug>
  346. <xsl:copy-of select="."/>
  347. </input_node_debug>-->
  348. <xsl:apply-templates mode="after_first_ant_assing_vars_childs" select="$current_RelatedFeature">
  349. <xsl:with-param name="input_obj_with_xpath" select="$input_obj_with_xpath"/>
  350. <xsl:with-param name="xml_id_parent" select="$xml_id"/>
  351. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  352. <xsl:with-param name="feature_pos" select="position()"/><!-- wiecej features z relacji dokladamy pozycje -->
  353. </xsl:apply-templates>
  354. </xsl:for-each>
  355. </RelatedFeatureRoot>
  356. </xsl:template>
  357. <xsl:template match="wfs:FeatureCollection|gml:featureMember" mode="after_first_ant_assing_xpath">
  358. <xsl:apply-templates mode="after_first_ant_assing_xpath"/>
  359. </xsl:template>
  360. <xsl:template mode="after_first_ant_assing_xpath" match="*">
  361. <xsl:param name="curr_xpath"/>
  362. <xsl:param name="loop_xpath" select="$loop_xpath"/>
  363. <xsl:choose>
  364. <xsl:when test="name()=$typeName">
  365. <xsl:apply-templates mode="after_first_ant_assing_xpath">
  366. <xsl:with-param name="curr_xpath" select="$curr_xpath"/>
  367. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  368. </xsl:apply-templates>
  369. </xsl:when>
  370. <xsl:otherwise>
  371. <xsl:variable name="curr_xpath_tmpl">
  372. <xsl:choose>
  373. <xsl:when test="$curr_xpath=''">
  374. <xsl:value-of select="local-name()"/> <!-- bylo local-name() - trzeba dorzucic xpath przechodzacy aby budowal sie w kwestii -->
  375. </xsl:when>
  376. <xsl:otherwise>
  377. <xsl:value-of select="concat($curr_xpath,'/',local-name())"/>
  378. </xsl:otherwise>
  379. </xsl:choose>
  380. </xsl:variable>
  381. <!--<xsl:variable name="curr_xpath_tmpl" select="'asdf'"/>-->
  382. <xsl:element name="{name()}">
  383. <xsl:attribute name="xpath" select="$curr_xpath_tmpl"/>
  384. <xsl:for-each select="@*">
  385. <xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
  386. </xsl:for-each>
  387. <xsl:value-of select="text()"/>
  388. <xsl:apply-templates mode="after_first_ant_assing_xpath">
  389. <xsl:with-param name="curr_xpath" select="$curr_xpath_tmpl"/>
  390. </xsl:apply-templates>
  391. </xsl:element>
  392. </xsl:otherwise>
  393. </xsl:choose>
  394. </xsl:template>
  395. <xsl:template match="text()" mode="after_first_ant_assing_xpath"/>
  396. <xsl:template match="RelatedFeature" mode="after_first_ant_assing_vars_childs">
  397. <xsl:param name="input_obj_with_xpath" required="yes"/>
  398. <xsl:param name="xml_id_parent" required="yes"/>
  399. <xsl:param name="loop_xpath" select="$loop_xpath"/>
  400. <xsl:param name="feature_pos" required="yes"/>
  401. <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>
  402. <!-- jest okazja do zrobienia bilda aby sciagnal rzeczy nizej -->
  403. <xsl:variable name="featureID_name" select="substring-after(@typeName,':')"/>
  404. <xsl:variable name="xml_id" select="@xml_id"/>
  405. <xsl:variable name="loop_xpath" select="concat($loop_xpath,'_x2f_.',$xml_id,'.',$featureID_name)"/>
  406. <!--<xsl:variable name="loop_xpath_save" select="concat($loop_xpath,'_x2f_.',$xml_id,'.',$featureID_name)"/>--> <!-- tutaj zapisal sie build z wezla z parent -->
  407. <!--<debug_358_RelatedFeature>
  408. <xsl:copy-of select="$input_obj_with_xpath"/>
  409. </debug_358_RelatedFeature>-->
  410. <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>
  411. <xsl:result-document href="{$uuid}.build_{$loop_xpath}.xml">
  412. <xsl:apply-templates select=".">
  413. <xsl:with-param name="typeName" select="@typeName"/>
  414. <xsl:with-param name="xpath" select="@xpath"/>
  415. <xsl:with-param name="xpath_value" select="@xpath_value"/>
  416. <!--<xsl:with-param name="loop_xpath_save" select="$loop_xpath"/>-->
  417. <xsl:with-param name="input_obj_with_xpath" select="$input_obj_with_xpath"/>
  418. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  419. <xsl:with-param name="wfs_output" select="concat($uuid,'.',$loop_xpath)" />
  420. <xsl:with-param name="xml_id_parent" select="$xml_id_parent"/>
  421. <!--<xsl:with-param name="wfs_output.xml" />-->
  422. </xsl:apply-templates>
  423. </xsl:result-document>
  424. <xsl:element name="RelatedFeature">
  425. <xsl:copy-of select="@*"/>
  426. <xsl:attribute name="featureID_name" select="$featureID_name"/>
  427. <xsl:attribute name="loop_xpath" select="$loop_xpath"/>
  428. </xsl:element>
  429. </xsl:template>
  430. <xsl:template match="*" mode="after_first_ant_assing_vars_childs">
  431. <xsl:param name="xml_id_parent" required="yes"/>
  432. <xsl:param name="loop_xpath" required="yes"/>
  433. <xsl:param name="input_obj_with_xpath" required="yes"/>
  434. <xsl:param name="feature_pos" required="yes"/>
  435. <xsl:for-each select=".">
  436. <xsl:choose>
  437. <!--<xsl:when test="node()='topic'">asdad</xsl:when>-->
  438. <!--<xsl:when test="name()='RelatedFeature'">
  439. <xsl:for-each select="data/apiname[@base='PROCES_INCLUDE']">
  440. <xsl:apply-templates mode="PROCES_INCLUDE">
  441. <xsl:with-param name="ID_PROCES" select="text()"/>
  442. </xsl:apply-templates>
  443. </xsl:for-each>
  444. </xsl:when>-->
  445. <!--<xsl:when test="name()='data-about'">
  446. <xsl:for-each select="data/apiname[@base='PROCES_INCLUDE']">
  447. <xsl:apply-templates mode="PROCES_INCLUDE">
  448. <xsl:with-param name="ID_PROCES" select="text()"/>
  449. </xsl:apply-templates>
  450. </xsl:for-each>
  451. </xsl:when>-->
  452. <xsl:when test="1=2"/>
  453. <xsl:otherwise>
  454. <xsl:element name="{name()}">
  455. <!--<xsl:copy-of select="namespace::node()"/>-->
  456. <xsl:for-each select="@*">
  457. <xsl:choose>
  458. <xsl:when test="name()='xpath'">
  459. <!--<xsl:attribute name="xpath_parsed" select="."/>-->
  460. <!--1:<xsl:value-of select="$parent_obj//node()[@system_cache__appinfo:xpath=$xpath]/text()"/>-->
  461. <!--<xsl:value-of select="$parent_obj//node()[local-name()=$xpath]/text()"/>-->
  462. <!--V:<xsl:value-of select="$xpath"/>-->
  463. </xsl:when>
  464. <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
  465. </xsl:choose>
  466. </xsl:for-each>
  467. <xsl:choose>
  468. <xsl:when test="@xpath">
  469. <!--<xsl:variable name="escaped_html_to_xml">
  470. <xsl:call-template name="system_cache__appinfo:escaped_html_to_xml">
  471. <xsl:with-param name="html" select="$input_obj_with_xpath/node()[local-name()=current()/@xpath]/text()"/>
  472. </xsl:call-template>
  473. </xsl:variable>-->
  474. <xsl:variable name="enter_to_ph">
  475. <xsl:apply-templates mode="enter_to_ph" select="$input_obj_with_xpath/node()[local-name()=current()/@xpath]">
  476. <xsl:with-param name="count" select="count($input_obj_with_xpath/node()[local-name()=current()/@xpath])"/>
  477. </xsl:apply-templates>
  478. </xsl:variable>
  479. <xsl:copy-of select="$enter_to_ph"/>
  480. </xsl:when>
  481. </xsl:choose>
  482. <xsl:value-of select="text()"/>
  483. <xsl:apply-templates mode="after_first_ant_assing_vars_childs">
  484. <xsl:with-param name="input_obj_with_xpath" select="$input_obj_with_xpath"/>
  485. <xsl:with-param name="xml_id_parent" select="$xml_id_parent"/>
  486. <xsl:with-param name="loop_xpath" select="$loop_xpath"/>
  487. <xsl:with-param name="feature_pos" select="$feature_pos"/>
  488. </xsl:apply-templates>
  489. </xsl:element>
  490. </xsl:otherwise>
  491. </xsl:choose>
  492. </xsl:for-each>
  493. </xsl:template>
  494. <xsl:template match="text()" mode="after_first_ant_assing_vars_childs"/>
  495. <xsl:template match="comment()" mode="after_first_ant_assing_vars_childs"/>
  496. <!-- pozbieranie do kupy wszystkich xmli i zlozenie dity -->
  497. <xsl:template match="*" mode="enter_to_ph">
  498. <xsl:param name="count"/>
  499. <xsl:choose>
  500. <xsl:when test=" contains( text(),'&#13;')">
  501. <xsl:for-each select="tokenize( text(),'&#13;')">
  502. <codeblock><xsl:value-of select="."/></codeblock>
  503. </xsl:for-each>
  504. </xsl:when>
  505. <xsl:otherwise>
  506. <xsl:choose>
  507. <xsl:when test="$count &gt;1">
  508. <codeblock>
  509. <!-- count:<xsl:value-of select="$count"/>
  510. --> <xsl:copy-of select=" text()"/>
  511. </codeblock>
  512. </xsl:when>
  513. <xsl:otherwise>
  514. <xsl:copy-of select=" text()"/>
  515. </xsl:otherwise>
  516. </xsl:choose>
  517. </xsl:otherwise>
  518. </xsl:choose>
  519. </xsl:template>
  520. </xsl:stylesheet>