You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ho...@apache.org on 2006/11/29 21:27:34 UTC
svn commit: r480708 -
/incubator/solr/trunk/example/solr/conf/xslt/example.xsl
Author: hossman
Date: Wed Nov 29 12:27:33 2006
New Revision: 480708
URL: http://svn.apache.org/viewvc?view=rev&rev=480708
Log:
a few minor improvements: multi-val fields as lists, and DHTML reveal of score explanation if available
Modified:
incubator/solr/trunk/example/solr/conf/xslt/example.xsl
Modified: incubator/solr/trunk/example/solr/conf/xslt/example.xsl
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/example/solr/conf/xslt/example.xsl?view=diff&rev=480708&r1=480707&r2=480708
==============================================================================
--- incubator/solr/trunk/example/solr/conf/xslt/example.xsl (original)
+++ incubator/solr/trunk/example/solr/conf/xslt/example.xsl Wed Nov 29 12:27:33 2006
@@ -37,8 +37,8 @@
<body>
<h1><xsl:value-of select="$title"/></h1>
<div class="note">
- This has been formatted by the default query-to-html.xsl transform - use your own XSLT
- to get a nicer page
+ This has been formatted by the sample "example.xsl" transform -
+ use your own XSLT to get a nicer page
</div>
<xsl:apply-templates select="response/result/doc"/>
</body>
@@ -46,13 +46,58 @@
</xsl:template>
<xsl:template match="doc">
+ <xsl:variable name="pos" select="position()"/>
<div class="doc">
<table width="100%">
- <xsl:apply-templates/>
+ <xsl:apply-templates>
+ <xsl:with-param name="pos"><xsl:value-of select="$pos"/></xsl:with-param>
+ </xsl:apply-templates>
</table>
</div>
</xsl:template>
+ <xsl:template match="doc/*[@name='score']" priority="100">
+ <xsl:param name="pos"></xsl:param>
+ <tr>
+ <td class="name">
+ <xsl:value-of select="@name"/>
+ </td>
+ <td class="value">
+ <xsl:value-of select="."/>
+
+ <xsl:if test="boolean(//lst[@name='explain'])">
+ <xsl:element name="a">
+ <!-- can't allow whitespace here -->
+ <xsl:attribute name="href">javascript:toggle("<xsl:value-of select="concat('exp-',$pos)" />");</xsl:attribute>?</xsl:element>
+ <br/>
+ <xsl:element name="div">
+ <xsl:attribute name="class">exp</xsl:attribute>
+ <xsl:attribute name="id">
+ <xsl:value-of select="concat('exp-',$pos)" />
+ </xsl:attribute>
+ <xsl:value-of select="//lst[@name='explain']/str[position()=$pos]"/>
+ </xsl:element>
+ </xsl:if>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="doc/arr" priority="100">
+ <tr>
+ <td class="name">
+ <xsl:value-of select="@name"/>
+ </td>
+ <td class="value">
+ <ul>
+ <xsl:for-each select="*">
+ <li><xsl:value-of select="."/></li>
+ </xsl:for-each>
+ </ul>
+ </td>
+ </tr>
+ </xsl:template>
+
+
<xsl:template match="doc/*">
<tr>
<td class="name">
@@ -67,12 +112,20 @@
<xsl:template match="*"/>
<xsl:template name="css">
+ <script>
+ function toggle(id) {
+ var obj = document.getElementById(id);
+ obj.style.display = (obj.style.display != 'block') ? 'block' : 'none';
+ }
+ </script>
<style type="text/css">
body { font-family: "Lucida Grande", sans-serif }
- .doc { margin-top: 1em; border-top: solid grey 1px; }
td.name { font-style: italic; font-size:80%; }
td { vertical-align: top; }
+ ul { margin: 0px; margin-left: 1em; padding: 0px; }
.note { font-size:80%; }
+ .doc { margin-top: 1em; border-top: solid grey 1px; }
+ .exp { display: none; font-family: monospace; white-space: pre; }
</style>
</xsl:template>