Talk:OSM to GML XSLT

From OpenStreetMap Wiki
Jump to: navigation, search

Using XSLT

The downside is that XSLT tends to be slow: XSLT processors usually build an entire DOM tree of the source XML document in memory. Worse, the template that links nodes to segments uses XPath, which results in (as best) O(n) search time for each node. Both of these properties make XSLT unsuitable for converting an entire planet.osm data dump to GML.

The performance of XSL can be improved dramatically by using an index on node id. See osmarender.xsl for a working example. The relevant lines are:

<xsl:key name='nodeById' match='/osm/node' use='@id'/>

and:

<xsl:variable name='fromNode' select='key("nodeById",$from)'/>

80n 18:55, 2 Jun 2006 (UTC)

Swapping lat/lon in the resultinh GML-file? (XML-solution)

I had to swap the lats with the lons for GRASS to read the file (via v.in.ogr) correctly. But apart from that, everything worked nice =D --Jannis 10:55, 18 December 2006 (UTC)

change to xml

I had to alter the style sheet to this to get it to render with the correct orientation.

<xsl:value-of select="$from_node/@lon"/>,<xsl:value-of select="$from_node/@lat"/> <xsl:text> </xsl:text> <xsl:value-of select="$to_node/@lon"/>,<xsl:value-of select="$to_node/@lat"/>

Conversion fails

I get the following error message when using the python converter:

Traceback (most recent call last):
 File "./osm2gml", line 143, in <module>
   xml.sax.parse( sys.stdin, osmParser )
 File "xml/sax/__init__.py", line 33, in parse
 File "xml/sax/expatreader.py", line 107, in parse
 File "xml/sax/xmlreader.py", line 123, in parse
 File "xml/sax/expatreader.py", line 207, in feed
 File "xml/sax/expatreader.py", line 301, in start_element
 File "./osm2gml", line 23, in startElement
   from_node = self.node[attr["from"]]
KeyError: u'80175'

I get it for different planet.osm files as well as for the Germany extract. -- JeLuF 03:01, 6 August 2007 (BST)

script in zipfile contains errors

The linux script in the zip does not work, this is the right syntax:

java -cp "lib/serializer.jar:lib/xsltc.jar:lib/osm2gml.jar" -Xmx512M org.apache.xalan.xsltc.cmdline.Transform -u $1 osm2gml > `basename "$1" .osm`.gml

...and the resulting GML was not readable by my GIS-Programs. Martin