2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 Simple transform of Solr query response into Solr Update XML compliant XML.
20 When used in the xslt response writer you will get UpdaateXML as output.
21 But you can also store a query response XML to disk and feed this XML to
22 the XSLTUpdateRequestHandler to index the content. Provided as example only.
23 See http://wiki.apache.org/solr/XsltUpdateRequestHandler for more info
25 <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
26 <xsl:output media-type="text/xml" method="xml" indent="yes"/>
28 <xsl:template match='/'>
30 <xsl:apply-templates select="response/result/doc"/>
34 <!-- Ignore score (makes no sense to index) -->
35 <xsl:template match="doc/*[@name='score']" priority="100">
38 <xsl:template match="doc">
39 <xsl:variable name="pos" select="position()"/>
42 <xsl:with-param name="pos"><xsl:value-of select="$pos"/></xsl:with-param>
43 </xsl:apply-templates>
47 <!-- Flatten arrays to duplicate field lines -->
48 <xsl:template match="doc/arr" priority="100">
49 <xsl:variable name="fn" select="@name"/>
51 <xsl:for-each select="*">
52 <xsl:element name="field">
53 <xsl:attribute name="name"><xsl:value-of select="$fn"/></xsl:attribute>
54 <xsl:value-of select="."/>
60 <xsl:template match="doc/*">
61 <xsl:variable name="fn" select="@name"/>
63 <xsl:element name="field">
64 <xsl:attribute name="name"><xsl:value-of select="$fn"/></xsl:attribute>
65 <xsl:value-of select="."/>
69 <xsl:template match="*"/>