Created
November 15, 2012 17:25
-
-
Save tf0054/4079923 to your computer and use it in GitHub Desktop.
solr-xslt file for making kml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version='1.0' encoding='UTF-8'?> | |
| <!-- | |
| * Licensed to the Apache Software Foundation (ASF) under one or more | |
| * contributor license agreements. See the NOTICE file distributed with | |
| * this work for additional information regarding copyright ownership. | |
| * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| * (the "License"); you may not use this file except in compliance with | |
| * the License. You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and | |
| * limitations under the License. | |
| --> | |
| <!-- | |
| Simple transform of Solr query results to HTML | |
| http://localhost:8983/solr/tweets/select?q=account:Metal_Oyaji&wt=xslt&tr=kml.xsl&indent=true&rows=1000 | |
| --> | |
| <xsl:stylesheet version='1.0' | |
| xmlns:xsl='http://www.w3.org/1999/XSL/Transform' | |
| > | |
| <xsl:output method="xml" indent="yes" /> | |
| <xsl:variable name="title" select="concat('Solr search results (',response/result/@numFound,' documents)')"/> | |
| <xsl:template match='/'> | |
| <kml xmlns="http://www.opengis.net/kml/2.2"> | |
| <Document> | |
| <xsl:apply-templates select="response/result/doc"/> | |
| </Document> | |
| </kml> | |
| </xsl:template> | |
| <xsl:template match="doc"> | |
| <xsl:variable name="pos" select="position()"/> | |
| <xsl:if test="str[@name='geo_lonlat']"> | |
| <Placemark> | |
| <xsl:apply-templates> | |
| <xsl:with-param name="pos"><xsl:value-of select="$pos"/></xsl:with-param> | |
| </xsl:apply-templates> | |
| </Placemark> | |
| </xsl:if> | |
| </xsl:template> | |
| <xsl:template match="doc/*"> | |
| </xsl:template> | |
| <xsl:template match="doc/str[@name='geo_lonlat']"> | |
| <Point> | |
| <coordinates> | |
| <xsl:value-of select="."/> | |
| </coordinates> | |
| </Point> | |
| </xsl:template> | |
| <xsl:template match="doc/str[@name='account']"> | |
| <name> | |
| <xsl:value-of select="."/> | |
| </name> | |
| </xsl:template> | |
| <xsl:template match="doc/str[@name='content']"> | |
| <description> | |
| <xsl:value-of select="."/> | |
| </description> | |
| </xsl:template> | |
| <xsl:template match="*"/> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment