1 |
4307
|
leinfelder
|
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
|
|
<xsl:stylesheet version="1.0"
|
3 |
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
4 |
|
|
xmlns:wfs="http://www.opengis.net/wfs"
|
5 |
|
|
xmlns:gml="http://www.opengis.net/gml"
|
6 |
|
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
7 |
|
|
xmlns:mb="http://mapbuilder.sourceforge.net/mapbuilder">
|
8 |
|
|
<!--
|
9 |
|
|
Description: A stylesheet to convert flickr rest service to standards-compliant wfs.
|
10 |
|
|
Author: Andreas Hocevar andreas.hocevarATgmail.com
|
11 |
|
|
Licence: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
12 |
|
|
|
13 |
|
|
$Id: FlickrRest2Wfs.xsl 3728 2007-12-12 15:35:04Z ahocevar $
|
14 |
|
|
-->
|
15 |
|
|
|
16 |
|
|
<xsl:param name="proxyUrl"/>
|
17 |
|
|
|
18 |
|
|
<xsl:template match="rsp/photos">
|
19 |
|
|
<wfs:FeatureCollection xml:base="$proxyUrl">
|
20 |
|
|
<xsl:for-each select="photo">
|
21 |
|
|
<xsl:call-template name="featureMember"/>
|
22 |
|
|
</xsl:for-each>
|
23 |
|
|
</wfs:FeatureCollection>
|
24 |
|
|
</xsl:template>
|
25 |
|
|
|
26 |
|
|
<xsl:template name="featureMember">
|
27 |
|
|
<xsl:call-template name="point"/>
|
28 |
|
|
</xsl:template>
|
29 |
|
|
|
30 |
|
|
<xsl:template name="point">
|
31 |
|
|
<xsl:param name="photouri"><xsl:value-of select="concat($proxyUrl,'?url=http%3A//www.flickr.com/services/rest/%3Fmethod%3Dflickr.photos.getInfo%26api_key%3Dafbacfb4d14cd681c04a06d69b24d847%26photo_id%3D',@id)"/></xsl:param>
|
32 |
|
|
<xsl:param name="photodoc" select="document($photouri)/rsp"/>
|
33 |
|
|
<xsl:variable name="lon">
|
34 |
|
|
<xsl:for-each select="$photodoc/photo/tags/tag">
|
35 |
|
|
<xsl:if test="substring-before(./@raw,'=')='geo:long'">
|
36 |
|
|
<xsl:value-of select="substring-after(./@raw,'=')"/>
|
37 |
|
|
</xsl:if>
|
38 |
|
|
</xsl:for-each>
|
39 |
|
|
</xsl:variable>
|
40 |
|
|
<xsl:variable name="lat">
|
41 |
|
|
<xsl:for-each select="$photodoc/photo/tags/tag">
|
42 |
|
|
<xsl:if test="substring-before(./@raw,'=')='geo:lat'">
|
43 |
|
|
<xsl:value-of select="substring-after(./@raw,'=')"/>
|
44 |
|
|
</xsl:if>
|
45 |
|
|
</xsl:for-each>
|
46 |
|
|
</xsl:variable>
|
47 |
|
|
<xsl:if test="$lat!=''">
|
48 |
|
|
<gml:featureMember>
|
49 |
|
|
<mb:geoRssFeature>
|
50 |
|
|
<xsl:attribute name="fid"><xsl:value-of select="./@id"/></xsl:attribute>
|
51 |
|
|
<mb:geom>
|
52 |
|
|
<gml:Point>
|
53 |
|
|
<gml:coordinates><xsl:value-of select="$lon"/>,<xsl:value-of select="$lat"/></gml:coordinates>
|
54 |
|
|
</gml:Point>
|
55 |
|
|
</mb:geom>
|
56 |
|
|
<mb:title><xsl:value-of select="$photodoc/photo/title"/></mb:title>
|
57 |
|
|
<mb:description><xsl:value-of select="$photodoc/photo/description"/></mb:description>
|
58 |
|
|
<dc:date><xsl:value-of select="$photodoc/photo/dates/@taken"/></dc:date>
|
59 |
|
|
<mb:url>http://static.flickr.com/<xsl:value-of select="./@server"/>/<xsl:value-of select="./@id"/>_<xsl:value-of select="./@secret"/>_s.jpg</mb:url>
|
60 |
|
|
<mb:photopage><xsl:value-of select="$photodoc/photo/urls/url[@type='photopage']"/></mb:photopage>
|
61 |
|
|
</mb:geoRssFeature>
|
62 |
|
|
</gml:featureMember>
|
63 |
|
|
</xsl:if>
|
64 |
|
|
</xsl:template>
|
65 |
|
|
</xsl:stylesheet>
|