functions.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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="escape_functions.xsl"/>
  8. <xsl:function name="system_cache__appinfo:document-uri_for_external_schema_id_namespace_prefix">
  9. <xsl:param name="system_cache__appinfo:document-uri_from_external_schema"/>
  10. <xsl:value-of select="substring-after(replace($system_cache__appinfo:document-uri_from_external_schema,$external_schema,$external_schema_id_namespace_prefix ), '/public_html/') "/>
  11. </xsl:function>
  12. <xsl:function name="system_cache__appinfo:document-uri-full_for_external_schema_id_namespace_prefix">
  13. <xsl:param name="system_cache__appinfo:document-uri_from_external_schema"/>
  14. <xsl:value-of select="replace($system_cache__appinfo:document-uri_from_external_schema,$external_schema,$external_schema_id_namespace_prefix )"/>
  15. </xsl:function>
  16. <xsl:function name="system_cache__appinfo:get_object_prefix_from_escaped_prefix_or_not_being_escaped">
  17. <xsl:param name="system_cache__appinfo:escape_object_prefix_to_string"/>
  18. <xsl:choose>
  19. <xsl:when test=" substring-before(system_cache__appinfo:translate_object_escaped_prefix_from_string($system_cache__appinfo:escape_object_prefix_to_string),':')">
  20. <xsl:value-of select="system_cache__appinfo:get_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($system_cache__appinfo:escape_object_prefix_to_string))"/>
  21. </xsl:when>
  22. <xsl:otherwise>
  23. <xsl:value-of select="$system_cache__appinfo:escape_object_prefix_to_string"/>
  24. </xsl:otherwise>
  25. </xsl:choose>
  26. </xsl:function>
  27. <xsl:function name="system_cache__appinfo:get_object_prefix_from_escaped_prefix">
  28. <xsl:param name="system_cache__appinfo:escape_object_prefix_to_string"/>
  29. <xsl:value-of select="system_cache__appinfo:get_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($system_cache__appinfo:escape_object_prefix_to_string))"/>
  30. </xsl:function>
  31. <!-- funkcja do wyczyszczenia wyescapowenago prefixu z np. default_db__x3A__IN7_DZIENNIK_KORESP do IN7_DZIENNIK_KORESP -->
  32. <xsl:function name="system_cache__appinfo:clean_object_escaped_prefix">
  33. <xsl:param name="name" />
  34. <xsl:choose>
  35. <xsl:when test="contains(system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name)),':')">
  36. <!--<xsl:message terminate="yes">#48 ERROR ERROR?? double prefixed or uncorrect object $name=<xsl:value-of select="$name"/>; try system_cache__appinfo:clean_object_escaped_prefix_with_db_prefix instead?</xsl:message>-->
  37. <xsl:value-of select=" system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name))"/>
  38. </xsl:when>
  39. <xsl:otherwise><xsl:value-of select=" system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name))"/></xsl:otherwise>
  40. </xsl:choose>
  41. </xsl:function>
  42. <xsl:function name="system_cache__appinfo:clean_object_escaped_prefix_with_db_prefix">
  43. <xsl:param name="name" />
  44. <xsl:choose>
  45. <xsl:when test="contains(system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name)),':')">
  46. <xsl:value-of select="system_cache__appinfo:clean_object_escaped_prefix(system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name)))"/>
  47. </xsl:when>
  48. <xsl:otherwise><xsl:value-of select=" system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name))"/></xsl:otherwise>
  49. </xsl:choose>
  50. </xsl:function>
  51. <xsl:template name="system_cache__appinfo:prefixed_object_info">
  52. <xsl:param name="prefixed_object" required="yes"/>
  53. <xsl:variable name="prefix_token" select="tokenize(system_cache__appinfo:translate_object_escaped_prefix_from_string($prefixed_object),':')"/>
  54. <xsl:choose>
  55. <xsl:when test=" string-length($prefix_token[3]) &gt; 0">
  56. <system_cache__appinfo:prefixed_object_info>
  57. <xsl:attribute name="prefix" select="$prefix_token[1]"/>
  58. <xsl:attribute name="name" select="$prefix_token[2]"/>
  59. <xsl:attribute name="element" select="$prefix_token[3]"/>
  60. </system_cache__appinfo:prefixed_object_info>
  61. </xsl:when>
  62. <xsl:otherwise>
  63. <system_cache__appinfo:prefixed_object_info>
  64. <xsl:attribute name="prefix" select="$prefix_token[1]"/>
  65. <xsl:attribute name="name" select="$prefix_token[2]"/>
  66. <xsl:attribute name="element" select="$prefix_token[2]"/>
  67. </system_cache__appinfo:prefixed_object_info>
  68. </xsl:otherwise>
  69. </xsl:choose>
  70. </xsl:template>
  71. <!-- @2016-08 funkcje do wykrywania prefixow, namespace itp itd...
  72. <xsl:attribute name="prefix" select="$vrtfNamespaces/ns[@uri=$targetnamespace][1]/@prefix" xpath-default-namespace=""/>
  73. <xsl:attribute name="targetnamespace" select="$targetnamespace"/>
  74. <xsl:attribute name="type_79" select="$type_79"/>
  75. <xsl:attribute name="prefix_79" select="$prefix_79"/>
  76. <xsl:attribute name="type_79_nopref" select="$type_79_nopref"/>
  77. -->
  78. <xsl:function name="system_cache__appinfo:prefix_from_targetNamespace">
  79. <xsl:param name="system_cache__appinfo:vrtfNamespaces" />
  80. <xsl:param name="targetNamespace" />
  81. <!--<xsl:message>#115 system_cache__appinfo:prefix_from_targetNamespace elements in system_cache__appinfo:vrtfNamespaces=<xsl:value-of select="count($system_cache__appinfo:vrtfNamespaces//ns)" xpath-default-namespace=""/></xsl:message>-->
  82. <!--<xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[substring-after(@uri,'://')=substring-after($targetNamespace,'://')][1]/@prefix" xpath-default-namespace=""/>-->
  83. <xsl:choose>
  84. <xsl:when test=" contains($targetNamespace,'://')">
  85. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[substring-after(@uri,'://')=substring-after($targetNamespace,'://') ][1]/@prefix" xpath-default-namespace=""/>
  86. </xsl:when>
  87. <xsl:otherwise>
  88. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[@uri=$targetNamespace][1]/@prefix" xpath-default-namespace=""/>
  89. </xsl:otherwise>
  90. </xsl:choose>
  91. </xsl:function>
  92. <xsl:function name="system_cache__appinfo:prefix_from_targetNamespace">
  93. <xsl:param name="system_cache__appinfo:vrtfNamespaces" />
  94. <xsl:param name="targetNamespace" />
  95. <xsl:param name="system_cache__appinfo:document-uri" />
  96. <!--<xsl:message>#115 system_cache__appinfo:prefix_from_targetNamespace elements in system_cache__appinfo:vrtfNamespaces=<xsl:value-of select="count($system_cache__appinfo:vrtfNamespaces//ns)" xpath-default-namespace=""/></xsl:message>-->
  97. <xsl:choose>
  98. <xsl:when test=" contains($targetNamespace,'://')">
  99. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[substring-after(@uri,'://')=substring-after($targetNamespace,'://') and @system_cache__appinfo:document-uri=$system_cache__appinfo:document-uri][1]/@prefix" xpath-default-namespace=""/>
  100. </xsl:when>
  101. <xsl:otherwise>
  102. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[@uri=$targetNamespace and @system_cache__appinfo:document-uri=$system_cache__appinfo:document-uri][1]/@prefix" xpath-default-namespace=""/>
  103. </xsl:otherwise>
  104. </xsl:choose>
  105. <xsl:message>#103 targetns another try for <xsl:value-of select="$targetNamespace"/> todo count all <xsl:value-of select="count($system_cache__appinfo:vrtfNamespaces//ns)"/> / <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//node()[local-name()='ns' and @uri=$targetNamespace]/@*"/> </xsl:message>
  106. </xsl:function>
  107. <xsl:function name="system_cache__appinfo:targetNamespace_from_prefix">
  108. <xsl:param name="system_cache__appinfo:vrtfNamespaces" />
  109. <xsl:param name="prefix" />
  110. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[@prefix=$prefix][1]/@uri" xpath-default-namespace=""/>
  111. </xsl:function>
  112. <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 -->
  113. <xsl:param name="parent_complexTypeNamespace" />
  114. <xsl:variable name="uri_tokens" select="tokenize($parent_complexTypeNamespace,'/')"/>
  115. <xsl:variable name="uri_tokens_count" select="count($uri_tokens)"/>
  116. <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'">
  117. <xsl:variable name="get_default_db_obj_url_table_name" select="tokenize($uri_tokens[$uri_tokens_count],'\.')"/>
  118. <xsl:value-of select="$get_default_db_obj_url_table_name[1]"/>
  119. </xsl:if>
  120. </xsl:function>
  121. <xsl:function name="system_cache__appinfo:get_default_db_obj_url_schema"><!-- @2016-10 funkcja do wykrywania nazwy tabeli dla default db, w przypadku braku zgodnosci namespace - nic nie zwraca -->
  122. <xsl:param name="parent_complexTypeNamespace" />
  123. <xsl:variable name="system_cache__appinfo:get_default_db_obj_url_table_name" select="system_cache__appinfo:get_default_db_obj_url_table_name($parent_complexTypeNamespace)"/>
  124. <xsl:choose>
  125. <xsl:when test=" string-length($system_cache__appinfo:get_default_db_obj_url_table_name) &gt; 0">
  126. <xsl:value-of select="concat($system_cache__appinfo:get_default_db_obj_url_table_name,'.xsd')"/>
  127. </xsl:when>
  128. <xsl:otherwise>
  129. <xsl:message>#127 !!!! in (system_cache__appinfo:get_default_db_obj_url_schema) in functions.xsl TODO system objects etc... !!!!!!!!!!! </xsl:message>
  130. </xsl:otherwise>
  131. </xsl:choose>
  132. </xsl:function>
  133. <xsl:function name="system_cache__appinfo:id.int.rand">
  134. <xsl:param name="id"/><!-- like DYSTRYBUCJI___d4e7067-1_ID_PROJECT -->
  135. <xsl:variable name="id.int" select="replace($id,'([a-z]|[A-Z]|_|-)','')"/>
  136. <xsl:variable name="mod.10" select="(number($id.int)+string-length($id)) mod 10"/>
  137. <xsl:variable name="mod.9" select="number($id.int) mod 9"/>
  138. <xsl:variable name="mod.8" select="number($id.int) mod 8"/>
  139. <xsl:value-of select="concat(1,$mod.10,$mod.9,$mod.8)"/>
  140. </xsl:function>
  141. <!--<xsl:function name="system_cache__appinfo:php_function_name_from_obj_with_prefix">
  142. <xsl:param name="object_name" required="yes"/>
  143. <xsl:value-of select="replace($object_name,':','__x3A__')"/>
  144. </xsl:function>-->
  145. </xsl:stylesheet>