This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Transforming XML output from XAPI search

1
1

I want to create a relation for a river. I do a XAPI name tag search and save the XML file in my computer. How do I transform the XML - I need to filter way ids and transform them into XML relation members for input with RawEditor. I have an XSLT stylesheet ready but I have trouble displaying the result in Firefox (shows blank page).

The stylesheet is here:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/osm">
  <relation>
    <xsl:apply-templates select="way"/>
  </relation>
</xsl:template>

<xsl:template match="way">
  <member type="way" ref="{@id}"/>
</xsl:template>

</xsl:stylesheet>

asked 02 Oct '11, 18:49

Kozuch's gravatar image

Kozuch
1.7k587285
accept rate: 8%


One Answer:

0

I wouldn't worry about XML transformations, myself - you're just after filling in the list for the rawedit upload, so that's a bunch of lines like:

<member type="way" ref="1234" role=""/>

I'd create a list of ways that you want to use from the XAPI output and then convert into the required "member" list using an editing macro in your favourite text editor. Obviously you'll then need to check the list of omissions and things that shouldn't be in it manually (have a look at the wiki "browserelation" links).

Then, re-order in the order that you want by following EdLoach's answer to this question.

answered 03 Oct '11, 13:08

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866
accept rate: 16%

I just found an XSL processor called SAXON which works great with the stylesheet. Or is there easier way how to filter the the ways out of a XAPI search result?

(03 Oct '11, 13:43) Kozuch

To filter the ways out of an XAPI search result, I'd use "grep" (or "find matching lines" in editor-of-your-choice) myself, but if SAXON works for you, that's great too.

(03 Oct '11, 14:05) SomeoneElse ♦

Source code available on GitHub .