xsd_to_objects_mysql.xsl 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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:exslt="http://exslt.org/common"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xmlns:system_cache__procesy5_xsd_business_objects="http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/procesy5_xsd_business_objects.xsd"
  7. exclude-result-prefixes="xs exslt"
  8. version="2.0">
  9. <!-- @2017 02 bindera: do weryfikacji do czego to jest potrzebne -->
  10. <!-- @2015-02-29 - proba testowej transormacji w celu stworzenia zapytan do tworzenia tabel,relacji,widokow na podstawie xsd -->
  11. <xsl:output omit-xml-declaration="no" method="xml" indent="yes" xml:space="default"/>
  12. <xsl:template name="get_all_xsd">
  13. <xsl:param name="path2collection">../public_html/</xsl:param>
  14. <xsl:variable name="path">
  15. <xsl:value-of select="concat('../',$path2collection,'?select=*.(xsd);recurse=yes;on-error=warning')"/>
  16. </xsl:variable>
  17. <xsl:variable name="docs" select="collection($path)"/>
  18. <xsl:for-each select="$docs">
  19. <xsl:message> get_all_xsd przetwarzam plik <xsl:value-of select="document-uri(/)"/></xsl:message>
  20. <xsl:copy-of select="/"/>
  21. </xsl:for-each>
  22. </xsl:template>
  23. <xsl:template name="main" >
  24. <xsl:variable name="get_all_xsd">
  25. <xsl:call-template name="get_all_xsd"/>
  26. </xsl:variable>
  27. <xsl:variable name="namespaces_imports">
  28. <xsl:for-each select="exslt:node-set($get_all_xsd)">
  29. <xsl:message>Uruchamiam apply templates dla calej zmiennej ze wszystkimi plikami - tam sa juz xs:schema </xsl:message>
  30. <xsl:apply-templates/>
  31. </xsl:for-each>
  32. </xsl:variable>
  33. <xsl:variable name="namespace_record_to_import">
  34. <xsl:for-each select="exslt:node-set($namespaces_imports/namespace_record_import)">
  35. <xsl:variable name="namespace_test" select="namespace"/>
  36. <xsl:message>W importach <xsl:value-of select="document-uri(.)"/>wystapil namespace : <xsl:value-of select="namespace"/> . Sprawdzamy czy wystepowal w TargetNameSpace</xsl:message>
  37. <xsl:variable name="ckk_if_import_exists" select="''"/>
  38. <xsl:variable name="ckk_if_import_exists">
  39. <xsl:comment>Szukam dla <xsl:value-of select="namespace"/></xsl:comment>
  40. <xsl:for-each select="exslt:node-set($namespaces_imports/namespace_record[namespace=$namespace_test])">
  41. <xsl:value-of select="namespace"/>
  42. </xsl:for-each>
  43. </xsl:variable>
  44. <xsl:choose>
  45. <xsl:when test="$ckk_if_import_exists=''">
  46. <xsl:message> - nie występował - tworzę namespace_record_to_import z namespace<xsl:value-of select="$namespace_test"/> i schemaLocation <xsl:value-of select="schemaLocation"/> </xsl:message>
  47. <namespace_record_to_import>
  48. <namespace>
  49. <xsl:value-of select="$namespace_test"/>
  50. </namespace>
  51. <schemaLocation>
  52. <xsl:value-of select="schemaLocation"/>
  53. </schemaLocation>
  54. <Parent_targetNamespace>
  55. <xsl:value-of select="Parent_targetNamespace"/>
  56. </Parent_targetNamespace>
  57. </namespace_record_to_import>
  58. </xsl:when>
  59. <!-- <xsl:otherwise>
  60. <NO_IMPORT_TODO><xsl:value-of select="$ckk_if_import_exists"/></NO_IMPORT_TODO>
  61. </xsl:otherwise>
  62. -->
  63. </xsl:choose>
  64. </xsl:for-each>
  65. </xsl:variable>
  66. <xsl:variable name="namespace_records">
  67. <xsl:for-each select="exslt:node-set($namespaces_imports/namespace_record)">
  68. <xsl:copy-of select="."/>
  69. </xsl:for-each>
  70. </xsl:variable>
  71. <xsl:call-template name="import_external">
  72. <xsl:with-param name="namespace_records" select="$namespace_records"/>
  73. <xsl:with-param name="namespace_record_to_import" select="$namespace_record_to_import"/>
  74. </xsl:call-template>
  75. <!-- wykrycie pojedynczych namespaces -->
  76. <xsl:variable name="uniq_namespaces">
  77. <xsl:for-each-group select="exslt:node-set($namespace_records)/namespace_record" group-by="namespace" xml:space="default">
  78. <namespace><xsl:value-of select="namespace"/></namespace>
  79. </xsl:for-each-group>
  80. </xsl:variable>
  81. <!-- teraz generujemy obiekty do php -->
  82. <xsl:comment>Test wyzwolenia pojedycznego resorce</xsl:comment>
  83. <xsl:element name="system_cache__procesy5_xsd_business_objects:resources">
  84. <xsl:attribute name="xsi:schemaLocation" select="'http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/procesy5_xsd_business_objects.xsd ../system_cache/procesy5_xsd_business_objects.xsd'"/>
  85. <!-- <xsl:for-each select="exslt:node-set($uniq_namespaces/namespace[.='http://biuro.biall-net.pl/xmlschema_procesy5/default_objects/projects.xsd' or .='http://biuro.biall-net.pl/xmlschema_procesy5/default_db/IN7_MK_BAZA_DYSTRYBUCJIxxx'])"> -->
  86. <xsl:for-each select="exslt:node-set($uniq_namespaces/namespace)">
  87. <!-- <xsl:for-each select="exslt:node-set($uniq_namespaces/namespace)"> -->
  88. <xsl:variable name="current_namespace" select="."/>
  89. <xsl:comment>Jedziemy root <xsl:value-of select="$current_namespace"/></xsl:comment>
  90. <xsl:for-each select="exslt:node-set($get_all_xsd/schema[@targetNamespace=$current_namespace[1]])" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  91. <xsl:comment>.. jedziemy next... </xsl:comment>
  92. <xsl:variable name="targetNamespace">
  93. <xsl:for-each select="attribute::node()[name()='targetNamespace']">
  94. <xsl:value-of select="."/>
  95. </xsl:for-each>
  96. </xsl:variable>
  97. <xsl:variable name="prefix">
  98. <xsl:for-each select="namespace::node()[.=$targetNamespace]">
  99. <xsl:value-of select="name()"/>
  100. </xsl:for-each>
  101. </xsl:variable>
  102. <!-- <targetNamespace><xsl:value-of select="$targetNamespace"/></targetNamespace>
  103. <prefix><xsl:value-of select="$prefix"/></prefix>
  104. <namespace-uri><xsl:value-of select="namespace-uri(.)"/></namespace-uri>-->
  105. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  106. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="$prefix"/></xsl:element>
  107. <system_cache__procesy5_xsd_business_objects:resource_type><system_cache__procesy5_xsd_business_objects:prefix/></system_cache__procesy5_xsd_business_objects:resource_type>
  108. <system_cache__procesy5_xsd_business_objects:resource_parent_id>root</system_cache__procesy5_xsd_business_objects:resource_parent_id>
  109. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="$prefix"/></system_cache__procesy5_xsd_business_objects:path>
  110. </xsl:element>
  111. <xsl:apply-templates mode="php" select="." xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  112. <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
  113. <xsl:with-param name="prefix" select="$prefix"/>
  114. <xsl:with-param name="prefix_path" select="$prefix"/>
  115. </xsl:apply-templates>
  116. <xsl:copy-of select="xxx" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>
  117. </xsl:for-each>
  118. </xsl:for-each>
  119. </xsl:element>
  120. <xsl:comment>EOF Test wyzwolenia pojedycznego resorce</xsl:comment>
  121. <xsl:comment>testowe wyswietlenie wszystkiego</xsl:comment>
  122. <xsl:for-each select="exslt:node-set($get_all_xsd)/REM_ME_TODO" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  123. <xsl:copy-of select="/"/>
  124. </xsl:for-each>
  125. </xsl:template>
  126. <xsl:template match="text()" mode="php">
  127. <!--<xsl:comment><xsl:value-of select="."/></xsl:comment>-->
  128. </xsl:template>
  129. <xsl:template match="attribute" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  130. <xsl:param name="targetNamespace"/>
  131. <xsl:param name="prefix"/>
  132. <xsl:param name="prefix_path"/>
  133. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  134. <xsl:choose>
  135. <xsl:when test="@name">
  136. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name">
  137. <xsl:value-of select="concat(@name,'::attribute')"/>
  138. </xsl:element>
  139. <system_cache__procesy5_xsd_business_objects:resource_type>
  140. <system_cache__procesy5_xsd_business_objects:attribute>
  141. <xsl:if test="@type">
  142. <system_cache__procesy5_xsd_business_objects:alias_id><xsl:value-of select="@type"/></system_cache__procesy5_xsd_business_objects:alias_id>
  143. </xsl:if>
  144. </system_cache__procesy5_xsd_business_objects:attribute>
  145. </system_cache__procesy5_xsd_business_objects:resource_type>
  146. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  147. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/',@name,'::attribute')"/></system_cache__procesy5_xsd_business_objects:path>
  148. </xsl:when>
  149. <xsl:when test="@ref">
  150. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="concat(@ref,'::attribute')"/>
  151. <system_cache__procesy5_xsd_business_objects:resource_type>
  152. <system_cache__procesy5_xsd_business_objects:attribute>
  153. <system_cache__procesy5_xsd_business_objects:alias_id><xsl:value-of select="@ref"/></system_cache__procesy5_xsd_business_objects:alias_id>
  154. </system_cache__procesy5_xsd_business_objects:attribute>
  155. </system_cache__procesy5_xsd_business_objects:resource_type>
  156. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  157. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/',@ref,'::attribute')"/></system_cache__procesy5_xsd_business_objects:path>
  158. </xsl:element>
  159. </xsl:when>
  160. <xsl:otherwise>
  161. <xsl:comment>ERROR - transformation needs another condition</xsl:comment>
  162. </xsl:otherwise>
  163. </xsl:choose>
  164. </xsl:element>
  165. </xsl:template>
  166. <xsl:template match="attributeGroup" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  167. <xsl:param name="targetNamespace"/>
  168. <xsl:param name="prefix"/>
  169. <xsl:param name="prefix_path"/>
  170. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  171. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="@name"/></xsl:element>
  172. <system_cache__procesy5_xsd_business_objects:resource_type>
  173. <system_cache__procesy5_xsd_business_objects:attributeGroup>
  174. <xsl:if test="@ref">
  175. <system_cache__procesy5_xsd_business_objects:alias_id><xsl:value-of select="@ref"/></system_cache__procesy5_xsd_business_objects:alias_id>
  176. </xsl:if>
  177. </system_cache__procesy5_xsd_business_objects:attributeGroup>
  178. </system_cache__procesy5_xsd_business_objects:resource_type>
  179. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  180. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/',@name,'::attributeGroup')"/></system_cache__procesy5_xsd_business_objects:path>
  181. </xsl:element>
  182. <xsl:apply-templates mode="php" select="attribute" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  183. <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
  184. <xsl:with-param name="prefix" select="$prefix"/>
  185. <xsl:with-param name="prefix_path" select="concat($prefix_path,'/',@name,'::attributeGroup')"/>
  186. </xsl:apply-templates>
  187. </xsl:template>
  188. <xsl:template match="complexType" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  189. <xsl:param name="targetNamespace"/>
  190. <xsl:param name="prefix"/>
  191. <xsl:param name="prefix_path"/>
  192. <xsl:variable name="ds">
  193. <xsl:choose>
  194. <xsl:when test="$prefix=$prefix_path"><xsl:value-of select="':'"/></xsl:when>
  195. <xsl:otherwise><xsl:value-of select="'/'"/></xsl:otherwise>
  196. </xsl:choose>
  197. </xsl:variable>
  198. <xsl:variable name="name_val">
  199. <xsl:choose>
  200. <xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
  201. <xsl:otherwise><xsl:value-of select="'complexType'"/></xsl:otherwise>
  202. </xsl:choose>
  203. </xsl:variable>
  204. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  205. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="$name_val"/></xsl:element>
  206. <system_cache__procesy5_xsd_business_objects:resource_type>
  207. <system_cache__procesy5_xsd_business_objects:complexType/>
  208. </system_cache__procesy5_xsd_business_objects:resource_type>
  209. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  210. <xsl:if test="@type">
  211. <system_cache__procesy5_xsd_business_objects:alias_id><xsl:value-of select="@type"/></system_cache__procesy5_xsd_business_objects:alias_id>
  212. </xsl:if>
  213. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,$ds,$name_val)"/></system_cache__procesy5_xsd_business_objects:path>
  214. <xsl:if test="annotation/documentation">
  215. <xsl:call-template name="documentation" >
  216. <xsl:with-param name="documentation" select="annotation/documentation"/>
  217. </xsl:call-template>
  218. </xsl:if>
  219. </xsl:element>
  220. <xsl:if test="@type"><type><xsl:value-of select="@type"/></type></xsl:if>
  221. <xsl:apply-templates mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  222. <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
  223. <xsl:with-param name="prefix" select="$prefix"/>
  224. <xsl:with-param name="prefix_path" select="concat($prefix_path,$ds,$name_val)"/>
  225. </xsl:apply-templates>
  226. </xsl:template>
  227. <xsl:template name="documentation" >
  228. <xsl:param name="documentation"/>
  229. <system_cache__procesy5_xsd_business_objects:annotation_documentation>
  230. <xsl:for-each select="$documentation">
  231. <xsl:value-of select='replace(.,"&apos;","^")'/>
  232. </xsl:for-each>
  233. </system_cache__procesy5_xsd_business_objects:annotation_documentation>
  234. </xsl:template>
  235. <xsl:template match="complexContent" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  236. <xsl:param name="targetNamespace"/>
  237. <xsl:param name="prefix"/>
  238. <xsl:param name="prefix_path"/>
  239. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  240. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name">
  241. <xsl:choose>
  242. <xsl:when test="@name">
  243. <xsl:value-of select="@name"/>
  244. </xsl:when>
  245. <xsl:otherwise>
  246. <xsl:value-of select="concat($prefix_path,'/complexContent')"/>
  247. </xsl:otherwise>
  248. </xsl:choose>
  249. </xsl:element>
  250. <system_cache__procesy5_xsd_business_objects:resource_type>
  251. <system_cache__procesy5_xsd_business_objects:complexContent>
  252. <xsl:if test="@mixed"><xsl:element name="system_cache__procesy5_xsd_business_objects:mixed"><xsl:value-of select="@mixed"/></xsl:element></xsl:if>
  253. </system_cache__procesy5_xsd_business_objects:complexContent>
  254. </system_cache__procesy5_xsd_business_objects:resource_type>
  255. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  256. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/','complexContent')"/></system_cache__procesy5_xsd_business_objects:path>
  257. </xsl:element>
  258. <xsl:apply-templates mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  259. <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
  260. <xsl:with-param name="prefix" select="$prefix"/>
  261. <xsl:with-param name="prefix_path" select="concat($prefix_path,'/','complexContent')"/>
  262. </xsl:apply-templates>
  263. </xsl:template>
  264. <xsl:template match="simpleType" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  265. <xsl:param name="targetNamespace"/>
  266. <xsl:param name="prefix"/>
  267. <xsl:param name="prefix_path"/>
  268. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  269. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="concat(@name,'::simpleType')"/></xsl:element>
  270. <system_cache__procesy5_xsd_business_objects:resource_type>
  271. <system_cache__procesy5_xsd_business_objects:simpleType>
  272. <xsl:if test="@type">
  273. <system_cache__procesy5_xsd_business_objects:alias_id><xsl:value-of select="@type"/></system_cache__procesy5_xsd_business_objects:alias_id>
  274. </xsl:if>
  275. </system_cache__procesy5_xsd_business_objects:simpleType>
  276. </system_cache__procesy5_xsd_business_objects:resource_type>
  277. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  278. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/',@name,'::simpleType')"/></system_cache__procesy5_xsd_business_objects:path>
  279. </xsl:element>
  280. <xsl:apply-templates mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  281. <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
  282. <xsl:with-param name="prefix" select="$prefix"/>
  283. <xsl:with-param name="prefix_path" select="concat($prefix_path,'/','complexContent')"/>
  284. </xsl:apply-templates>
  285. </xsl:template>
  286. <xsl:template match="minInclusive|maxInclusive|enumeration|length|maxLength|minExclusive|maxExclusive|minLength|pattern|totalDigits|whiteSpace" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  287. <xsl:param name="targetNamespace"/>
  288. <xsl:param name="prefix"/>
  289. <xsl:param name="prefix_path"/>
  290. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  291. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="local-name()"/></xsl:element>
  292. <system_cache__procesy5_xsd_business_objects:resource_type>
  293. <xsl:element name="{concat('system_cache__procesy5_xsd_business_objects:',local-name())}">
  294. <xsl:if test="@value">
  295. <system_cache__procesy5_xsd_business_objects:value><xsl:value-of select="@value"/></system_cache__procesy5_xsd_business_objects:value>
  296. </xsl:if>
  297. <xsl:if test="@fixed">
  298. <system_cache__procesy5_xsd_business_objects:fixed><xsl:value-of select="@fixed"/></system_cache__procesy5_xsd_business_objects:fixed>
  299. </xsl:if>
  300. </xsl:element>
  301. </system_cache__procesy5_xsd_business_objects:resource_type>
  302. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  303. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/',local-name())"/></system_cache__procesy5_xsd_business_objects:path>
  304. </xsl:element>
  305. </xsl:template>
  306. <xsl:template match="restriction" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  307. <xsl:param name="targetNamespace"/>
  308. <xsl:param name="prefix"/>
  309. <xsl:param name="prefix_path"/>
  310. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  311. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="'restriction'"/></xsl:element>
  312. <system_cache__procesy5_xsd_business_objects:resource_type>
  313. <system_cache__procesy5_xsd_business_objects:restriction>
  314. <xsl:if test="@base">
  315. <system_cache__procesy5_xsd_business_objects:alias_id><xsl:value-of select="@base"/></system_cache__procesy5_xsd_business_objects:alias_id>
  316. </xsl:if>
  317. </system_cache__procesy5_xsd_business_objects:restriction>
  318. </system_cache__procesy5_xsd_business_objects:resource_type>
  319. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  320. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/','restriction')"/></system_cache__procesy5_xsd_business_objects:path>
  321. </xsl:element>
  322. <xsl:apply-templates mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  323. <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
  324. <xsl:with-param name="prefix" select="$prefix"/>
  325. <xsl:with-param name="prefix_path" select="concat($prefix_path,'/','restriction')"/>
  326. </xsl:apply-templates>
  327. </xsl:template>
  328. <xsl:template match="choice" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  329. <xsl:param name="targetNamespace"/>
  330. <xsl:param name="prefix"/>
  331. <xsl:param name="prefix_path"/>
  332. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  333. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="'choice'"/></xsl:element>
  334. <system_cache__procesy5_xsd_business_objects:resource_type>
  335. <system_cache__procesy5_xsd_business_objects:choice>
  336. <xsl:if test="@minOccurs"><xsl:element name="system_cache__procesy5_xsd_business_objects:minOccurs"><xsl:value-of select="@minOccurs"/></xsl:element> </xsl:if>
  337. <xsl:if test="@maxOccurs"><xsl:element name="system_cache__procesy5_xsd_business_objects:maxOccurs"><xsl:value-of select="@maxOccurs"/></xsl:element></xsl:if>
  338. </system_cache__procesy5_xsd_business_objects:choice>
  339. </system_cache__procesy5_xsd_business_objects:resource_type>
  340. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  341. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/','choice')"/></system_cache__procesy5_xsd_business_objects:path>
  342. </xsl:element>
  343. <xsl:apply-templates mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  344. <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
  345. <xsl:with-param name="prefix" select="$prefix"/>
  346. <xsl:with-param name="prefix_path" select="concat($prefix_path,'/','choice')"/>
  347. </xsl:apply-templates>
  348. </xsl:template>
  349. <xsl:template match="sequence" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  350. <xsl:param name="targetNamespace"/>
  351. <xsl:param name="prefix"/>
  352. <xsl:param name="prefix_path"/>
  353. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  354. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="'sequence'"/></xsl:element>
  355. <system_cache__procesy5_xsd_business_objects:resource_type>
  356. <system_cache__procesy5_xsd_business_objects:sequence>
  357. <xsl:if test="@minOccurs"><xsl:element name="system_cache__procesy5_xsd_business_objects:minOccurs"><xsl:value-of select="@minOccurs"/></xsl:element> </xsl:if>
  358. <xsl:if test="@maxOccurs"><xsl:element name="system_cache__procesy5_xsd_business_objects:maxOccurs"><xsl:value-of select="@maxOccurs"/></xsl:element></xsl:if>
  359. </system_cache__procesy5_xsd_business_objects:sequence>
  360. </system_cache__procesy5_xsd_business_objects:resource_type>
  361. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  362. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/','sequence')"/></system_cache__procesy5_xsd_business_objects:path>
  363. </xsl:element>
  364. <xsl:apply-templates mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  365. <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
  366. <xsl:with-param name="prefix" select="$prefix"/>
  367. <xsl:with-param name="prefix_path" select="concat($prefix_path,'/','sequence')"/>
  368. </xsl:apply-templates>
  369. </xsl:template>
  370. <xsl:template match="element" mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  371. <xsl:param name="targetNamespace"/>
  372. <xsl:param name="prefix"/>
  373. <xsl:param name="prefix_path"/>
  374. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource">
  375. <xsl:element name="system_cache__procesy5_xsd_business_objects:resource_name"><xsl:value-of select="@name"/></xsl:element>
  376. <system_cache__procesy5_xsd_business_objects:resource_type>
  377. <system_cache__procesy5_xsd_business_objects:element>
  378. <xsl:if test="@type">
  379. <system_cache__procesy5_xsd_business_objects:alias_id><xsl:value-of select="@type"/></system_cache__procesy5_xsd_business_objects:alias_id>
  380. </xsl:if>
  381. </system_cache__procesy5_xsd_business_objects:element>
  382. </system_cache__procesy5_xsd_business_objects:resource_type>
  383. <system_cache__procesy5_xsd_business_objects:resource_parent_id><xsl:value-of select="$prefix_path"/></system_cache__procesy5_xsd_business_objects:resource_parent_id>
  384. <system_cache__procesy5_xsd_business_objects:path><xsl:value-of select="concat($prefix_path,'/',@name)"/></system_cache__procesy5_xsd_business_objects:path>
  385. </xsl:element>
  386. <xsl:apply-templates mode="php" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  387. <xsl:with-param name="targetNamespace" select="$targetNamespace"/>
  388. <xsl:with-param name="prefix" select="$prefix"/>
  389. <xsl:with-param name="prefix_path" select="concat($prefix_path,'/','element')"/>
  390. </xsl:apply-templates>
  391. </xsl:template>
  392. <!-- funkcja do sciagania zewnetrznych schema
  393. musi znac liste juz includowanych targetnamespaces, aby ich nie importowac
  394. musi po kazdym imporcie dodawac do listy zaimportowanych schematow defaultnamespace, aby nie bylo petli
  395. -->
  396. <xsl:template name="import_external">
  397. <xsl:param name="namespace_records"/>
  398. <xsl:param name="namespace_record_to_import"/>
  399. <xsl:for-each-group select="$namespace_record_to_import/namespace_record_to_import" group-by="schemaLocation">
  400. <xsl:message>wyzwalam call-template retrieve_single_import parametr loc,namespace: <xsl:value-of select="concat(schemaLocation,',',namespace)"/></xsl:message>
  401. <xsl:call-template name="retrieve_single_import">
  402. <xsl:with-param name="schemaLocation" select="schemaLocation"/>
  403. <xsl:with-param name="namespace" select="namespace"/>
  404. <xsl:with-param name="Parent_targetNamespace" select="Parent_targetNamespace"/>
  405. <xsl:with-param name="namespace_records" select="namespace_records"/>
  406. </xsl:call-template>
  407. </xsl:for-each-group>
  408. </xsl:template>
  409. <!-- template do odczytania pojedynczego schematu na podstawie URLa -->
  410. <xsl:template name="retrieve_single_import">
  411. <xsl:param name="schemaLocation"></xsl:param>
  412. <xsl:param name="namespace"></xsl:param>
  413. <xsl:param name="Parent_targetNamespace"></xsl:param>
  414. <xsl:param name="namespace_records"></xsl:param>
  415. <xsl:message>Importuje schemat namespace z uri: <xsl:value-of select="$schemaLocation"/> parent was <xsl:value-of select="Parent_targetNamespace"/> </xsl:message>
  416. <!-- todo nalezy sprawdizc po parent_TargetNameSpace - co go importowalo i z jakiego urla - z takiego URLa trzeba dociagnac teraz plik xsd, trzeba sprawdzic czy jest tam referencja lokalna -->
  417. <xsl:choose>
  418. <xsl:when test="contains($schemaLocation,'http')">
  419. <xsl:message> schema locations contains http:</xsl:message>
  420. </xsl:when>
  421. <xsl:otherwise>
  422. <xsl:message> schema location <xsl:value-of select="$schemaLocation"/> not contains http:, but:
  423. <xsl:value-of select="exslt:node-set($namespace_records/schema/import/@schemaLocation[@namespace=$Parent_targetNamespace])"/>
  424. </xsl:message>
  425. </xsl:otherwise>
  426. </xsl:choose>
  427. <xsl:for-each select="document($schemaLocation)">
  428. <xsl:variable name="filename" select="concat('../auto_imported_referenced_schemas/',replace(replace($schemaLocation,'http://',''),'\.\./',''))"/>
  429. <xsl:message terminate="no">Import pliku ze zrodla <xsl:value-of select="$schemaLocation"/> </xsl:message>
  430. <xsl:result-document href="{$filename}" method="xml">
  431. <xsl:copy-of select="/"/>
  432. </xsl:result-document>
  433. </xsl:for-each>
  434. </xsl:template>
  435. <xsl:template match="import" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  436. <namespace_record_import>
  437. <namespace>
  438. <xsl:value-of select="attribute::node()[name()='namespace']"/>
  439. </namespace>
  440. <schemaLocation>
  441. <xsl:value-of select="attribute::node()[name()='schemaLocation']"/>
  442. </schemaLocation>
  443. <Parent_targetNamespace>
  444. <xsl:value-of select="../@targetNamespace"/>
  445. </Parent_targetNamespace>
  446. </namespace_record_import>
  447. </xsl:template>
  448. <xsl:template match="schema" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  449. <!--
  450. <document>
  451. <xsl:value-of select="document-uri(/)"/>
  452. </document> -->
  453. <xsl:variable name="targetNamespace">
  454. <xsl:for-each select="attribute::node()[name()='targetNamespace']">
  455. <xsl:value-of select="."/>
  456. </xsl:for-each>
  457. </xsl:variable>
  458. <xsl:for-each select="namespace::node()[.=$targetNamespace]">
  459. <namespace_record>
  460. <prefix>
  461. <xsl:value-of select="name()"/>
  462. </prefix>
  463. <namespace>
  464. <xsl:value-of select="."/>
  465. </namespace>
  466. </namespace_record>
  467. </xsl:for-each>
  468. <xsl:apply-templates select="import"/>
  469. </xsl:template>
  470. <!--
  471. <xsl:template match="node()|@*">
  472. <xsl:for-each select="xs:complexType">
  473. <test>create table <xsl:value-of select="@name"/></test>
  474. </xsl:for-each>
  475. </xsl:template> -->
  476. </xsl:stylesheet>