object_modeling_new.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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:include href="system_cache__appinfo/TargetNamespaceBindings.xsl"/>-->
  8. <xsl:include href="object_modeling.xsl"/> <!-- to use one time system_cache__appinfo:new_object_by_prototype_schema_root -->
  9. <!--<xsl:param name="new_object_namespace" required="yes"/>--> <!-- example https://biuro.biall-net.pl/wfs/default_db/table/CRM_PROCES.xsd -->
  10. <xsl:param name="TargetNamespaceBindingsApi" required="yes"/> <!-- example https://biuro.biall-net.pl/wfs -->
  11. <xsl:param name="NamespaceDatabaseStorageDefinitionPrefix" select="'default_db'"/> <!-- example default_db -->
  12. <xsl:param name="NamespaceObjectInstanceType" select="'table'"/> <!-- example table -->
  13. <xsl:param name="NamespaceObjectInstanceTable" required="yes"/> <!-- example CRM_PROCES -->
  14. <xsl:param name="template_object.xml_location" required="yes"/> <!-- <xsl:variable name="template_object.xml_location" select="concat($object_modeling_new_repository,'/',$NamespaceDatabaseStorageDefinitionPrefix,'/',$NamespaceObjectInstanceType,'/',$NamespaceObjectInstanceTable,'.xml')"/> -->
  15. <xsl:param name="object_modeling_new_basedir_repository" required="yes"/> <!-- location where is template modified objects repository for debug only -->
  16. <!--<xsl:param name="prototype_object_namespace" select="'https://biuro.biall-net.pl/wfs/default_db/Types/Default.xsd'"/>--> <!-- for default prototype object set in child xsl -->
  17. <xsl:variable name="TargetNamespace_from_Bindings">
  18. <xsl:call-template name="system_cache__appinfo:TargetNamespace_from_Bindings">
  19. <xsl:with-param name="NamespaceDatabaseStorageDefinitionPrefix" select="$NamespaceDatabaseStorageDefinitionPrefix"/>
  20. <xsl:with-param name="NamespaceObjectInstanceTable" select="$NamespaceObjectInstanceTable"/>
  21. <xsl:with-param name="TargetNamespaceBindingsApi" select="$TargetNamespaceBindingsApi"/>
  22. <xsl:with-param name="NamespaceObjectInstanceType" select="$NamespaceObjectInstanceType"/>
  23. </xsl:call-template>
  24. </xsl:variable>
  25. <xsl:variable name="prototype_TargetNamespaceBindings_from_Namespace">
  26. <xsl:call-template name="system_cache__appinfo:TargetNamespaceBindings_from_Namespace">
  27. <xsl:with-param name="TargetNamespace" select="$prototype_object_namespace"/>
  28. </xsl:call-template>
  29. </xsl:variable>
  30. <xsl:variable name="new_TargetNamespaceBindings_from_Namespace">
  31. <xsl:call-template name="system_cache__appinfo:TargetNamespaceBindings_from_Namespace">
  32. <xsl:with-param name="TargetNamespace" select="$TargetNamespace_from_Bindings//@TargetNamespace"/>
  33. </xsl:call-template>
  34. </xsl:variable>
  35. <xsl:variable name="template_object.xml">
  36. <xsl:choose>
  37. <xsl:when test=" doc-available( $template_object.xml_location)">
  38. <xsl:copy-of select=" doc($template_object.xml_location)"></xsl:copy-of>
  39. </xsl:when>
  40. </xsl:choose>
  41. </xsl:variable>
  42. <xsl:template match="system_cache__appinfo:get_all_xsd_list" mode="system_cache__appinfo:object_modeling_new">
  43. <system_cache__appinfo:object_modeling_new>
  44. <xsl:attribute name="object_modeling_new_basedir_repository" select="$object_modeling_new_basedir_repository"/>
  45. <xsl:copy-of select="$TargetNamespace_from_Bindings"/>
  46. <new_TargetNamespaceBindings_from_Namespace>
  47. <xsl:copy-of select="$new_TargetNamespaceBindings_from_Namespace"></xsl:copy-of>
  48. </new_TargetNamespaceBindings_from_Namespace>
  49. <xsl:variable name="system_cache__appinfo:object_modeling_new_test_if_exists">
  50. <xsl:apply-templates mode="system_cache__appinfo:object_modeling_new_test_if_exists"/>
  51. </xsl:variable>
  52. <xsl:choose>
  53. <xsl:when test="$system_cache__appinfo:object_modeling_new_test_if_exists/*">
  54. <ERROR>
  55. Object already defined in current schema
  56. </ERROR>
  57. </xsl:when>
  58. <xsl:otherwise>
  59. <OK>
  60. We try to create new object in <xsl:value-of select="$template_object.xml_location"/>
  61. </OK>
  62. <xsl:variable name="system_cache__appinfo:new_object_by_prototype_test_if_prototype">
  63. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_test_if_prototype"/>
  64. </xsl:variable>
  65. <xsl:choose>
  66. <xsl:when test="$system_cache__appinfo:new_object_by_prototype_test_if_prototype/*">
  67. <xsl:apply-templates mode="system_cache__appinfo:object_modeling_new_add"/>
  68. </xsl:when>
  69. <xsl:otherwise>
  70. <!--<xsl:message terminate="yes">#84 prototype <xsl:value-of select="$prototype_object_namespace"/> not exists in schema! if it realy exist consider rebuild procesy5_system_schema.xml !</xsl:message>-->
  71. <system_cache__appinfo:new_object_by_prototype_test_if_prototype>
  72. <xsl:copy-of select="$system_cache__appinfo:new_object_by_prototype_test_if_prototype"></xsl:copy-of>
  73. </system_cache__appinfo:new_object_by_prototype_test_if_prototype>
  74. <ERROR>Not exists prototype $prototype_object_namespace=<xsl:value-of select="$prototype_object_namespace"/>;</ERROR>
  75. </xsl:otherwise>
  76. </xsl:choose>
  77. </xsl:otherwise>
  78. </xsl:choose>
  79. </system_cache__appinfo:object_modeling_new>
  80. </xsl:template>
  81. <xsl:template mode="system_cache__appinfo:object_modeling_new_add" match="schema[@targetNamespace=$prototype_object_namespace]" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  82. <xsl:result-document href="{$template_object.xml_location}">
  83. <xsl:element name="xs:schema">
  84. <xsl:copy-of select="namespace::node()"/>
  85. <xsl:namespace name="{$new_TargetNamespaceBindings_from_Namespace//@NamespacePrefix}" select="$TargetNamespace_from_Bindings//@TargetNamespace"/>
  86. <xsl:attribute name="targetNamespace" select="$TargetNamespace_from_Bindings//@TargetNamespace"/>
  87. <xsl:variable name="prototype_NamespacePrefix">
  88. <xsl:for-each select="namespace::node()">
  89. <xsl:if test=".= $prototype_object_namespace">
  90. <xsl:value-of select="name()"/>
  91. </xsl:if>
  92. </xsl:for-each>
  93. </xsl:variable>
  94. <xsl:apply-templates mode="system_cache__appinfo:new_object_by_prototype_schema_root">
  95. <xsl:with-param name="prototype_TargetNamespaceBindings_from_Namespace" select="$prototype_TargetNamespaceBindings_from_Namespace"/>
  96. <xsl:with-param name="new_TargetNamespaceBindings_from_Namespace" select="$new_TargetNamespaceBindings_from_Namespace"/>
  97. <xsl:with-param name="prototype_NamespacePrefix" select="$prototype_NamespacePrefix"/>
  98. </xsl:apply-templates>
  99. </xsl:element>
  100. </xsl:result-document>
  101. </xsl:template>
  102. <xsl:template mode="system_cache__appinfo:object_modeling_new_add" match="schema|text()|comment()"/>
  103. <xsl:template match="system_cache__appinfo:get_all_xsd" mode="system_cache__appinfo:object_modeling_new">
  104. <xsl:apply-templates mode="system_cache__appinfo:object_modeling_new_test_if_exists"/>
  105. </xsl:template>
  106. <xsl:template match="system_cache__appinfo:get_all_xsd_list" mode="system_cache__appinfo:object_modeling_new_test_if_exists">
  107. <system_cache__appinfo:object_modeling_new_test_if_exists>
  108. <xsl:message><xsl:copy-of select="$TargetNamespace_from_Bindings//@TargetNamespace"/></xsl:message>
  109. <xsl:apply-templates mode="system_cache__appinfo:object_modeling_new_test_if_exists"/>
  110. </system_cache__appinfo:object_modeling_new_test_if_exists>
  111. </xsl:template>
  112. <xsl:template match="system_cache__appinfo:get_all_xsd" mode="system_cache__appinfo:object_modeling_new_test_if_exists">
  113. <xsl:apply-templates mode="system_cache__appinfo:object_modeling_new_test_if_exists"/>
  114. </xsl:template>
  115. <xsl:template mode="system_cache__appinfo:object_modeling_new_test_if_exists" match="schema[@targetNamespace=$TargetNamespace_from_Bindings//@TargetNamespace]" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
  116. <!-- not good - we have some objects already in this schema -->
  117. <!--<xsl:copy-of select="."/>-->
  118. <ERROR>
  119. Object already defined in current schema
  120. </ERROR>
  121. <!--<xsl:copy-of select="."/>-->
  122. </xsl:template>
  123. <xsl:template mode="system_cache__appinfo:object_modeling_new_test_if_exists" match="schema" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>
  124. <xsl:template mode="system_cache__appinfo:object_modeling_new_add_new_table" match="object_modeling_new_add_new_table">
  125. <system_cache__appinfo:object_modeling_new_add_new_table>
  126. <TargetNamespace_from_Bindings>
  127. <xsl:copy-of select="$TargetNamespace_from_Bindings"/>
  128. </TargetNamespace_from_Bindings>
  129. <new_TargetNamespaceBindings_from_Namespace>
  130. <xsl:copy-of select="$new_TargetNamespaceBindings_from_Namespace"/>
  131. </new_TargetNamespaceBindings_from_Namespace>
  132. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  133. xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
  134. xmlns:gml="http://www.opengis.net/gml/3.2"
  135. xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty"
  136. xmlns:default_db__x3A__SALES_PLAN="https://biuro.biall-net.pl/wfs/default_db/table/SALES_PLAN.xsd"
  137. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd">
  138. <xsl:namespace name="{$TargetNamespace_from_Bindings//@Prefix}" select="$TargetNamespace_from_Bindings//@TargetNamespace"/>
  139. <xsl:attribute name="elementFormDefault" select="'qualified'"/>
  140. <xsl:attribute name="targetNamespace" select="$TargetNamespace_from_Bindings//@TargetNamespace"/>
  141. <xsl:attribute name="vc:minVersion" select="'1.0'"/>
  142. <xsl:attribute name="vc:maxVersion" select="'1.1'"/>
  143. <xs:complexType name="{$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable}">
  144. <xs:sequence />
  145. </xs:complexType>
  146. <xs:element name="{$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable}">
  147. <xsl:attribute name="type" select="concat($TargetNamespace_from_Bindings//@Prefix,':',$new_TargetNamespaceBindings_from_Namespace//@NamespaceObjectInstanceTable)"/>
  148. </xs:element>
  149. </xs:schema>
  150. </system_cache__appinfo:object_modeling_new_add_new_table>
  151. </xsl:template>
  152. </xsl:stylesheet>