procesy5_status.xsl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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:raport="procesy5_raport"
  5. exclude-result-prefixes="xs"
  6. version="2.0">
  7. <xsl:output indent="yes"/>
  8. <xsl:strip-space elements="*"/>
  9. <xsl:param name="temp" required="yes"/>
  10. <xsl:variable name="raport:df_correct">
  11. <disk raport:max_capacity="90" raport:min_free="1000"/>
  12. </xsl:variable>
  13. <xsl:template name="build_procesy5_status">
  14. <xsl:message>#13 odpalam templ $temp:<xsl:value-of select="$temp"/>; </xsl:message>
  15. <xsl:variable name="collection" select="collection(concat($temp,'/?select=*.xml'))"/>
  16. <build_procesy5_status>
  17. <xsl:apply-templates select="$collection"/>
  18. </build_procesy5_status>
  19. </xsl:template>
  20. <xsl:template match="storage_free.xml">
  21. <storage_free.xml>
  22. <xsl:apply-templates mode="df_output"/>
  23. </storage_free.xml>
  24. </xsl:template>
  25. <!-- [element]
  26. [text]
  27. [attribute]
  28. [text]
  29. [element]
  30. [comment]
  31. [processing instruction]-->
  32. <!-- <xsl:template match="empty"/> -->
  33. <xsl:template match="*|text()" mode="df_output">
  34. <xsl:variable name="df_output">
  35. <df_output>
  36. <xsl:for-each select="tokenize(.,'\n')">
  37. <xsl:if test="position() &gt; 1">
  38. <row><xsl:attribute name="pos" select="position()-1"/>
  39. <xsl:for-each select="tokenize(normalize-space(.),' ')">
  40. <el><xsl:attribute name="pos" select="position()"/>
  41. <xsl:value-of select="."/></el>
  42. </xsl:for-each>
  43. </row>
  44. </xsl:if>
  45. <xsl:if test="position() = 1">
  46. <fields>
  47. <xsl:for-each select="tokenize(normalize-space(.),' ')">
  48. <el><xsl:attribute name="pos" select="position()"/>
  49. <xsl:value-of select="."/></el>
  50. </xsl:for-each>
  51. </fields>
  52. </xsl:if>
  53. </xsl:for-each>
  54. </df_output>
  55. </xsl:variable>
  56. <raport:df>
  57. <xsl:for-each select="$df_output//row">
  58. <disk>
  59. <xsl:attribute name="{$df_output//fields/el[@pos='1']}" select="el[@pos='1']"/>
  60. <xsl:element name="{$df_output//fields/el[@pos='5']}">
  61. <xsl:if test="number(replace(el[@pos='5'],'%','')) &gt; number($raport:df_correct/disk/@raport:max_capacity)">
  62. <xsl:attribute name="error" select="'Zbyt duże wykorzystanie'"/>
  63. </xsl:if>
  64. <xsl:value-of select="el[@pos='5']"/>
  65. </xsl:element>
  66. <xsl:element name="{$df_output//fields/el[@pos='4']}">
  67. <xsl:if test="number(el[@pos='4']) &lt; number($raport:df_correct/disk/@raport:min_free)">
  68. <xsl:attribute name="error" select="'Zbyt mało wolnego miejsca'"/>
  69. </xsl:if>
  70. <xsl:value-of select="el[@pos='4']"/>
  71. </xsl:element>
  72. </disk>
  73. </xsl:for-each>
  74. </raport:df>
  75. <!--<xsl:copy-of select="$df_output"/>-->
  76. </xsl:template>
  77. </xsl:stylesheet>