lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Solr Wiki] Update of "XsltResponseWriter" by BrianWhitman
Date Mon, 19 Mar 2007 19:15:44 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The following page has been changed by BrianWhitman:
http://wiki.apache.org/solr/XsltResponseWriter

The comment on the change is:
Adding XSL 2.0 / Saxon stuff

------------------------------------------------------------------------------
  
  The performance of XSLT transforms can vary dramatically depending on how well they're written
- you've been warned.
  
+ 
+ = Using Saxon for XSLT 2.0 Transforms =
+ 
+ The XsltResponseWriter can easily be changed to use other transformers. The [http://saxon.sourceforge.net/
Saxon-B] open source XSL transformer supports XSL 2.0 features, such as URI encoding, time
and date functions, and field grouping. To change the default transformer to use Saxon, simply
copy the Saxon .jar files into your classpath and set the system property javax.xml.TransformerFactory
to "net.sf.saxon.TransfomerFactoryImpl". No changes to the Solr source are needed. For Resin,
put this in your resin.conf:
+ 
+ {{{
+         <system-property javax.xml.transform.TransformerFactory="net.sf.saxon.TransformerFactoryImpl"/>
+ }}}
+ 
+ == Grouping example ==
+ 
+ Now that you've got Saxon-B running, make sure your XSL files state the right version:
+ 
+ {{{
+ <xsl:stylesheet version='2.0'...
+ }}}
+ 
+ and you can use the best new feature for Solr users of XSL, for-each-grouping. Here I'll
group by the Solr field 'username' and show the "comments" field per document:
+ 
+ {{{
+ <?xml version='1.0' encoding='UTF-8'?>
+ <xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
+   <xsl:output media-type="text/html; charset=UTF-8" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"
/>
+   <xsl:template match='/'>
+     <xsl:for-each-group select="response/result/doc" group-by="str[@name='username']">
+       <P>Documents for: 
+         <xsl:value-of select="current-grouping-key()"/></P>
+ 	<ul>
+           <xsl:for-each select="current-group()">
+             <li><xsl:value-of select="str[@name='comments']"/></li>
+           </xsl:for-each>
+         </ul>
+       </xsl:for-each-group>
+   </xsl:template>
+ </xsl:stylesheet>
+ }}}
+ 
+ 
+ 
+ 
+ 

Mime
View raw message