common.xsl 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. Copyright MetaCommunications, Inc. 2003-2004.
  4. Distributed under the Boost Software License, Version 1.0. (See
  5. accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <xsl:stylesheet
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  10. xmlns:exsl="http://exslt.org/common"
  11. xmlns:func="http://exslt.org/functions"
  12. xmlns:str="http://exslt.org/strings"
  13. xmlns:meta="http://www.meta-comm.com"
  14. extension-element-prefixes="func"
  15. version="1.0">
  16. <xsl:variable name="output_directory" select="'output'"/>
  17. <xsl:template name="get_toolsets">
  18. <xsl:param name="toolsets"/>
  19. <xsl:param name="required-toolsets"/>
  20. <xsl:variable name="toolset_output">
  21. <xsl:for-each select="$toolsets">
  22. <xsl:variable name="toolset" select="."/>
  23. <xsl:element name="toolset">
  24. <xsl:attribute name="toolset"><xsl:value-of select="$toolset"/></xsl:attribute>
  25. <xsl:choose>
  26. <xsl:when test="$required_toolsets[ $toolset = @name ]">
  27. <xsl:attribute name="required">yes</xsl:attribute>
  28. <xsl:attribute name="sort">a</xsl:attribute>
  29. </xsl:when>
  30. <xsl:otherwise>
  31. <xsl:attribute name="required">no</xsl:attribute>
  32. <xsl:attribute name="sort">z</xsl:attribute>
  33. </xsl:otherwise>
  34. </xsl:choose>
  35. </xsl:element>
  36. </xsl:for-each>
  37. </xsl:variable>
  38. <xsl:for-each select="exsl:node-set( $toolset_output )/toolset">
  39. <xsl:sort select="concat( @sort, ' ', @toolset)" order="ascending"/>
  40. <xsl:copy-of select="."/>
  41. </xsl:for-each>
  42. </xsl:template>
  43. <func:function name="meta:show_output">
  44. <xsl:param name="explicit_markup"/>
  45. <xsl:param name="test_log"/>
  46. <func:result select="$test_log/@result != 'success' and not( meta:is_unusable( $explicit_markup, $test_log/@library, $test_log/@toolset )) or $test_log/@show-run-output = 'true'"/>
  47. </func:function>
  48. <func:function name="meta:is_test_log_a_test_case">
  49. <xsl:param name="test_log"/>
  50. <func:result select="$test_log/@test-type='compile' or $test_log/@test-type='compile_fail' or $test_log/@test-type='run' or $test_log/@test-type='run_pyd'"/>
  51. </func:function>
  52. <func:function name="meta:is_unusable">
  53. <xsl:param name="explicit_markup"/>
  54. <xsl:param name="library"/>
  55. <xsl:param name="toolset"/>
  56. <func:result select="$explicit_markup//library[ @name = $library ]/mark-unusable[ toolset/@name = $toolset or toolset/@name='*' ]"/>
  57. </func:function>
  58. <func:function name="meta:re_match">
  59. <xsl:param name="pattern"/>
  60. <xsl:param name="text"/>
  61. <xsl:choose>
  62. <xsl:when test="not( contains( $pattern, '*' ) )">
  63. <func:result select="$text = $pattern"/>
  64. </xsl:when>
  65. <xsl:when test="$pattern = '*'">
  66. <func:result select="1 = 1"/>
  67. </xsl:when>
  68. <xsl:when test="substring( $pattern, 1, 1 ) = '*' and substring( $pattern, string-length($pattern), 1 ) = '*' ">
  69. <func:result select="contains( $text, substring( $pattern, 2, string-length($pattern) - 2 ) ) "/>
  70. </xsl:when>
  71. <xsl:when test="substring( $pattern, 1, 1 ) = '*'">
  72. <xsl:variable name="pattern_tail" select="substring( $pattern, 2, string-length($pattern) - 1 )"/>
  73. <func:result select="substring( $text, string-length($text) - string-length($pattern_tail) + 1, string-length($pattern_tail) ) = $pattern_tail"/>
  74. </xsl:when>
  75. <xsl:when test="substring( $pattern, string-length($pattern), 1 ) = '*' ">
  76. <xsl:variable name="pattern_head" select="substring( $pattern, 1, string-length($pattern) - 2 )"/>
  77. <func:result select="substring( $text, 1, string-length($pattern_head) ) = $pattern_head "/>
  78. </xsl:when>
  79. </xsl:choose>
  80. </func:function>
  81. <func:function name="meta:encode_path">
  82. <xsl:param name="path"/>
  83. <func:result select="translate( translate( $path, '/', '-' ), './', '-' )"/>
  84. </func:function>
  85. <func:function name="meta:toolset_name">
  86. <xsl:param name="name"/>
  87. <func:result select="$name"/>
  88. </func:function>
  89. <func:function name="meta:output_file_path">
  90. <xsl:param name="path"/>
  91. <func:result select="concat( $output_directory, '/', meta:encode_path( $path ), '.html' )"/>
  92. </func:function>
  93. <xsl:template name="show_notes">
  94. <xsl:param name="explicit_markup"/>
  95. <xsl:param name="notes"/>
  96. <div class="notes">
  97. <xsl:for-each select="$notes">
  98. <div>
  99. <xsl:variable name="refid" select="@refid"/>
  100. <xsl:call-template name="show_note">
  101. <xsl:with-param name="note" select="."/>
  102. <xsl:with-param name="reference" select="$explicit_markup//note[ $refid = @id ]"/>
  103. </xsl:call-template>
  104. </div>
  105. </xsl:for-each>
  106. </div>
  107. </xsl:template>
  108. <xsl:template name="show_note">
  109. <xsl:param name="note"/>
  110. <xsl:param name="reference"/>
  111. <div class="note">
  112. <xsl:variable name="author">
  113. <xsl:choose>
  114. <xsl:when test="$note/@author">
  115. <xsl:value-of select="$note/@author"/>
  116. </xsl:when>
  117. <xsl:when test="$reference">
  118. <xsl:value-of select="$reference/@author"/>
  119. </xsl:when>
  120. <xsl:otherwise>
  121. <xsl:text/>
  122. </xsl:otherwise>
  123. </xsl:choose>
  124. </xsl:variable>
  125. <xsl:variable name="date">
  126. <xsl:choose>
  127. <xsl:when test="$note/@date">
  128. <xsl:value-of select="$note/@date"/>
  129. </xsl:when>
  130. <xsl:when test="$reference">
  131. <xsl:value-of select="$reference/@date"/>
  132. </xsl:when>
  133. <xsl:otherwise>
  134. <xsl:text/>
  135. </xsl:otherwise>
  136. </xsl:choose>
  137. </xsl:variable>
  138. <span class="note-header">
  139. <xsl:choose>
  140. <xsl:when test="$author != '' and $date != ''">
  141. [&#160;<xsl:value-of select="$author"/>&#160;<xsl:value-of select="$date"/>&#160;]
  142. </xsl:when>
  143. <xsl:when test="$author != ''">
  144. [&#160;<xsl:value-of select="$author"/>&#160;]
  145. </xsl:when>
  146. <xsl:when test="$date != ''">
  147. [&#160;<xsl:value-of select="$date"/>&#160;]
  148. </xsl:when>
  149. </xsl:choose>
  150. </span>
  151. <xsl:if test="$reference">
  152. <xsl:copy-of select="$reference/node()"/>
  153. </xsl:if>
  154. <xsl:copy-of select="$note/node()"/>
  155. </div>
  156. </xsl:template>
  157. </xsl:stylesheet>
粤ICP备19079148号