Why not ask your question on the new OpenStreetMap Community Forum?

For doing some tests with xslt i want to run a request to find out certain entity - let us take for example the restaurants. we want to find out all the restaurants in the area.

now we can run that directly on the bz2 compressed file, that we downloaded - for example if we use the following code:

bzcat germany.osm.bz2 | xsltproc restaurants.xslt - > restaurants,csv

well i splitted the file with xml_split -which is a great perl-module from CPAN.

The problem: with the following xslt-processor i get only bad results - the parsed files werent not parsed enough i only get a minor set of informations when i run the code on a xml-file. see the xslt-processor - and below - a litte data-chunk out of the file i run and parse if you want to check it - just get the little dataset - note it is a splitted file

here you can get it: https://rapidshare.com/#!download|643p12|2523227518|germany-001.xml|100000

Note: see therefore the important lines: xmlns:xml_split="http://xmltwig.com/xml_split"and this one here:

Note: here we have a much more little-file which is very very small - compared with the one that is mentioned above. https://rapidshare.com/files/2447253717/germany-081.xml Here we have the xslt-processor that has difficulties with gathering theinformation - the xslt-procssor should be reengineerd a bit. well i tried seferal things ... but at the moment i got stuck some how...:

Some musings regarding the overhaul of the code: well at least it looks like the code needs an overhaul. hmmm - i should consider changing the code to make it clearer and avoid errors. Well above all: i think i should make useage of XPaths like select="tag/@id" and tag[@k='country']/@v. But above all - i really think that i should consider refactoring this code to make better use of template. What do you think..

Below i show you the code that runs against the two files - mainly against this one here: https://rapidshare.com/files/2447253717/germany-081.xml

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" />
<xsl:template match="/">
    <xsl:apply-templates />
<xsl:template match="osm">
    <xsl:apply-templates />
<xsl:template match="node[tag[@k='amenity' and @v='restaurant']]">
    <xsl:value-of select="./@id"/>
    <xsl:value-of select="./@lat"/>
    <xsl:value-of select="./@lon"/>
    <xsl:value-of select="./tag[@k = 'cuisine']/@v"/>
    <xsl:value-of select="./tag[@k = 'name']/@v"/>
    <xsl:value-of select="./tag[@k = 'wheelchair']/@v"/>
    <xsl:value-of select="./tag[@k = 'website']/@v"/>
    <xsl:value-of select="./tag[@k = 'addr:country']/@v"/>
<xsl:value-of select="./tag[@k = 'addr:city']/@v"/>
    <xsl:value-of select="./tag[@k = 'addr:street']/@v"/>
    <xsl:value-of select="./tag[@k = 'addr:housenumber']/@v"/>

<!-- all non-restaurant nodes -->
<xsl:template match="node[tag[@k='amenity' and @v!='restaurant']]" />

how to rework the xslt in order to work smooothly?

and here below we have a data-chunk out of the xml-file that we have parsed: see it

<node id="52768810" lat="48.2044749" lon="11.3249434" version="7" changeset="9490517" user="wheelmap_visitor" uid="290680" timestamp="2011-10-07T20:24:46Z">
    <tag k="addr:city" v="Olching" />
    <tag k="addr:country" v="DE" />
    <tag k="addr:housenumber" v="72" />
    <tag k="addr:postcode" v="82140" />
    <tag k="addr:street" v="Hauptstraße" />
    <tag k="amenity" v="restaurant" />
    <tag k="cuisine" v="mexican" />
    <tag k="email" v="info@cantina-olching.de" />
    <tag k="name" v="La Cantina" />
    <tag k="opening_hours" v="Mo-Su 17:00-01:00" />
    <tag k="phone" v="+49 (8142) 444393" />
    <tag k="website" v="http://www.cantina-olching.com/" />
    <tag k="wheelchair" v="no" />

see the results - note there are missing some parts - unfortunatly.. Question: How can we rearrange and reengineer the code so that it procudes better results on the above mentioned files:

By the way:here you can get it:



asked 28 Apr '12, 18:24

tagtheworld's gravatar image

accept rate: 0%

closed 28 Apr '12, 19:44

Frederik%20Ramm's gravatar image

Frederik Ramm ♦

help.osm.org is not the best place to ask questions about xslt or other general problems not related to gis. You may find other sites that have more xslt experts than osm, like http://stackoverflow.com/

(28 Apr '12, 19:27) Gnonthgol ♦

The question has been closed for the following reason "Question is off-topic or not relevant - This is not an XSLT help forum." by Frederik Ramm 28 Apr '12, 19:44

Follow this question

By Email:

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



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:


question asked: 28 Apr '12, 18:24

question was seen: 2,345 times

last updated: 28 Apr '12, 19:44

powered by OSQA