object_modeling.xsl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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:apply-templates mode="system_cache__appinfo:new_object_by_prototype"/>
  20. </xsl:when>
  21. <xsl:otherwise><xsl:message terminate="yes">#25 not set required $prototype_object_namespace and $new_object_namespace params!</xsl:message></xsl:otherwise>
  22. </xsl:choose>
  23. </xsl:template>
  24. <xsl:template mode="system_cache__appinfo:new_object_by_prototype" match="system_cache__appinfo:get_all_xsd">
  25. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype"/>
  26. </xsl:template>
  27. <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">
  28. <xsl:variable name="prototype_TargetNamespaceBindings_from_Namespace">
  29. <xsl:call-template name="system_cache__appinfo:TargetNamespaceBindings_from_Namespace">
  30. <xsl:with-param name="TargetNamespace" select="$prototype_object_namespace"/>
  31. </xsl:call-template>
  32. </xsl:variable>
  33. <xsl:variable name="new_TargetNamespaceBindings_from_Namespace">
  34. <xsl:call-template name="system_cache__appinfo:TargetNamespaceBindings_from_Namespace">
  35. <xsl:with-param name="TargetNamespace" select="$new_object_namespace"/>
  36. </xsl:call-template>
  37. </xsl:variable>
  38. <xsl:variable name="prototype_NamespacePrefix">
  39. <xsl:for-each select="namespace::node()">
  40. <xsl:if test=".= $prototype_object_namespace">
  41. <xsl:value-of select="name()"/>
  42. </xsl:if>
  43. </xsl:for-each>
  44. </xsl:variable>
  45. <system_cache__appinfo:new_object_by_prototype>
  46. <xsl:attribute name="prototype_object_namespace" select="$prototype_object_namespace"/>
  47. <xsl:attribute name="new_object_namespace" select="$new_object_namespace"/>
  48. <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')"/>
  49. <prototype_TargetNamespaceBindings_from_Namespace>
  50. <xsl:copy-of select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  51. </prototype_TargetNamespaceBindings_from_Namespace>
  52. <new_TargetNamespaceBindings_from_Namespace>
  53. <xsl:copy-of select="$new_TargetNamespaceBindings_from_Namespace"/>
  54. </new_TargetNamespaceBindings_from_Namespace>
  55. <prototype_NamespacePrefix>
  56. <xsl:copy-of select="$prototype_NamespacePrefix"/>
  57. </prototype_NamespacePrefix>
  58. <xsl:choose>
  59. <xsl:when test=" doc-available(concat($procesy5_system_schema_collection_dir,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceType,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,'.xsd'))">
  60. <ERROR>
  61. <xsl:attribute name="message" select="'document already generated and aviable'"/>
  62. OUTPUT__START
  63. document already generated and aviable
  64. OUTPUT__END
  65. </ERROR>
  66. </xsl:when>
  67. <xsl:otherwise>
  68. <xsl:result-document href="{ concat($procesy5_system_schema_collection_dir,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceType,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,'.xsd')}">
  69. <!--<xsl:attribute name="href" select=" concat($procesy5_system_schema_collection_dir,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceType,'/',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,'.xsd')"/>-->
  70. <xsl:element name="xs:schema">
  71. <xsl:copy-of select="namespace::node()"/>
  72. <xsl:namespace name="{$new_TargetNamespaceBindings_from_Namespace//@NamespacePrefix}" select="$new_object_namespace"/>
  73. <xsl:attribute name="targetNamespace" select="$new_object_namespace"/>
  74. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  75. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  76. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  77. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  78. </xsl:apply-templates>
  79. </xsl:element>
  80. </xsl:result-document>
  81. </xsl:otherwise>
  82. </xsl:choose>
  83. </system_cache__appinfo:new_object_by_prototype>
  84. </xsl:template>
  85. <xsl:template mode="system_cache__appinfo:new_object_by_prototype_schema_root" match="import" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  86. <xsl:copy-of select="."/>
  87. </xsl:template>
  88. <xsl:template mode="system_cache__appinfo:new_object_by_prototype_schema_root" match="element|complexType" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  89. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  90. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  91. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  92. <xsl:element name="{name()}">
  93. <xsl:apply-templates select="@*" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  94. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  95. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  96. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  97. </xsl:apply-templates>
  98. <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())"/>
  99. <!--<xsl:attribute name="name" select=" replace(@name,$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,'InfrastructureAAAA')"/>-->
  100. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  101. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  102. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  103. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  104. </xsl:apply-templates>
  105. </xsl:element>
  106. </xsl:template>
  107. <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">
  108. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  109. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  110. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  111. <xsl:element name="{name()}">
  112. <xsl:attribute name="id" select="concat(substring($new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,0,15),'_',generate-id())"/>
  113. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  114. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  115. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  116. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  117. </xsl:apply-templates>
  118. </xsl:element>
  119. </xsl:template>
  120. <xsl:template match="element|complexContent|restriction" mode="system_cache__appinfo:new_object_by_prototype_schema_child" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  121. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  122. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  123. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  124. <xsl:element name="{name()}">
  125. <xsl:copy-of select="@minOccurs"/>
  126. <xsl:copy-of select="@maxOccurs"/>
  127. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child" select="@*">
  128. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  129. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  130. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  131. <xsl:with-param name="node" select="."/>
  132. </xsl:apply-templates>
  133. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  134. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  135. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  136. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  137. </xsl:apply-templates>
  138. </xsl:element>
  139. </xsl:template>
  140. <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">
  141. <xsl:element name="{name()}">
  142. <xsl:copy-of select="@*"/>
  143. <xsl:copy-of select="text()"/>
  144. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_child"/>
  145. </xsl:element>
  146. </xsl:template>
  147. <xsl:template match="system_cache__appinfo:flat_relation_cache" mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  148. <xsl:copy-of select="."/>
  149. </xsl:template>
  150. <xsl:template match="@ref" mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  151. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  152. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  153. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  154. <xsl:attribute name="{ name()}" select=" replace(.,$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable)"/>
  155. </xsl:template>
  156. <xsl:template match="@base" mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  157. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  158. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  159. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  160. <!--<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 )) )"/>-->
  161. <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 ) ) )"/>
  162. </xsl:template>
  163. <xsl:template match="@*" mode="system_cache__appinfo:new_object_by_prototype_schema_child">
  164. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  165. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  166. <xsl:attribute name="{ name()}" select="."/>
  167. </xsl:template>
  168. <xsl:template match="@id" 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="node" required="yes"/>
  172. <xsl:attribute name="{ name()}" select="concat(substring($new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,0,15),'_',generate-id($node))"/>-->
  173. </xsl:template>
  174. <xsl:template match="@name" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  175. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  176. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  177. <xsl:attribute name="{ name()}" select=" replace(.,$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable)"/>
  178. </xsl:template>
  179. <xsl:template match="@type" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  180. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  181. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  182. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  183. <!--<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 )) )"/>-->
  184. <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 ) ) )"/>
  185. </xsl:template>
  186. <!--<xsl:template match="@type" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  187. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  188. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  189. <xsl:param name="prototype_NamespacePrefix" required="yes"/>
  190. <xsl:attribute name="{ name()}" select=" replace(.,$prototype_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable,$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable)"/>
  191. </xsl:template>-->
  192. <xsl:template match="@*" mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  193. <xsl:param name="prototype_TargetNamespaceBindings_from_Namespace" required="yes"/>
  194. <xsl:param name="new_TargetNamespaceBindings_from_Namespace" required="yes"/>
  195. <xsl:attribute name="{name()}" select="."/>
  196. </xsl:template>
  197. <xsl:template match="@abstract" mode="system_cache__appinfo:new_object_by_prototype_schema_root"/>
  198. <xsl:template match=" text()|comment()" mode="system_cache__appinfo:new_object_by_prototype_schema_child"/>
  199. <xsl:template match=" text()|comment()" mode="system_cache__appinfo:new_object_by_prototype_schema_root"/>
  200. <xsl:template mode="system_cache__appinfo:new_object_by_prototype" match="*|text()|comment()"/>
  201. </xsl:stylesheet>