functions.xsl 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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:value-of select=" system_cache__appinfo:clean_object_prefix(system_cache__appinfo:translate_object_escaped_prefix_from_string($name))"/>
  35. </xsl:function>
  36. <xsl:template name="system_cache__appinfo:prefixed_object_info">
  37. <xsl:param name="prefixed_object" required="yes"/>
  38. <xsl:variable name="prefix_token" select="tokenize(system_cache__appinfo:translate_object_escaped_prefix_from_string($prefixed_object),':')"/>
  39. <xsl:choose>
  40. <xsl:when test=" string-length($prefix_token[3]) &gt; 0">
  41. <system_cache__appinfo:prefixed_object_info>
  42. <xsl:attribute name="prefix" select="$prefix_token[1]"/>
  43. <xsl:attribute name="name" select="$prefix_token[2]"/>
  44. <xsl:attribute name="element" select="$prefix_token[3]"/>
  45. </system_cache__appinfo:prefixed_object_info>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <system_cache__appinfo:prefixed_object_info>
  49. <xsl:attribute name="prefix" select="$prefix_token[1]"/>
  50. <xsl:attribute name="name" select="$prefix_token[2]"/>
  51. <xsl:attribute name="element" select="$prefix_token[2]"/>
  52. </system_cache__appinfo:prefixed_object_info>
  53. </xsl:otherwise>
  54. </xsl:choose>
  55. </xsl:template>
  56. <!-- @2016-08 funkcje do wykrywania prefixow, namespace itp itd...
  57. <xsl:attribute name="prefix" select="$vrtfNamespaces/ns[@uri=$targetnamespace][1]/@prefix" xpath-default-namespace=""/>
  58. <xsl:attribute name="targetnamespace" select="$targetnamespace"/>
  59. <xsl:attribute name="type_79" select="$type_79"/>
  60. <xsl:attribute name="prefix_79" select="$prefix_79"/>
  61. <xsl:attribute name="type_79_nopref" select="$type_79_nopref"/>
  62. -->
  63. <xsl:function name="system_cache__appinfo:prefix_from_targetNamespace">
  64. <xsl:param name="system_cache__appinfo:vrtfNamespaces" />
  65. <xsl:param name="targetNamespace" />
  66. <!--<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>-->
  67. <!--<xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[substring-after(@uri,'://')=substring-after($targetNamespace,'://')][1]/@prefix" xpath-default-namespace=""/>-->
  68. <xsl:choose>
  69. <xsl:when test=" contains($targetNamespace,'://')">
  70. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[substring-after(@uri,'://')=substring-after($targetNamespace,'://') ][1]/@prefix" xpath-default-namespace=""/>
  71. </xsl:when>
  72. <xsl:otherwise>
  73. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[@uri=$targetNamespace][1]/@prefix" xpath-default-namespace=""/>
  74. </xsl:otherwise>
  75. </xsl:choose>
  76. </xsl:function>
  77. <xsl:function name="system_cache__appinfo:prefix_from_targetNamespace">
  78. <xsl:param name="system_cache__appinfo:vrtfNamespaces" />
  79. <xsl:param name="targetNamespace" />
  80. <xsl:param name="system_cache__appinfo:document-uri" />
  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:choose>
  83. <xsl:when test=" contains($targetNamespace,'://')">
  84. <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=""/>
  85. </xsl:when>
  86. <xsl:otherwise>
  87. <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=""/>
  88. </xsl:otherwise>
  89. </xsl:choose>
  90. <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>
  91. </xsl:function>
  92. <xsl:function name="system_cache__appinfo:targetNamespace_from_prefix">
  93. <xsl:param name="system_cache__appinfo:vrtfNamespaces" />
  94. <xsl:param name="prefix" />
  95. <xsl:value-of select="$system_cache__appinfo:vrtfNamespaces//ns[@prefix=$prefix][1]/@uri" xpath-default-namespace=""/>
  96. </xsl:function>
  97. <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 -->
  98. <xsl:param name="parent_complexTypeNamespace" />
  99. <xsl:variable name="uri_tokens" select="tokenize($parent_complexTypeNamespace,'/')"/>
  100. <xsl:variable name="uri_tokens_count" select="count($uri_tokens)"/>
  101. <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'">
  102. <xsl:variable name="get_default_db_obj_url_table_name" select="tokenize($uri_tokens[$uri_tokens_count],'\.')"/>
  103. <xsl:value-of select="$get_default_db_obj_url_table_name[1]"/>
  104. </xsl:if>
  105. </xsl:function>
  106. <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 -->
  107. <xsl:param name="parent_complexTypeNamespace" />
  108. <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)"/>
  109. <xsl:choose>
  110. <xsl:when test=" string-length($system_cache__appinfo:get_default_db_obj_url_table_name) &gt; 0">
  111. <xsl:value-of select="concat($system_cache__appinfo:get_default_db_obj_url_table_name,'.xsd')"/>
  112. </xsl:when>
  113. <xsl:otherwise>
  114. <xsl:message>#127 !!!! in (system_cache__appinfo:get_default_db_obj_url_schema) in functions.xsl TODO system objects etc... !!!!!!!!!!! </xsl:message>
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:function>
  118. <xsl:function name="system_cache__appinfo:id.int.rand">
  119. <xsl:param name="id"/><!-- like DYSTRYBUCJI___d4e7067-1_ID_PROJECT -->
  120. <xsl:variable name="id.int" select="replace($id,'([a-z]|[A-Z]|_|-)','')"/>
  121. <xsl:variable name="mod.10" select="(number($id.int)+string-length($id)) mod 10"/>
  122. <xsl:variable name="mod.9" select="number($id.int) mod 9"/>
  123. <xsl:variable name="mod.8" select="number($id.int) mod 8"/>
  124. <xsl:value-of select="concat(1,$mod.10,$mod.9,$mod.8)"/>
  125. </xsl:function>
  126. <!--<xsl:function name="system_cache__appinfo:php_function_name_from_obj_with_prefix">
  127. <xsl:param name="object_name" required="yes"/>
  128. <xsl:value-of select="replace($object_name,':','__x3A__')"/>
  129. </xsl:function>-->
  130. </xsl:stylesheet>