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