Hello and good day dear friends

I am brandnew to GIS-Things, so please bear with me for asking a newbie question. I have an xslt that works on a split osm file[germany.osm.bz2]

i took the file called germany.osm.bz2 from this site: http://ftp5.gwdg.de/pub/misc/openstreetmap/download.geofabrik.de/ Apparently, right now, i am not at home so i cannot give you a smaller piece of this large file. Note: i splitted it with XML_Split Regarding the expected output - i want to have ALL (!!) Nodes and data that are combined with the term restaurant... HTH - (End of update.)

I am divin into the GIS-world with a headstart: As a example i I want to do is parse all elements of 'amenity' and @v='restaurant.

i visited the Doku for XAPI on Openstreetmap here: http://wiki.openstreetmap.org/wiki/Xapi

Here ive found a little example to show a map with marker (with XSL Code): http://wiki.openstreetmap.org/wiki/OpenLayers_Marker

Note: this is only an example: i guess if i can do this with one 'amenity'` - called restaurant then i can do it with others too.

My first trial: What i am currently ironing out: i have a xslt-processor that runs and gives back some results..: In other words i want to gather all "available" elements (nodes, ways and relations) to match the elements I need to rework the given filter below so that we can get all elements.... See the current XSLT - and see where i stuck..

<xsl:stylesheet version = '1.0'
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:xml_split="http://xmltwig.com/xml_split"
        xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

    <xsl:output method="text" encoding="UTF-8"/>
    <xsl:template match="/">

            <xsl:for-each select="xml_split:root/node/tag[@k='amenity' and @v='restaurant']">
            <xsl:value-of select="../@id"/>
            <xsl:text>&#x09;</xsl:text>
            <xsl:value-of select="../@lat"/>
            <xsl:text>&#x09;</xsl:text>
            <xsl:value-of select="../@lon"/>
            <xsl:text>&#x09;</xsl:text>
            <xsl:for-each select="../tag[@k='name']">
                <xsl:value-of select="@v"/>
            </xsl:for-each>
            <xsl:text>&#x0A;</xsl:text>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>

it gives back the following results and now you see where i stuck...:

"27376049   49.6499423  8.5543447   Clubhaus SC Olympia Lorsch"
"27407910   49.7045590  8.5115993   Forsthaus Jägersburg"
"27433397   51.4588114  7.0073003   Unperfekthaus"
"27433643   50.0081188  9.0691993   Schützenhaus"
"27453754   49.6358087  8.4547972   Feldschlössel"
"27474067   50.1880211  9.1742722   Pizzeria A66"
"27475403   49.0062148  8.3369945   Marty's Restaurant"
"27505752   48.4081456  11.7959129  Gasthof Nagerl"
"27530181   49.5054702  8.7089191   Zum Pflug"

I want to have a more in depth results with all tags. What modifications do I need to make to the xslt-file?

I hope that I was able to ask the question correctly. If you have any questions do not hesitate to ask..

asked 17 Apr '12, 09:09

tagtheworld's gravatar image

tagtheworld
0888
accept rate: 0%

1

Sorry for the off-topic but... Do you really need to use xslt ?

I imagine in this forum you'll find more people able to help if you use one of osm's many parsing libraries (or even a standard xml parsing library) and a for_loop in the language of your choice rather than xslt (which is a rather unpopular technology).

(17 Apr '12, 11:14) Vincent de P... ♦

hi vincent - thx for the quick help. I am pretty new to xslt and also new to xml too. but i am willing to learn - if any body can help me it would be a great pleasure to dive into another technology..

(17 Apr '12, 11:31) tagtheworld
2

To add a little more to what Vincent de P said - some XML documents are governed by strict rules as to the values that they can contain. OSM isn't really like that - there's even a wiki document expaining that you can with caveats use any tags you like.

What might help a little is if you could explain a bit about what you're trying to do with the data. It may be that there's an existing service (such as the XAPI that allows you to get at what you want rather than starting with flat XML), or it may be that you need to put the OSM data in a database optimised for the task that you want to perform (for rendering map tiles for example, there are instructions here).

The problem is that alongside the name there are manu, many other tags that might get used alongside amenity=restaurant (see here for a list). Also, have a look at the "See Also" section of the amenity=restaurant wiki page for this that an establishment might get tagged as other than "restaurant".

(17 Apr '12, 13:32) SomeoneElse ♦

hello dear SomeoneElse hello dear Vincent de p

many thanks for the answers and the hints. Great to see such support to a newbie i want to play with the data - and see how i can transform data fom one formate to another. Well if it is easy to work with XAPI or other methods - well ithougth that it would be pretty eays to enlarge the xslt to a enriched version - that covers some more entities - eg. the adress of the restaurant and some more stuff. Well i want to see how i can move the data into a database!`? Any idea or help greatly appreciated

(17 Apr '12, 21:00) tagtheworld

can i do some requests on POIs of Openstreetmap with XAPI.

doing like so: i send a request to the API-Server - over http

as a respond i get the following result - in XML

example: the following link gives back all the Nodes of the Type amenity=restaurant in XML-Format. the bounding box (bbox) limits the area:

http://xapi.openstreetmap.org/api/0.6/node[amenity=restaurant][bbox=9.4908142,48.7810801,9.5660019,48.8387351]

well i get a blank page back - this is making me wondering...

(17 Apr '12, 22:56) tagtheworld

... which continues into this question about the XAPI specificallly.

(18 Apr '12, 00:18) SomeoneElse ♦
showing 5 of 6 show 1 more comments
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×276
×79
×16
×5

question asked: 17 Apr '12, 09:09

question was seen: 2,433 times

last updated: 18 Apr '12, 00:19

powered by OSQA