include-recherche-facette.xslt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl cd67" xmlns:cd67 ="http://my.functions" >
  4. <xsl:template match="int" mode="facette">
  5. <xsl:if test=".>0">
  6. <xsl:variable name="fq"><xsl:value-of select="../@name" />:"<xsl:value-of select="@name"/>"</xsl:variable>
  7. <xsl:variable name="color">
  8. <xsl:choose>
  9. <xsl:when test="contains(/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']/.,$fq)">color1</xsl:when>
  10. <xsl:otherwise>facet-color</xsl:otherwise>
  11. </xsl:choose>
  12. </xsl:variable>
  13. <li>
  14. <a class="a-facet {$color}">
  15. <xsl:attribute name="href">
  16. ?<xsl:value-of select="$paramrecherche" />=<xsl:value-of select="$recherche" /><xsl:value-of select="$extend" />&amp;rows=<xsl:value-of select="$recordsPerPage" />&amp;start=0<xsl:apply-templates select="/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']" mode="fq">
  17. <xsl:with-param name="facette" select="$fq"></xsl:with-param>
  18. </xsl:apply-templates>
  19. <xsl:if test="contains(/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']/., $fq)=false">&amp;fq=<xsl:value-of select="../@name" />:"<xsl:value-of select="@name"/>"</xsl:if>
  20. </xsl:attribute>
  21. <xsl:if test="contains(/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']/.,$fq)">
  22. <span class="sp140 {$color}" aria-hidden="true">&#9745;</span>
  23. </xsl:if>
  24. <xsl:if test="not(contains(/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']/.,$fq))">
  25. <span class="sp140" aria-hidden="true">&#9744;</span>
  26. </xsl:if>
  27. <xsl:text> </xsl:text>
  28. <xsl:choose>
  29. <xsl:when test="string-length(substring-after(@name,'/'))!=0">
  30. <xsl:value-of select="substring-after(@name,'/')"/>
  31. </xsl:when>
  32. <!--Noms de résultats personnalisés-->
  33. <xsl:when test="@name='Marches'">Marchés</xsl:when>
  34. <xsl:otherwise>
  35. <xsl:value-of select="@name"/>
  36. </xsl:otherwise>
  37. </xsl:choose> (<xsl:value-of select="text()" />)
  38. </a>
  39. </li>
  40. </xsl:if>
  41. </xsl:template>
  42. <xsl:template match="int" mode="facette-range">
  43. <!--<xsl:if test=".>0">-->
  44. <xsl:variable name="fq"><xsl:value-of select="../../@name" />:[<xsl:value-of select="@name"/> TO <xsl:value-of select="number(@name) + (number(../../int[@name='gap'])-1)"/>]</xsl:variable>
  45. <!--<span class="no"> <xsl:value-of select="$fq"/>
  46. </span>-->
  47. <xsl:variable name="color">
  48. <xsl:choose>
  49. <xsl:when test="contains(/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']/.,$fq)">color1</xsl:when>
  50. <xsl:otherwise>facet-color</xsl:otherwise>
  51. </xsl:choose>
  52. </xsl:variable>
  53. <li>
  54. <a class="a-facet a-facet-range {$color}">
  55. <xsl:attribute name="href">
  56. ?<xsl:value-of select="$paramrecherche" />=<xsl:value-of select="$recherche" /><xsl:value-of select="$extend" />&amp;rows=<xsl:value-of select="$recordsPerPage" />&amp;start=0<xsl:apply-templates select="/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']" mode="fq">
  57. <xsl:with-param name="facette" select="$fq"></xsl:with-param>
  58. </xsl:apply-templates>
  59. <xsl:if test="contains(/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']/., $fq)=false">&amp;fq=<xsl:value-of select="../../@name" />:[<xsl:value-of select="@name"/> TO <xsl:value-of select="number(@name) + (number(../../int[@name='gap'])-1)"/>]</xsl:if>
  60. </xsl:attribute>
  61. <xsl:if test="contains(/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']/.,$fq)">
  62. <span class="sp140 {$color}" aria-hidden="true">&#9745;</span>
  63. </xsl:if>
  64. <xsl:if test="not(contains(/response/lst[@name='responseHeader']/lst[@name='params']/*[@name='fq']/.,$fq))">
  65. <span class="sp140" aria-hidden="true">&#9744;</span>
  66. </xsl:if>
  67. <xsl:text> </xsl:text>
  68. <xsl:choose>
  69. <xsl:when test="string-length(substring-after(@name,'/'))!=0">
  70. <xsl:value-of select="substring-after(@name,'/')"/>
  71. </xsl:when>
  72. <!--Noms de résultats personnalisés-->
  73. <xsl:when test="@name='Marches'">Marchés</xsl:when>
  74. <xsl:otherwise>
  75. <xsl:value-of select="@name"/> à <xsl:value-of select="number(@name) + (number(../../int[@name='gap'])-1)"/>
  76. </xsl:otherwise>
  77. </xsl:choose> (<xsl:value-of select="text()" />)
  78. </a>
  79. </li>
  80. <!--</xsl:if>-->
  81. </xsl:template>
  82. <!-- suppression des facette -->
  83. <xsl:template match="str" mode="delfacet">
  84. <a class="delfacet">
  85. <xsl:variable name="fq"><xsl:value-of select="."/></xsl:variable>
  86. <xsl:attribute name="href">
  87. ?rows=<xsl:value-of select="$recordsPerPage" />&amp;start=0<xsl:for-each select="//descendant-or-self::str[@name='fq']|//descendant-or-self::arr[@name='fq']/str"><xsl:if test="contains(., $fq)=false">&amp;fq=<xsl:value-of select="."/></xsl:if>
  88. </xsl:for-each>
  89. </xsl:attribute>
  90. <xsl:text>X </xsl:text>
  91. <xsl:value-of select="."/>
  92. </a>
  93. </xsl:template>
  94. <xsl:template match="str" mode="fq">
  95. <xsl:param name="facette" />
  96. <xsl:if test="not($facette=text())">&amp;fq=<xsl:value-of select="text()"/></xsl:if>
  97. </xsl:template>
  98. <xsl:template match="arr" mode="fq">
  99. <xsl:param name="facette" />
  100. <xsl:apply-templates select="str" mode="fq">
  101. <xsl:with-param name="facette" select="$facette"></xsl:with-param>
  102. </xsl:apply-templates>
  103. </xsl:template>
  104. <xsl:template match="str" mode="facet">&amp;fq=<xsl:value-of select="."/></xsl:template>
  105. </xsl:stylesheet>