example_rss.xsl 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!--
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. -->
  18. <!--
  19. Simple transform of Solr query results to RSS
  20. -->
  21. <xsl:stylesheet version='1.0'
  22. xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
  23. <xsl:output
  24. method="xml"
  25. encoding="utf-8"
  26. media-type="application/xml"
  27. />
  28. <xsl:template match='/'>
  29. <rss version="2.0">
  30. <channel>
  31. <title>Example Solr RSS 2.0 Feed</title>
  32. <link>http://localhost:8983/solr</link>
  33. <description>
  34. This has been formatted by the sample "example_rss.xsl" transform -
  35. use your own XSLT to get a nicer RSS feed.
  36. </description>
  37. <language>en-us</language>
  38. <docs>http://localhost:8983/solr</docs>
  39. <xsl:apply-templates select="response/result/doc"/>
  40. </channel>
  41. </rss>
  42. </xsl:template>
  43. <!-- search results xslt -->
  44. <xsl:template match="doc">
  45. <xsl:variable name="id" select="str[@name='id']"/>
  46. <xsl:variable name="timestamp" select="date[@name='timestamp']"/>
  47. <item>
  48. <title><xsl:value-of select="str[@name='name']"/></title>
  49. <link>
  50. http://localhost:8983/solr/select?q=id:<xsl:value-of select="$id"/>
  51. </link>
  52. <description>
  53. <xsl:value-of select="arr[@name='features']"/>
  54. </description>
  55. <pubDate><xsl:value-of select="$timestamp"/></pubDate>
  56. <guid>
  57. http://localhost:8983/solr/select?q=id:<xsl:value-of select="$id"/>
  58. </guid>
  59. </item>
  60. </xsl:template>
  61. </xsl:stylesheet>