object_modeling.xsl 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  5. exclude-result-prefixes="xs"
  6. version="2.0">
  7. <xsl:output indent="yes"/>
  8. <xsl:strip-space elements="*"/>
  9. <!--<xsl:include href="get_all_xsd.xsl"/>-->
  10. <!--<xsl:param name="procesy5_system_schema_file" select="'../default_db.instance.xml/transformed/procesy5_system_schema.xml'"/>-->
  11. <xsl:include href="system_cache__appinfo/TargetNamespaceBindings.xsl"/>
  12. <!--<xsl:include href="get_all_xsd.xsl"/>--> <!-- for use system_cache__appinfo:escape_object_prefix_to_string -->
  13. <xsl:param name="prototype_object_namespace" select="'https://biuro.biall-net.pl/wfs/default_db/Types/Infrastructure.xsd'"/>
  14. <xsl:param name="new_object_namespace"/> <!-- example https://biuro.biall-net.pl/wfs/default_db/table/CRM_PROCES.xsd -->
  15. <!--<xsl:param name="procesy5_system_schema_collection_dir" select="'../../'"/>--> <!-- should be like /Users/a.binder/Documents/xmlschema_procesy5/src-xmlschema/public_html -->
  16. <xsl:template match="system_cache__appinfo:get_all_xsd_list" mode="system_cache__appinfo:new_object_by_prototype">
  17. <xsl:choose>
  18. <xsl:when test="$prototype_object_namespace and $new_object_namespace">
  19. <xsl:variable name="system_cache__appinfo:new_object_by_prototype_test_if_prototype">
  20. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_test_if_prototype"/>
  21. </xsl:variable>
  22. <xsl:choose>
  23. <xsl:when test="$system_cache__appinfo:new_object_by_prototype_test_if_prototype/*">
  24. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype"/>
  25. </xsl:when>
  26. <xsl:otherwise>
  27. <xsl:message terminate="yes">#32 prototype <xsl:value-of select="$prototype_object_namespace"/> not exists in schema ! if it realy exiss consider rebuild procesy5_system_schema.xml !</xsl:message>
  28. </xsl:otherwise>
  29. </xsl:choose>
  30. </xsl:when>
  31. <xsl:otherwise><xsl:message terminate="yes">#25 not set required $prototype_object_namespace and $new_object_namespace params!</xsl:message></xsl:otherwise>
  32. </xsl:choose>
  33. </xsl:template>
  34. <xsl:template mode="system_cache__appinfo:new_object_by_prototype" match="system_cache__appinfo:get_all_xsd">
  35. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype"/>
  36. </xsl:template>
  37. <xsl:template mode="system_cache__appinfo:new_object_by_prototype_test_if_prototype" match="system_cache__appinfo:get_all_xsd">
  38. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_test_if_prototype"/>
  39. </xsl:template>
  40. <xsl:template mode="system_cache__appinfo:new_object_by_prototype_test_if_prototype" match="schema[@targetNamespace=$prototype_object_namespace]" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  41. <system_cache__appinfo:new_object_by_prototype_test_if_prototype>exists_flag</system_cache__appinfo:new_object_by_prototype_test_if_prototype>
  42. </xsl:template>
  43. <xsl:template mode="system_cache__appinfo:new_object_by_prototype_test_if_prototype" match="*|text()|comment()"/>
  44. <xsl:template mode="system_cache__appinfo:new_object_by_prototype" match="schema[@targetNamespace=$prototype_object_namespace]" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  45. <xsl:variable name="prototype_TargetNamespaceBindings_from_Namespace">
  46. <xsl:call-template name="system_cache__appinfo:TargetNamespaceBindings_from_Namespace">
  47. <xsl:with-param name="TargetNamespace" select="$prototype_object_namespace"/>
  48. </xsl:call-template>
  49. </xsl:variable>
  50. <xsl:variable name="new_TargetNamespaceBindings_from_Namespace">
  51. <xsl:call-template name="system_cache__appinfo:TargetNamespaceBindings_from_Namespace">
  52. <xsl:with-param name="TargetNamespace" select="$new_object_namespace"/>
  53. </xsl:call-template>
  54. </xsl:variable>
  55. <xsl:variable name="prototype_NamespacePrefix">
  56. <xsl:for-each select="namespace::node()">
  57. <xsl:if test=".= $prototype_object_namespace">
  58. <xsl:value-of select="name()"/>
  59. </xsl:if>
  60. </xsl:for-each>
  61. </xsl:variable>
  62. <system_cache__appinfo:new_object_by_prototype>
  63. <xsl:attribute name="prototype_object_namespace" select="$prototype_object_namespace"/>
  64. <xsl:attribute name="new_object_namespace" select="$new_object_namespace"/>
  65. <xsl:attribute name="generating_schema_file_to" select="concat($procesy5_system_schema_collection_dir,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceType,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,'.xsd')"/>
  66. <prototype_TargetNamespaceBindings_from_Namespace>
  67. <xsl:copy-of select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  68. </prototype_TargetNamespaceBindings_from_Namespace>
  69. <new_TargetNamespaceBindings_from_Namespace>
  70. <xsl:copy-of select="$new_TargetNamespaceBindings_from_Namespace"/>
  71. </new_TargetNamespaceBindings_from_Namespace>
  72. <prototype_NamespacePrefix>
  73. <xsl:copy-of select="$prototype_NamespacePrefix"/>
  74. </prototype_NamespacePrefix>
  75. <xsl:choose>
  76. <xsl:when test=" doc-available(concat($procesy5_system_schema_collection_dir,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceType,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,'.xsd'))">
  77. <ERROR>
  78. <xsl:attribute name="message" select="'document already generated and aviable'"/>
  79. OUTPUT__START
  80. document already generated and aviable
  81. OUTPUT__END
  82. </ERROR>
  83. </xsl:when>
  84. <xsl:otherwise>
  85. <xsl:result-document href="{ concat($procesy5_system_schema_collection_dir,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceType,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,'.xsd')}">
  86. <!--<xsl:attribute name="href" select=" concat($procesy5_system_schema_collection_dir,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceType,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,'.xsd')"/>-->
  87. <xsl:element name="xs:schema">
  88. <xsl:copy-of select="namespace::node()"/>
  89. <xsl:namespace name="{$new_TargetNamespaceBindings_from_Namespace//@NamespacePrefix}" select="$new_object_namespace"/>
  90. <xsl:attribute name="targetNamespace" select="$new_object_namespace"/>
  91. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  92. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  93. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  94. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  95. </xsl:apply-templates>
  96. </xsl:element>
  97. </xsl:result-document>
  98. </xsl:otherwise>
  99. </xsl:choose>
  100. </system_cache__appinfo:new_object_by_prototype>
  101. </xsl:template>
  102. <xsl:template mode="system_cache__appinfo:new_object_by_prototype_schema_root" match="import" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  103. <xsl:copy-of select="."/>
  104. </xsl:template>
  105. <xsl:template mode="system_cache__appinfo:new_object_by_prototype_schema_root" match="element|complexType|simpleType" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  106. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  107. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  108. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  109. <xsl:element name="{name()}">
  110. <xsl:apply-templates select="@*" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  111. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  112. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  113. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  114. </xsl:apply-templates>
  115. <!--<xsl:attribute name="id" select="concat(substring($new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,0,8),'_', substring(replace(@name,$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable),0,5),'_',generate-id())"/>-->
  116. <!--<xsl:attribute name="name" select=" replace(@name,$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,'InfrastructureAAAA')"/>-->
  117. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  118. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  119. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  120. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  121. </xsl:apply-templates>
  122. </xsl:element>
  123. </xsl:template>
  124. <xsl:template match="sequence|choice|all" mode="system_cache__appinfo:new_object_by_prototype_schema_child" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  125. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  126. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  127. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  128. <xsl:element name="{name()}">
  129. <!--<xsl:attribute name="id" select="concat(substring($new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,0,15),'_',generate-id())"/>-->
  130. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  131. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  132. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  133. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  134. </xsl:apply-templates>
  135. </xsl:element>
  136. </xsl:template>
  137. <xsl:template match="element|complexContent|restriction|enumeration|minInclusive" mode="system_cache__appinfo:new_object_by_prototype_schema_child" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  138. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  139. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  140. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  141. <xsl:element name="{name()}">
  142. <xsl:copy-of select="@minOccurs"/>
  143. <xsl:copy-of select="@maxOccurs"/>
  144. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child" select="@*">
  145. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  146. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  147. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  148. <xsl:with-param name="node" select="."/>
  149. </xsl:apply-templates>
  150. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  151. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  152. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  153. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  154. </xsl:apply-templates>
  155. </xsl:element>
  156. </xsl:template>
  157. <xsl:template match="annotation|appinfo|documentation" mode="system_cache__appinfo:new_object_by_prototype_schema_child" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  158. <xsl:element name="{name()}">
  159. <xsl:copy-of select="@*"/>
  160. <xsl:copy-of select="text()"/>
  161. <xsl:copy-of select="system_cache__appinfo:base_type"/>
  162. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child"/>
  163. </xsl:element>
  164. </xsl:template>
  165. <xsl:template match="system_cache__appinfo:flat_relation_cache" mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  166. <xsl:copy-of select="."/>
  167. </xsl:template>
  168. <xsl:template match="@ref" mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  169. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  170. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  171. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  172. <xsl:attribute name="{ name()}" select=" replace(.,$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable)"/>
  173. </xsl:template>
  174. <xsl:template match="@base|@type" mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  175. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  176. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  177. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  178. <!--<xsl:attribute name="{name()}" select=" concat($prototype_NamespacePrefix,':', substring-after(.,':'),'__to__',concat($new_TargetNamespaceBindings_from_Namespace//@NamespaceDatabaseStorageDefinitionPrefix ,'__x3A__', $new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable, ':', replace( substring-after(.,':'),$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable )) )"/>-->
  179. <xsl:attribute name="{ name()}" select=" replace(., concat($prototype_NamespacePrefix,':', substring-after(.,':')), concat($new_TargetNamespaceBindings_from_Namespace//@NamespaceDatabaseStorageDefinitionPrefix ,'__x3A__', $new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,':', replace( substring-after(.,':'),$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable ) ) )"/>
  180. </xsl:template>
  181. <xsl:template match="@*" mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  182. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  183. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  184. <xsl:attribute name="{ name()}" select="."/>
  185. </xsl:template>
  186. <xsl:template match="@id" mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  187. <!-- <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  188. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  189. <xsl:param name="node" required="yes"/>
  190. <xsl:attribute name="{ name()}" select="concat(substring($new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,0,15),'_',generate-id($node))"/>-->
  191. </xsl:template>
  192. <xsl:template match="@id" mode="system_cache__appinfo:new_object_by_prototype_schema_root"/>
  193. <xsl:template match="@name" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  194. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  195. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  196. <xsl:attribute name="{ name()}" select=" replace(.,$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable)"/>
  197. </xsl:template>
  198. <xsl:template match="@type" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  199. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  200. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  201. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  202. <!--<xsl:attribute name="{name()}" select=" concat($prototype_NamespacePrefix,':', substring-after(.,':'),'__to__',concat($new_TargetNamespaceBindings_from_Namespace//@NamespaceDatabaseStorageDefinitionPrefix ,'__x3A__', $new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable, ':', replace( substring-after(.,':'),$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable )) )"/>-->
  203. <xsl:attribute name="{ name()}" select=" replace(., concat($prototype_NamespacePrefix,':', substring-after(.,':')), concat($new_TargetNamespaceBindings_from_Namespace//@NamespaceDatabaseStorageDefinitionPrefix ,'__x3A__', $new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,':', replace( substring-after(.,':'),$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable ) ) )"/>
  204. </xsl:template>
  205. <!--<xsl:template match="@type" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  206. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  207. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  208. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  209. <xsl:attribute name="{ name()}" select=" replace(.,$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable)"/>
  210. </xsl:template>-->
  211. <xsl:template match="@*" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  212. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  213. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  214. <xsl:attribute name="{name()}" select="."/>
  215. </xsl:template>
  216. <xsl:template match="@abstract" mode="system_cache__appinfo:new_object_by_prototype_schema_root"/>
  217. <xsl:template match=" text()|comment()" mode="system_cache__appinfo:new_object_by_prototype_schema_child"/>
  218. <xsl:template match=" text()|comment()" mode="system_cache__appinfo:new_object_by_prototype_schema_root"/>
  219. <xsl:template mode="system_cache__appinfo:new_object_by_prototype" match="*|text()|comment()"/>
  220. </xsl:stylesheet>