[OSM-newbies] XSLT question

Renaud MICHEL r.h.michel+osm at gmail.com
Mon Sep 14 19:30:41 BST 2009


Hello
Le lundi 14 septembre 2009 à 14:37, Andrew Errington a écrit :
> So far I have a very simple XSLT that will find all nodes (or ways,
> because a restaurant could be a node or an area) that have a tag with an
> attribute k="amenity" and an attribute v="restaurant".  I can query the
> parent node and get its id, but I really want to query the sibling nodes,
> find the one that has attribute k="name" and print the value of attribute
> v (the name itself).

You can select those elements with an xpath like

node[tag[@k='amenity' and @v='restaurant']]/tag[@k='name']

for more informations, see
http://www.w3.org/TR/xpath
http://www.w3.org/TR/xslt

If you only want the names as a flat text file, you can use a command line 
tool like xmlstarlet (http://xmlstar.sourceforge.net) and do something like

xml sel -t -m "//node[tag[@k='amenity' and @v='restaurant']]/tag[@k='name']"
        -v "@v" -o "
" file.osm

-- 
Renaud Michel




More information about the newbies mailing list