get_all_xsd.xsl 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. exclude-result-prefixes="xs hfp"
  5. version="2.0"
  6. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  7. xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty">
  8. <xsl:output indent="yes"/>
  9. <xsl:strip-space elements="*"/>
  10. <xsl:param name="procesy5_system_schema" select="'../default_db.instance.xml/transformed/procesy5_system_schema.xml'"/>
  11. <xsl:param name="procesy5_system_schema_collection_dir" select="'../'"/>
  12. <xsl:param name="cache" select="'refresh'"/>
  13. <xsl:param name="targetNamespace_DEFAULTS" select="'http://biuro.biall-net.pl/xmlschema_procesy5/default_db'"/>
  14. <xsl:param name="external_schema" select="'/public_html/external_schema'"/>
  15. <xsl:param name="external_schema_id_namespace_prefix" select="'/public_html/external_schema_id_namespace_prefix'"/>
  16. <xsl:param name="XMLSchema_prefix" select="'xs'"/><xsl:include href="../default_db_xml_cache.public/xml-schema-primitives.xsl"/>
  17. <xsl:include href="system_cache__appinfo/external_schema_targetNamespace.xsl"/>
  18. <xsl:function name="system_cache__appinfo:document-uri_for_external_schema_id_namespace_prefix">
  19. <xsl:param name="system_cache__appinfo:document-uri_from_external_schema"/>
  20. <xsl:value-of select="substring-after(replace($system_cache__appinfo:document-uri_from_external_schema,$external_schema,$external_schema_id_namespace_prefix ), '/public_html/') "/>
  21. </xsl:function>
  22. <xsl:function name="system_cache__appinfo:document-uri-full_for_external_schema_id_namespace_prefix">
  23. <xsl:param name="system_cache__appinfo:document-uri_from_external_schema"/>
  24. <xsl:value-of select="replace($system_cache__appinfo:document-uri_from_external_schema,$external_schema,$external_schema_id_namespace_prefix )"/>
  25. </xsl:function><xsl:function name="system_cache__appinfo:clean_object_prefix">
  26. <xsl:param name="name" />
  27. <xsl:choose>
  28. <xsl:when test="substring-after($name,':')">
  29. <xsl:value-of select="substring-after($name,':')"/>
  30. </xsl:when>
  31. <xsl:otherwise>
  32. <xsl:value-of select="$name"/>
  33. </xsl:otherwise>
  34. </xsl:choose>
  35. </xsl:function>
  36. <xsl:function name="system_cache__appinfo:get_object_prefix">
  37. <xsl:param name="name" />
  38. <xsl:choose>
  39. <xsl:when test="substring-before($name,':')">
  40. <xsl:value-of select="substring-before($name,':')"/>
  41. </xsl:when>
  42. <xsl:otherwise>
  43. <xsl:message terminate="yes">system_cache__appinfo:get_object_prefix(<xsl:value-of select="$name"/>) - parameter has no exptected prefix:object format definition! Maybe not expected schema?</xsl:message>
  44. </xsl:otherwise>
  45. </xsl:choose>
  46. </xsl:function>
  47. <!-- funkcja do wyczyszczenia wyescapowenago prefixu z np. default_db__x3A__IN7_DZIENNIK_KORESP do IN7_DZIENNIK_KORESP -->
  48. <xsl:function name="system_cache__appinfo:clean_object_escaped_prefix">
  49. <xsl:param name="name" />
  50. </xsl:function>
  51. <!-- funkcja do ponownego zamienienia na sredniki itp z np. default_db__x3A__IN7_DZIENNIK_KORESP do IN7_DZIENNIK_KORESP -->
  52. <xsl:function name="system_cache__appinfo:translate_object_escaped_prefix_from_string">
  53. <xsl:param name="name" />
  54. <xsl:value-of select="replace(replace(replace(replace(replace(replace(replace(replace($name, '__x2F__', '/'), '__x3A__', ':'),'__x2D__','-'),'__x25__','%'),'__x28__','('),'__x29__',')'),'__x23__','#'),'__x2A__','*')"/>
  55. </xsl:function>
  56. <!-- funkcja do zamienienia na postac default_db__x3A__IN7_DZIENNIK_KORESP do IN7_DZIENNIK_KORESP -->
  57. <xsl:function name="system_cache__appinfo:escape_object_prefix_to_string">
  58. <xsl:param name="name" />
  59. <xsl:value-of select="replace(replace(replace(replace(replace(replace(replace(replace($name, '/', '__x2F__'), ':', '__x3A__'),'-','__x2D__'),'%','__x25__'), '\(', '__x28__'), '\)' ,'__x29__'),'#','__x23__'),'\*','__x2A__')"/>
  60. </xsl:function>
  61. <xsl:template name="system_cache__appinfo:prefixed_object_info">
  62. <xsl:param name="prefixed_object" required="yes"/>
  63. <xsl:variable name="prefix_token" select="tokenize(system_cache__appinfo:translate_object_escaped_prefix_from_string($prefixed_object),':')"/>
  64. <xsl:choose>
  65. <xsl:when test=" string-length($prefix_token[3]) &gt; 0">
  66. <system_cache__appinfo:prefixed_object_info>
  67. <xsl:attribute name="prefix" select="$prefix_token[1]"/>
  68. <xsl:attribute name="name" select="$prefix_token[2]"/>
  69. <xsl:attribute name="element" select="$prefix_token[3]"/>
  70. </system_cache__appinfo:prefixed_object_info>
  71. </xsl:when>
  72. <xsl:otherwise>
  73. <system_cache__appinfo:prefixed_object_info>
  74. <xsl:attribute name="prefix" select="$prefix_token[1]"/>
  75. <xsl:attribute name="name" select="$prefix_token[2]"/>
  76. <xsl:attribute name="element" select="$prefix_token[2]"/>
  77. </system_cache__appinfo:prefixed_object_info>
  78. </xsl:otherwise>
  79. </xsl:choose>
  80. </xsl:template>
  81. <!-- @2016-08 funkcje do wykrywania prefixow, namespace itp itd...
  82. <xsl:attribute name="prefix" select="$vrtfNamespaces/ns[@uri=$targetnamespace][1]/@prefix" xpath-default-namespace=""/>
  83. <xsl:attribute name="targetnamespace" select="$targetnamespace"/>
  84. <xsl:attribute name="type_79" select="$type_79"/>
  85. <xsl:attribute name="prefix_79" select="$prefix_79"/>
  86. <xsl:attribute name="type_79_nopref" select="$type_79_nopref"/>
  87. -->
  88. <xsl:function name="system_cache__appinfo:prefix_from_targetNamespace">
  89. <xsl:param name="system_cache__appinfo:vrtfNamespaces" />
  90. <xsl:param name="targetNamespace" />
  91. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[@uri=$targetNamespace][1]/@prefix" xpath-default-namespace=""/>
  92. </xsl:function>
  93. <xsl:function name="system_cache__appinfo:targetNamespace_from_prefix">
  94. <xsl:param name="system_cache__appinfo:vrtfNamespaces" />
  95. <xsl:param name="prefix" />
  96. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[@prefix=$prefix][1]/@uri" xpath-default-namespace=""/>
  97. </xsl:function>
  98. <xsl:function name="system_cache__appinfo:get_default_db_obj_url_table_name"><!-- @2016-10 funkcja do wykrywania nazwy tabeli dla default db, w przypadku braku zgodnosci namespace - nic nie zwraca -->
  99. <xsl:param name="parent_complexTypeNamespace" />
  100. <xsl:variable name="uri_tokens" select="tokenize($parent_complexTypeNamespace,'/')"/>
  101. <xsl:variable name="uri_tokens_count" select="count($uri_tokens)"/>
  102. <xsl:if test="$uri_tokens[($uri_tokens_count - 1)]='table' and $uri_tokens[($uri_tokens_count - 2)]='default_db' and $uri_tokens[($uri_tokens_count - 3)]='wfs'">
  103. <xsl:variable name="get_default_db_obj_url_table_name" select="tokenize($uri_tokens[$uri_tokens_count],'\.')"/>
  104. <xsl:value-of select="$get_default_db_obj_url_table_name[1]"/>
  105. </xsl:if>
  106. </xsl:function>
  107. <!--<xsl:function name="system_cache__appinfo:php_function_name_from_obj_with_prefix">
  108. <xsl:param name="object_name" required="yes"/>
  109. <xsl:value-of select="replace($object_name,':','__x3A__')"/>
  110. </xsl:function>-->
  111. <xsl:template name="main">
  112. <xsl:call-template name="system_cache__appinfo:get_all_xsd">
  113. <xsl:with-param name="path2collection" select="'../'"/>
  114. <xsl:with-param name="cache" select="'read'"/>
  115. </xsl:call-template>
  116. </xsl:template>
  117. <xsl:template match="system_cache__appinfo:get_all_xsd_external_schema" mode="system_cache__appinfo:get_all_xsd_external_schema__equals" >
  118. <xsl:param name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" required="yes"/>
  119. <xsl:variable name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix">
  120. <var>
  121. <xsl:for-each select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/*">
  122. <xsl:element name="{name()}">
  123. <xsl:attribute name="pos" select="position()"/>
  124. <xsl:copy-of select="@*"/>
  125. <xsl:copy-of select="*"/>
  126. </xsl:element>
  127. </xsl:for-each>
  128. </var>
  129. </xsl:variable>
  130. <system_cache__appinfo:get_all_xsd_external_schema__equals>
  131. <xsl:copy-of select="@*"/>
  132. <xsl:call-template name="system_cache__appinfo:get_all_xsd_external_schema__equals">
  133. <xsl:with-param name="system_cache__appinfo:get_all_xsd_external_schema" select=".[*]"/>
  134. <xsl:with-param name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix"/>
  135. </xsl:call-template>
  136. <!--<system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix>
  137. <xsl:copy-of select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix"></xsl:copy-of>
  138. </system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix>-->
  139. </system_cache__appinfo:get_all_xsd_external_schema__equals>
  140. </xsl:template>
  141. <!--<xsl:template match="schema" mode="system_cache__appinfo:get_all_xsd_external_schema__equals" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  142. <xsl:param name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" required="yes"/>
  143. <xsl:apply-templates mode="system_cache__appinfo:get_all_xsd_external_schema__equals">
  144. <xsl:with-param name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/*"/>
  145. </xsl:apply-templates>
  146. </xsl:template>-->
  147. <xsl:template name="system_cache__appinfo:get_all_xsd_external_schema__equals" >
  148. <xsl:param name="system_cache__appinfo:get_all_xsd_external_schema" required="yes"/>
  149. <xsl:param name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" required="yes"/>
  150. <!--<pre_external_schema>
  151. <xsl:for-each select="$system_cache__appinfo:get_all_xsd_external_schema/*">
  152. <xsl:element name="{name()}"><xsl:copy-of select="@*"/></xsl:element>
  153. </xsl:for-each>
  154. </pre_external_schema>
  155. <pre_schema_id_namespace_prefix>
  156. <xsl:for-each select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/var/*">
  157. <xsl:element name="{name()}"><xsl:copy-of select="@*"/></xsl:element>
  158. </xsl:for-each>
  159. </pre_schema_id_namespace_prefix>-->
  160. <xsl:for-each select="$system_cache__appinfo:get_all_xsd_external_schema/*">
  161. <xsl:variable name="position" select="position()"/>
  162. <xsl:comment> Try position <xsl:value-of select="$position"/>;</xsl:comment>
  163. <xsl:choose>
  164. <!--<xsl:when test="not($position = $pos)">
  165. <not_pos>
  166. <xsl:attribute name="pos" select="$pos"/>
  167. <xsl:attribute name="position" select="$position"/>
  168. <xsl:attribute name="expected" select="local-name()"/>
  169. </not_pos>
  170. </xsl:when>-->
  171. <xsl:when test="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/var/*[ @pos = $position]/local-name() = local-name()">
  172. <!--<equals>
  173. <xsl:attribute name="position" select="position()"/>
  174. <xsl:attribute name="expected" select="local-name()"/>
  175. <xsl:attribute name="found" select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/var/*[ @pos = $position]/local-name()"/>
  176. <xsl:attribute name="first_el_par" select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/var[1]/name()"/>
  177. </equals>-->
  178. <!--<xsl:message>#170 comp equal <xsl:value-of select="local-name()"/> === <xsl:value-of select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix[ position() = $position]/local-name()"/></xsl:message>-->
  179. </xsl:when>
  180. <xsl:otherwise>
  181. <not_equals>
  182. <xsl:attribute name="position" select="position()"/>
  183. <xsl:attribute name="expected" select="local-name()"/>
  184. <xsl:attribute name="found" select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/var/*[ @pos = $position]/local-name()"/>
  185. <xsl:attribute name="found_id" select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/var/*[ @pos = $position]/@id"/>
  186. <xsl:attribute name="found_pos" select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/var/*[ @pos = $position]/@pos"/>
  187. <xsl:attribute name="first_el_par" select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/var/*[1]/name()"/>
  188. </not_equals>
  189. </xsl:otherwise>
  190. </xsl:choose>
  191. <!--<child>-->
  192. <xsl:variable name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix_new">
  193. <var>
  194. <xsl:for-each select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix/var/*[@pos=$position]/*">
  195. <xsl:element name="{name()}">
  196. <xsl:attribute name="pos" select="position()"/>
  197. <xsl:copy-of select="@*"/>
  198. <xsl:copy-of select="*"/>
  199. </xsl:element>
  200. </xsl:for-each>
  201. </var>
  202. </xsl:variable>
  203. <!--<test_var_new><xsl:copy-of select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix_new"/></test_var_new>-->
  204. <xsl:call-template name="system_cache__appinfo:get_all_xsd_external_schema__equals">
  205. <xsl:with-param name="system_cache__appinfo:get_all_xsd_external_schema" select=".[*]"/>
  206. <xsl:with-param name="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" select="$system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix_new/.[*]"/>
  207. </xsl:call-template>
  208. <!--</child>-->
  209. </xsl:for-each>
  210. </xsl:template>
  211. <xsl:template match="schema" mode="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  212. <xsl:param name="system_cache__appinfo:document-uri" required="yes"/>
  213. <xsl:variable name="targetNamespace" select="@targetNamespace"/>
  214. <xsl:variable name="namespaces_cur">
  215. <namespaces_cur>
  216. <xsl:for-each select="namespace::node()">
  217. <ns element="{name(..)}" prefix="{name()}" uri="{.}"/>
  218. </xsl:for-each>
  219. </namespaces_cur>
  220. </xsl:variable>
  221. <xsl:element name="schema" namespace="http://www.w3.org/2001/XMLSchema" extension-element-prefixes="#default" inherit-namespaces="yes">
  222. <xsl:choose>
  223. <xsl:when test="@targetNamespace and ( not($namespaces_cur//ns[@uri=$targetNamespace]/@prefix) or $namespaces_cur//ns[@uri=$targetNamespace]/@prefix='' ) " xpath-default-namespace="">
  224. <xsl:variable name="detect_prefix" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace_prefix($system_cache__appinfo:document-uri)"/>
  225. <xsl:namespace name="{$detect_prefix}" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace(@targetNamespace)"/>
  226. <xsl:copy-of select="@targetNamespace"/>
  227. <xsl:attribute name="vc:minVersion" select="'1.0'"/>
  228. <xsl:attribute name="vc:maxVersion" select="'1.1'"/>
  229. <xsl:comment>#144 when @targetNamespace exists and prefix not exists</xsl:comment>
  230. <xsl:comment>namespaces_cur/ns/@uri=<xsl:value-of select="$targetNamespace"/> = <xsl:value-of select="$namespaces_cur/namespaces_cur/ns[@uri=$targetNamespace]/@prefix"/> </xsl:comment>
  231. <xsl:comment> count: <xsl:value-of select="count($namespaces_cur/namespaces_cur/ns)"/> </xsl:comment>
  232. <xsl:copy-of select="*"/>
  233. </xsl:when>
  234. <xsl:when test="@targetNamespace">
  235. <xsl:variable name="detect_prefix" select="$namespaces_cur//ns[@uri=$targetNamespace]/@prefix" xpath-default-namespace=""/>
  236. <xsl:namespace name="{$detect_prefix}" select="@targetNamespace"/>
  237. <xsl:copy-of select="@targetNamespace"/>
  238. <xsl:attribute name="vc:minVersion" select="'1.0'"/>
  239. <xsl:attribute name="vc:maxVersion" select="'1.1'"/>
  240. <xsl:comment>#147 when @targetNamespace and prefix probably exists!</xsl:comment>
  241. <xsl:copy-of select="*"/>
  242. </xsl:when>
  243. <xsl:otherwise>
  244. <xsl:variable name="detect_prefix" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace_prefix($system_cache__appinfo:document-uri)"/>
  245. <xsl:namespace name="{$detect_prefix}" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace($system_cache__appinfo:document-uri)"/>
  246. <xsl:attribute name="targetNamespace" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace($system_cache__appinfo:document-uri)"/>
  247. <xsl:attribute name="vc:minVersion" select="'1.0'"/>
  248. <xsl:attribute name="vc:maxVersion" select="'1.1'"/>
  249. <xsl:message>#35 detect. targetNamespace <xsl:value-of select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace($system_cache__appinfo:document-uri)"/></xsl:message>
  250. <xsl:comment>#158 otherwise not @targetNamespace and no prefix</xsl:comment>
  251. <xsl:copy-of select="*"/>
  252. </xsl:otherwise>
  253. </xsl:choose>
  254. </xsl:element>
  255. </xsl:template>
  256. <xsl:template match="schema" mode="system_cache__appinfo:get_all_xsd_external_schema" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  257. <xsl:param name="system_cache__appinfo:document-uri" required="yes"/>
  258. <xsl:variable name="targetNamespace" select="@targetNamespace"/>
  259. <xsl:variable name="namespaces_cur">
  260. <namespaces_cur>
  261. <xsl:for-each select="namespace::node()">
  262. <ns element="{name(..)}" prefix="{name()}" uri="{.}"/>
  263. </xsl:for-each>
  264. </namespaces_cur>
  265. </xsl:variable>
  266. <xsl:element name="schema" namespace="http://www.w3.org/2001/XMLSchema" extension-element-prefixes="#default" inherit-namespaces="yes">
  267. <xsl:choose>
  268. <xsl:when test="@targetNamespace and ( not($namespaces_cur//ns[@uri=$targetNamespace]/@prefix) or $namespaces_cur//ns[@uri=$targetNamespace]/@prefix='' ) " xpath-default-namespace="">
  269. <xsl:variable name="detect_prefix" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace_prefix($system_cache__appinfo:document-uri)"/>
  270. <xsl:namespace name="{$detect_prefix}" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace(@targetNamespace)"/>
  271. <xsl:copy-of select="@targetNamespace"/>
  272. <xsl:attribute name="vc:minVersion" select="'1.0'"/>
  273. <xsl:attribute name="vc:maxVersion" select="'1.1'"/>
  274. <xsl:comment>#144 when @targetNamespace exists and prefix not exists</xsl:comment>
  275. <xsl:comment>namespaces_cur/ns/@uri=<xsl:value-of select="$targetNamespace"/> = <xsl:value-of select="$namespaces_cur/namespaces_cur/ns[@uri=$targetNamespace]/@prefix"/> </xsl:comment>
  276. <xsl:comment> count: <xsl:value-of select="count($namespaces_cur/namespaces_cur/ns)"/> </xsl:comment>
  277. <!--<xsl:for-each select="$namespaces_cur/namespaces_cur/ns">
  278. <xsl:comment> ns @element=<xsl:value-of select="@element"/>; @prefix=<xsl:value-of select="@prefix"/>; @uri=<xsl:value-of select="@uri"/>;</xsl:comment>
  279. </xsl:for-each>-->
  280. <!-- <xs:debug>
  281. <xsl:copy-of select="$namespaces_cur"/>
  282. </xs:debug>
  283. <xs:debug_filter>
  284. <xsl:copy-of select="$namespaces_cur//ns[@uri=$targetNamespace]"/>
  285. </xs:debug_filter>
  286. <xs:debug_filter_NS>
  287. <xsl:copy-of select="$namespaces_cur//ns[@uri=$targetNamespace]" xpath-default-namespace=""/>
  288. </xs:debug_filter_NS>-->
  289. <xsl:apply-templates mode="system_cache__appinfo:get_all_xsd_external_schema_not_targetNamespace">
  290. <xsl:with-param name="detect_prefix" select="$detect_prefix"/>
  291. <xsl:with-param name="detect_targetNamespace" select="@targetNamespace"/>
  292. <xsl:with-param name="namespaces_cur" select="$namespaces_cur"/>
  293. </xsl:apply-templates>
  294. </xsl:when>
  295. <xsl:when test="@targetNamespace">
  296. <xsl:variable name="detect_prefix" select="$namespaces_cur//ns[@uri=$targetNamespace]/@prefix" xpath-default-namespace=""/>
  297. <xsl:namespace name="{$detect_prefix}" select="@targetNamespace"/>
  298. <xsl:copy-of select="@targetNamespace"/>
  299. <xsl:attribute name="vc:minVersion" select="'1.0'"/>
  300. <xsl:attribute name="vc:maxVersion" select="'1.1'"/>
  301. <xsl:comment>#147 when @targetNamespace and prefix probably exists!</xsl:comment>
  302. <!--<xsl:copy-of select="*" copy-namespaces="yes"/>-->
  303. <!--<xs:debug_test>
  304. <xsl:value-of select="$namespaces_cur//ns[@uri=$targetNamespace]/@prefix"/>
  305. </xs:debug_test>
  306. <xs:debug>
  307. <xsl:copy-of select="$namespaces_cur"/>
  308. </xs:debug>
  309. <xs:debug_filter>
  310. <xsl:copy-of select="$namespaces_cur//ns[@uri=$targetNamespace]"/>
  311. </xs:debug_filter>
  312. <xs:debug_filter_NS>
  313. <xsl:copy-of select="$namespaces_cur//ns[@uri=$targetNamespace]" xpath-default-namespace=""/>
  314. </xs:debug_filter_NS>-->
  315. <xsl:apply-templates mode="system_cache__appinfo:get_all_xsd_external_schema_with_prefix"/>
  316. </xsl:when>
  317. <xsl:otherwise>
  318. <xsl:variable name="detect_prefix" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace_prefix($system_cache__appinfo:document-uri)"/>
  319. <xsl:namespace name="{$detect_prefix}" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace($system_cache__appinfo:document-uri)"/>
  320. <xsl:attribute name="targetNamespace" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace($system_cache__appinfo:document-uri)"/>
  321. <xsl:attribute name="vc:minVersion" select="'1.0'"/>
  322. <xsl:attribute name="vc:maxVersion" select="'1.1'"/>
  323. <xsl:message>#35 detect. targetNamespace <xsl:value-of select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace($system_cache__appinfo:document-uri)"/></xsl:message>
  324. <xsl:comment>#158 otherwise not @targetNamespace and no prefix</xsl:comment>
  325. <xsl:apply-templates mode="system_cache__appinfo:get_all_xsd_external_schema_not_targetNamespace">
  326. <xsl:with-param name="detect_prefix" select="$detect_prefix"/>
  327. <xsl:with-param name="detect_targetNamespace" select="system_cache__appinfo:object_install_se_ant_object.detect_external_targetNamespace($system_cache__appinfo:document-uri)"/>
  328. <xsl:with-param name="namespaces_cur" select="$namespaces_cur"/>
  329. </xsl:apply-templates>
  330. </xsl:otherwise>
  331. </xsl:choose>
  332. </xsl:element>
  333. </xsl:template>
  334. <xsl:template match="*" mode="system_cache__appinfo:get_all_xsd_external_schema_with_prefix" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  335. <xsl:element name="{$XMLSchema_prefix}:{local-name()}" namespace="http://www.w3.org/2001/XMLSchema">
  336. <xsl:apply-templates select="@*" mode="system_cache__appinfo:get_all_xsd_external_schema_with_prefix"/>
  337. <xsl:apply-templates mode="system_cache__appinfo:get_all_xsd_external_schema_with_prefix"/>
  338. </xsl:element>
  339. </xsl:template>
  340. <xsl:template mode="system_cache__appinfo:get_all_xsd_external_schema_with_prefix" match="@type|@base">
  341. <!-- sa bledy ze schematami z prefix xsd... -->
  342. <xsl:choose>
  343. <xsl:when test="contains(.,'xsd:')">
  344. <xsl:attribute name="{name()}" select="concat($XMLSchema_prefix,':', system_cache__appinfo:clean_object_prefix(.))"/>
  345. </xsl:when>
  346. <xsl:otherwise>
  347. <xsl:attribute name="{name()}" select="."/>
  348. </xsl:otherwise>
  349. </xsl:choose>
  350. </xsl:template>
  351. <xsl:template mode="system_cache__appinfo:get_all_xsd_external_schema_with_prefix" match="@*">
  352. <xsl:attribute name="{name()}" select="."/>
  353. </xsl:template>
  354. <xsl:template match="*" mode="system_cache__appinfo:get_all_xsd_external_schema_not_targetNamespace" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  355. <xsl:param name="detect_prefix" required="yes"/>
  356. <xsl:param name="detect_targetNamespace" required="yes"/>
  357. <xsl:param name="namespaces_cur" required="yes"/>
  358. <xsl:element name="{$XMLSchema_prefix}:{local-name()}" namespace="http://www.w3.org/2001/XMLSchema">
  359. <!--<xsl:attribute name="test_prefix" select="system_cache__appinfo:prefix_from_targetNamespace($namespaces_cur,'http://www.w3.org/2001/XMLSchema')"/>-->
  360. <xsl:apply-templates mode="system_cache__appinfo:get_all_xsd_external_schema_not_targetNamespace" select="@*">
  361. <xsl:with-param name="detect_prefix" select="$detect_prefix"/>
  362. <xsl:with-param name="namespaces_cur" select="$namespaces_cur"/>
  363. </xsl:apply-templates>
  364. <xsl:apply-templates mode="system_cache__appinfo:get_all_xsd_external_schema_not_targetNamespace">
  365. <xsl:with-param name="detect_prefix" select="$detect_prefix"/>
  366. <xsl:with-param name="detect_targetNamespace" select="$detect_targetNamespace"/>
  367. <xsl:with-param name="namespaces_cur" select="$namespaces_cur"/>
  368. </xsl:apply-templates>
  369. </xsl:element>
  370. </xsl:template>
  371. <xsl:template mode="system_cache__appinfo:get_all_xsd_external_schema_not_targetNamespace" match="@type|@base">
  372. <!-- sa bledy ze schematami z prefix xsd... -->
  373. <xsl:param name="namespaces_cur" required="yes"/>
  374. <xsl:param name="detect_prefix" required="yes"/>
  375. <xsl:choose>
  376. <!--<xsl:when test="contains(.,'xsd:')">
  377. <xsl:attribute name="{name()}" select="concat($XMLSchema_prefix,':', system_cache__appinfo:clean_object_prefix(.))"/>
  378. </xsl:when>-->
  379. <xsl:when test="not(contains(.,':'))">
  380. <xsl:attribute name="{name()}" select="concat($detect_prefix,':',.)"/>
  381. </xsl:when>
  382. <xsl:when test="system_cache__appinfo:prefix_from_targetNamespace($namespaces_cur,'http://www.w3.org/2001/XMLSchema')=system_cache__appinfo:get_object_prefix(.)">
  383. <!--<xsl:message terminate="yes">#281 - wykryte ze jest to type XSD <xsl:value-of select="."/></xsl:message>-->
  384. <xsl:attribute name="{name()}" select="concat($XMLSchema_prefix,':', system_cache__appinfo:clean_object_prefix(.))"/>
  385. </xsl:when>
  386. <xsl:when test="contains(.,':')">
  387. <xsl:copy-of select="."/>
  388. </xsl:when>
  389. <xsl:otherwise>
  390. <xsl:message> #285 test : <xsl:value-of select="system_cache__appinfo:prefix_from_targetNamespace($namespaces_cur,'http://www.w3.org/2001/XMLSchema')"/> = <xsl:value-of select="system_cache__appinfo:get_object_prefix(.)"/> (<xsl:value-of select="."/>) ?</xsl:message>
  391. <xsl:attribute name="{name()}" select="concat($detect_prefix,':',.)"/>
  392. </xsl:otherwise>
  393. </xsl:choose>
  394. </xsl:template>
  395. <xsl:template mode="system_cache__appinfo:get_all_xsd_external_schema_not_targetNamespace" match="@ref">
  396. <xsl:param name="namespaces_cur" required="yes"/>
  397. <xsl:param name="detect_prefix" required="yes"/>
  398. <xsl:attribute name="{name()}" select="concat($detect_prefix,':',.)"/>
  399. </xsl:template>
  400. <xsl:template mode="system_cache__appinfo:get_all_xsd_external_schema_not_targetNamespace" match="@*">
  401. <xsl:param name="namespaces_cur" required="yes"/>
  402. <xsl:attribute name="{name()}" select="."/>
  403. </xsl:template><xsl:template name="system_cache__appinfo:get_all_xsd">
  404. <xsl:param name="path2collection" select="$procesy5_system_schema_collection_dir"/>
  405. <xsl:param name="get_system_schemas"/>
  406. <xsl:param name="cache" select="$cache"/>
  407. <xsl:variable name="element-filename" select="'procesy5_system_schema'"/>
  408. <xsl:choose>
  409. <xsl:when test="unparsed-text-available(concat('../default_db.instance.xml/transformed/',$element-filename,'.xml')) and $cache='read'">
  410. <xsl:copy-of select="doc(concat('../default_db.instance.xml/transformed/',$element-filename,'.xml'))"/>
  411. </xsl:when>
  412. <xsl:otherwise>
  413. <xsl:variable name="path">
  414. <xsl:value-of select="concat($path2collection,'?select=*.(xsd);recurse=yes;on-error=warning')"/>
  415. </xsl:variable>
  416. <xsl:variable name="docs" select="collection($path)"/>
  417. <xsl:variable name="procesy5_system_schema">
  418. <system_cache__appinfo:get_all_xsd_list>
  419. <xsl:for-each select="$docs">
  420. <xsl:message> get_all_xsd przetwarzam plik <xsl:value-of select="document-uri(/)"/></xsl:message>
  421. <xsl:choose>
  422. <xsl:when test=" contains(document-uri(/), concat($external_schema,'/'))">
  423. <xsl:comment>#145 Ignored /public_html/external_schema <xsl:value-of select="document-uri(/)"/></xsl:comment>
  424. <system_cache__appinfo:get_all_xsd_external_schema>
  425. <xsl:attribute name="system_cache__appinfo:document-uri" select="system_cache__appinfo:document-uri_for_external_schema_id_namespace_prefix(document-uri(/))"/>
  426. <xsl:attribute name="system_cache__appinfo:document-uri-full" select="system_cache__appinfo:document-uri-full_for_external_schema_id_namespace_prefix(document-uri(/))"/>
  427. <xsl:attribute name="system_cache__appinfo:document-uri-orig" select="substring-after(document-uri(/), $external_schema)"/>
  428. <!--<xsl:attribute name="system_cache__appinfo:document-uri-full-orig" select="document-uri(/)"/>-->
  429. <!--<xsl:for-each select="//schema" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  430. <xsl:element name="{name()}">
  431. <xsl:for-each select="@*">
  432. <xsl:attribute name="{name()}" select="."/>
  433. <xsl:copy-of select="child::node()"/>
  434. </xsl:for-each>
  435. </xsl:element>
  436. </xsl:for-each>-->
  437. <!--<xsl:copy-of select="/"/>-->
  438. <xsl:apply-templates mode="system_cache__appinfo:get_all_xsd_external_schema" select=".">
  439. <xsl:with-param name="system_cache__appinfo:document-uri" select="substring-after(document-uri(/), '/public_html/')"/>
  440. </xsl:apply-templates>
  441. </system_cache__appinfo:get_all_xsd_external_schema>
  442. </xsl:when>
  443. <xsl:when test=" contains(document-uri(/), concat($external_schema_id_namespace_prefix,'/'))">
  444. <xsl:comment>#248 Ignored /public_html/external_schema_id_namespace_prefix <xsl:value-of select="document-uri(/)"/></xsl:comment>
  445. <system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix>
  446. <xsl:attribute name="system_cache__appinfo:document-uri" select="substring-after(document-uri(/), '/public_html/')"/>
  447. <xsl:attribute name="system_cache__appinfo:document-uri-full" select="document-uri(/)"/>
  448. <xsl:attribute name="system_cache__appinfo:document-uri-orig" select="substring-after(document-uri(/), $external_schema_id_namespace_prefix)"/>
  449. <!--<xsl:for-each select="//schema" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  450. <xsl:element name="{name()}">
  451. <xsl:for-each select="@*">
  452. <xsl:attribute name="{name()}" select="."/>
  453. <xsl:copy-of select="child::node()"/>
  454. </xsl:for-each>
  455. </xsl:element>
  456. </xsl:for-each>-->
  457. <!--<xsl:copy-of select="/"/>-->
  458. <xsl:apply-templates mode="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" select=".">
  459. <xsl:with-param name="system_cache__appinfo:document-uri" select="substring-after(document-uri(/), '/public_html/')"/>
  460. </xsl:apply-templates>
  461. </system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix>
  462. </xsl:when>
  463. <xsl:otherwise><system_cache__appinfo:get_all_xsd>
  464. <xsl:attribute name="system_cache__appinfo:document-uri" select="substring-after(document-uri(/), '/public_html/')"/>
  465. <xsl:attribute name="system_cache__appinfo:document-uri-full" select="document-uri(/)"/>
  466. <!--<xsl:for-each select="//schema" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  467. <xsl:element name="{name()}">
  468. <xsl:for-each select="@*">
  469. <xsl:attribute name="{name()}" select="."/>
  470. <xsl:copy-of select="child::node()"/>
  471. </xsl:for-each>
  472. </xsl:element>
  473. </xsl:for-each>-->
  474. <xsl:copy-of select="/"/>
  475. </system_cache__appinfo:get_all_xsd>
  476. </xsl:otherwise>
  477. </xsl:choose></xsl:for-each>
  478. <!-- -->
  479. <xsl:message> schemat dla XML primitives <xsl:value-of select="'http://www.w3.org/1999/XSL/Transform'"/></xsl:message>
  480. <system_cache__appinfo:get_all_xsd>
  481. <xsl:attribute name="system_cache__appinfo:document-uri" select="'http://www.w3.org/1999/XSL/Transform'"/>
  482. <xsl:attribute name="system_cache__appinfo:document-uri-full" select="'http://www.w3.org/1999/XSL/Transform'"/>
  483. <xsl:copy-of select="$system_cache__appinfo:primitives.xsd"/>
  484. </system_cache__appinfo:get_all_xsd>
  485. <xsl:message> schemat dla XML primitives/derived <xsl:value-of select="'http://www.w3.org/1999/XSL/Transform'"/></xsl:message>
  486. <system_cache__appinfo:get_all_xsd>
  487. <xsl:attribute name="system_cache__appinfo:document-uri" select="'http://www.w3.org/1999/XSL/Transform'"/>
  488. <xsl:attribute name="system_cache__appinfo:document-uri-full" select="'http://www.w3.org/1999/XSL/Transform'"/>
  489. <xsl:copy-of select="$system_cache__appinfo:derived.xsd"/>
  490. </system_cache__appinfo:get_all_xsd>
  491. <system_cache__appinfo:get_all_xsd>
  492. <xsl:attribute name="system_cache__appinfo:document-uri" select="'http://www.w3.org/1999/XSL/Transform'"/>
  493. <xsl:attribute name="system_cache__appinfo:document-uri-full" select="'http://www.w3.org/1999/XSL/Transform'"/>
  494. <xsl:copy-of select="$system_cache__appinfo:XMLSchema11.xsd"/>
  495. </system_cache__appinfo:get_all_xsd>
  496. <system_cache__appinfo:get_all_xsd>
  497. <xsl:attribute name="system_cache__appinfo:document-uri" select="'http://www.w3.org/1999/XSL/Transform'"/>
  498. <xsl:attribute name="system_cache__appinfo:document-uri-full" select="'http://www.w3.org/1999/XSL/Transform'"/>
  499. <xsl:copy-of select="$system_cache__appinfo:builtintypes.xsd"/>
  500. </system_cache__appinfo:get_all_xsd>
  501. </system_cache__appinfo:get_all_xsd_list>
  502. </xsl:variable>
  503. <!--<xsl:result-document href="{concat('../default_db.instance.xml/transformed/',$element-filename,'.xml')}">
  504. <xsl:copy-of select="$procesy5_system_schema"/>
  505. </xsl:result-document>-->
  506. <xsl:copy-of select="$procesy5_system_schema"></xsl:copy-of>
  507. </xsl:otherwise>
  508. </xsl:choose>
  509. </xsl:template>
  510. <xsl:template match="system_cache__appinfo:get_all_xsd_list" mode="system_cache__appinfo:vrtfNamespaces">
  511. <system_cache__appinfo:vrtfNamespaces>
  512. <xsl:for-each select="//(system_cache__appinfo:get_all_xsd|system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix)/schema/namespace::node()"
  513. xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  514. <ns element="{name(..)}" prefix="{name()}" uri="{.}" system_cache__appinfo:document-uri="{../@system_cache__appinfo:document-uri}"/>
  515. </xsl:for-each>
  516. </system_cache__appinfo:vrtfNamespaces>
  517. </xsl:template>
  518. <xsl:template match="system_cache__appinfo:get_all_xsd_list" mode="system_cache__appinfo:element_complexType">
  519. <xsl:param name="targetNamespace" select="$targetNamespace_DEFAULTS"/>
  520. <system_cache__appinfo:element_complexType>
  521. <xsl:for-each select="get_all_xsd[ substring-before(@system_cache__appinfo:document-uri,'/')!='default_db_xml_cache' and substring-before(@system_cache__appinfo:document-uri,'/')!='default_db_xml_cache.public']" xpath-default-namespace="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd">
  522. <xsl:variable name="get_all_xsd_236" select="."/>
  523. <xsl:comment>
  524. 246:detect_resource_type, przetwarzam schemat:<xsl:value-of select="@system_cache__appinfo:document-uri"/>; $targetNamespace:<xsl:value-of select="$targetNamespace"/>;
  525. @targetNamespace:<xsl:value-of select="schema/@targetNamespace" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>;</xsl:comment>
  526. <xsl:variable name="schema_node_144" select="."/>
  527. <xsl:for-each select="schema" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"><!--[ @targetNamespace != $targetNamespace ] namespace::node() = $targetNamespace and @targetNamespace='moj_ogrodek' -->
  528. <xsl:message>239::detect_resource_type przetwarzam schemat:@targetNamespace:<xsl:value-of select="@targetNamespace"/>;</xsl:message>
  529. <xsl:variable name="prefix_83" select="namespace::node()[. = $targetNamespace]/name()"/>
  530. <xsl:variable name="targetNamespace_134" select="@targetNamespace"/>
  531. <xsl:variable name="prefix_134" select="namespace::node()[. = $targetNamespace_134][1]/name()"/><!-- np. test_objects -->
  532. <xsl:if test="not(@targetNamespace) or not($prefix_134) ">
  533. <xsl:message terminate="yes">#394 ERROR - schema error - set @targetNamespace and prefix for shema file:<xsl:value-of select="../@system_cache__appinfo:document-uri-full"/> ; </xsl:message>
  534. </xsl:if>
  535. <xsl:if test="count(.//node()[(local-name()='element' or local-name()='complexType' or local-name()='sequence' or local-name()='choice' or local-name()='complexContent' or local-name()='extension' ) and not(@id)])=0">
  536. <xsl:for-each select="(element|complexType)" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"><!-- dla ograniczenia mozna [$prefix_134='test_objects']-->
  537. <xsl:variable name="complexType_or_element_name186">
  538. <xsl:choose>
  539. <xsl:when test="local-name()='element'"><xsl:value-of select="@name"/></xsl:when>
  540. <xsl:when test="local-name()='complexType'"><xsl:value-of select="@name"/></xsl:when>
  541. <xsl:otherwise><xsl:message terminate="yes">#391 it should work only for element or complexType</xsl:message></xsl:otherwise>
  542. </xsl:choose>
  543. </xsl:variable>
  544. <xsl:comment>157: buduje plaski obiekt/mape przetwarzania w celu przeszukania relacji @id:<xsl:value-of select="@id"/>; targetNamespace:<xsl:value-of select="$prefix_134"/>; $complexType_or_element_name186:<xsl:value-of select="$complexType_or_element_name186"/>; name:<xsl:value-of select="@name"/>; namespace-uri-for-prefix:<xsl:value-of select="namespace-uri-for-prefix($prefix_134,.)"/></xsl:comment>
  545. <xsl:message>157: buduje plaski obiekt/mape przetwarzania w celu przeszukania relacji @id:<xsl:value-of select="@id"/>; targetNamespace:<xsl:value-of select="$prefix_134"/>; $complexType_or_element_name186:<xsl:value-of select="$complexType_or_element_name186"/>; name:<xsl:value-of select="@name"/>; namespace-uri-for-prefix:<xsl:value-of select="namespace-uri-for-prefix($prefix_134,.)"/></xsl:message>
  546. <xsl:choose>
  547. <xsl:when test="local-name()='element'">
  548. <build_cache name="build_element">
  549. <with-param name="element" select="{$prefix_134}:{$complexType_or_element_name186}"/>
  550. </build_cache>
  551. </xsl:when>
  552. <xsl:when test="local-name()='complexType'">
  553. <build_cache name="build_complexType">
  554. <with-param name="complexType"
  555. select="{$prefix_134}:{$complexType_or_element_name186}"/>
  556. </build_cache>
  557. </xsl:when>
  558. </xsl:choose>
  559. </xsl:for-each>
  560. </xsl:if>
  561. </xsl:for-each>
  562. </xsl:for-each>
  563. </system_cache__appinfo:element_complexType>
  564. </xsl:template>
  565. <!-- do aktualizowania pozycji w schemache-->
  566. <xsl:template name="system_cache__appinfo:position">
  567. <xsl:param name="xml"/>
  568. <xsl:for-each select="$xml/*">
  569. <xsl:if test="name()">
  570. <xsl:element name="{name()}">
  571. <xsl:attribute name="system_cache__appinfo:position" select="position()"/>
  572. <xsl:apply-templates mode="system_cache__appinfo:position" select="@*"/>
  573. <xsl:call-template name="system_cache__appinfo:position">
  574. <xsl:with-param name="xml" select="."/>
  575. </xsl:call-template>
  576. </xsl:element>
  577. </xsl:if>
  578. </xsl:for-each>
  579. </xsl:template>
  580. <xsl:template match="@*" mode="system_cache__appinfo:position">
  581. <xsl:attribute name="{name()}" select="."/>
  582. </xsl:template>
  583. <xsl:template match="text()" mode="system_cache__appinfo:position"/>
  584. <xsl:template match="comment()" mode="system_cache__appinfo:position"/>
  585. </xsl:stylesheet>