p5dg.filepath.xsl 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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:p5dg="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/documentation_generator/documentation_generator.xsd"
  5. xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
  6. xmlns:SystemObjects__x3A__File="https://biuro.biall-net.pl/wfs/default_db/SystemObjects/File.xsd"
  7. xmlns:p5ant-interface-resp="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/ant_interface/ant_interface-resp.xsd"
  8. xmlns:p5ant="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache.public/ant/ant.xsd"
  9. xmlns:object_merge_ant_object="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/object_merge_ant_object.xsd"
  10. exclude-result-prefixes="xs"
  11. version="2.0">
  12. <xsl:output indent="yes"/>
  13. <xsl:strip-space elements="*"/>
  14. <!--<xsl:import-schema schema-location="repository/p5dg.documentation.files.antstructure-resp.xsd" namespace="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/ant_interface/ant_interface-resp.xsd"/>-->
  15. <xsl:function name="p5dg:filepath.clean">
  16. <xsl:param name="p5dg:filepath"/>
  17. <xsl:variable name="clean" select="replace($p5dg:filepath,'//','/')"/>
  18. <xsl:variable name="out">
  19. <xsl:for-each select="tokenize($clean,'/')">
  20. <xsl:choose>
  21. <!--<xsl:when test="position() = 1 and string-length(.) &gt; 0">
  22. <xsl:value-of select="concat('/',.)"/>
  23. </xsl:when>-->
  24. <xsl:when test="position() = last() and string-length(.) = 0">
  25. <xsl:value-of select="."/>
  26. </xsl:when>
  27. <xsl:otherwise >
  28. <xsl:value-of select="concat('/',.)"/>
  29. </xsl:otherwise>
  30. </xsl:choose>
  31. </xsl:for-each>
  32. </xsl:variable>
  33. <xsl:value-of select="replace($out,'//','/')"/>
  34. </xsl:function>
  35. <xsl:function name="p5dg:filepath.dir">
  36. <xsl:param name="p5dg:filepath"/>
  37. <xsl:variable name="out">
  38. <xsl:for-each select="tokenize($p5dg:filepath,'/')[ position() &lt; count(tokenize($p5dg:filepath,'/'))]">
  39. <xsl:choose>
  40. <xsl:when test="position() = last()">
  41. <xsl:value-of select="."/>
  42. </xsl:when>
  43. <xsl:otherwise>
  44. <xsl:value-of select="concat(.,'/')"/>
  45. </xsl:otherwise>
  46. </xsl:choose>
  47. </xsl:for-each>
  48. </xsl:variable>
  49. <xsl:value-of select="$out"/>
  50. </xsl:function>
  51. <xsl:function name="p5dg:filepath.dir">
  52. <xsl:param name="p5dg:filepath"/>
  53. <xsl:param name="p5dg.documentation.files.index.root_dir"/>
  54. <xsl:value-of select="p5dg:filepath.clean(p5dg:filepath.dir.task($p5dg:filepath,$p5dg.documentation.files.index.root_dir))"/>
  55. </xsl:function>
  56. <xsl:function name="p5dg:filepath.dir.task">
  57. <xsl:param name="p5dg:filepath"/>
  58. <xsl:param name="p5dg.documentation.files.index.root_dir"/>
  59. <xsl:variable name="out">
  60. <xsl:value-of select="$p5dg.documentation.files.index.root_dir"/><xsl:value-of select="'/'"/>
  61. <xsl:for-each select="tokenize($p5dg:filepath,'/')[ position() &lt; count(tokenize($p5dg:filepath,'/'))]">
  62. <xsl:choose>
  63. <xsl:when test="position() = last()">
  64. <xsl:value-of select="."/>
  65. </xsl:when>
  66. <xsl:otherwise>
  67. <xsl:value-of select="concat(.,'/')"/>
  68. </xsl:otherwise>
  69. </xsl:choose>
  70. </xsl:for-each>
  71. </xsl:variable>
  72. <xsl:value-of select="$out"/>
  73. </xsl:function>
  74. <xsl:function name="p5dg:filename">
  75. <xsl:param name="p5dg:filepath"/>
  76. <xsl:value-of select="tokenize($p5dg:filepath,'/')[ position() = count(tokenize($p5dg:filepath,'/'))]"/>
  77. </xsl:function>
  78. <xsl:function name="p5dg:filename.noext">
  79. <xsl:param name="p5dg:filepath"/>
  80. <xsl:variable name="out">
  81. <xsl:for-each select="tokenize(p5dg:filename($p5dg:filepath),'\.')">
  82. <xsl:choose>
  83. <xsl:when test="position()=1 and position()=last()">
  84. <xsl:value-of select="."/>
  85. </xsl:when>
  86. <xsl:when test="position()=last()"></xsl:when>
  87. <xsl:when test="position()=(last() -1 )">
  88. <xsl:value-of select="."/>
  89. </xsl:when>
  90. <xsl:otherwise>
  91. <xsl:value-of select="."/><xsl:text>.</xsl:text>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. </xsl:for-each>
  95. </xsl:variable>
  96. <xsl:copy-of select="$out"/>
  97. </xsl:function>
  98. </xsl:stylesheet>