Skip to content

Instantly share code, notes, and snippets.

@andrewshadura
Created January 22, 2014 11:06

Revisions

  1. andrewshadura created this gist Jan 22, 2014.
    37 changes: 37 additions & 0 deletions fix-narrow.xslt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exslt="http://exslt.org/common"
    xmlns:math="http://exslt.org/math"
    xmlns:date="http://exslt.org/dates-and-times"
    xmlns:func="http://exslt.org/functions"
    xmlns:set="http://exslt.org/sets"
    xmlns:str="http://exslt.org/strings"
    xmlns:dyn="http://exslt.org/dynamic"
    xmlns:saxon="http://icl.com/saxon"
    xmlns:xalanredirect="org.apache.xalan.xslt.extensions.Redirect"
    xmlns:xt="http://www.jclark.com/xt"
    xmlns:libxslt="http://xmlsoft.org/XSLT/namespace"
    xmlns:test="http://xmlsoft.org/XSLT/"
    extension-element-prefixes="exslt math date func set str dyn saxon xalanredirect xt libxslt test"
    exclude-result-prefixes="math str">
    <xsl:output omit-xml-declaration="no" indent="yes"/>
    <xsl:param name="inputFile">-</xsl:param>
    <xsl:template match="/">
    <xsl:call-template name="t1"/>
    </xsl:template>
    <xsl:template name="t1">
    <osm version='0.6' upload='true' generator='JOSM'>
    <xsl:copy-of select="/osm/bounds"/>
    <xsl:copy-of select="/osm/node"/>
    <xsl:for-each select="/osm/way/tag[@k='addr:conscriptionnumber']/../tag[@k='addr:streetnumber']/..">
    <way id='{@id}' version='{number(@version+0)}' changeset='{@changeset}' action='modify'>
    <xsl:copy-of select="./nd"/>
    <xsl:copy-of select="./tag[@k!='addr:housenumber']"/>
    <tag k="addr:housenumber" v="{./tag[@k='addr:streetnumber']/@v}"/>
    </way>
    </xsl:for-each>
    <xsl:copy-of select="/osm/relation"/>
    </osm>
    </xsl:template>
    </xsl:stylesheet>

    37 changes: 37 additions & 0 deletions fix-wide.xslt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exslt="http://exslt.org/common"
    xmlns:math="http://exslt.org/math"
    xmlns:date="http://exslt.org/dates-and-times"
    xmlns:func="http://exslt.org/functions"
    xmlns:set="http://exslt.org/sets"
    xmlns:str="http://exslt.org/strings"
    xmlns:dyn="http://exslt.org/dynamic"
    xmlns:saxon="http://icl.com/saxon"
    xmlns:xalanredirect="org.apache.xalan.xslt.extensions.Redirect"
    xmlns:xt="http://www.jclark.com/xt"
    xmlns:libxslt="http://xmlsoft.org/XSLT/namespace"
    xmlns:test="http://xmlsoft.org/XSLT/"
    extension-element-prefixes="exslt math date func set str dyn saxon xalanredirect xt libxslt test"
    exclude-result-prefixes="math str">
    <xsl:output omit-xml-declaration="no" indent="yes"/>
    <xsl:param name="inputFile">-</xsl:param>
    <xsl:template match="/">
    <xsl:call-template name="t1"/>
    </xsl:template>
    <xsl:template name="t1">
    <osm version='0.6' upload='true' generator='JOSM'>
    <xsl:copy-of select="/osm/bounds"/>
    <xsl:copy-of select="/osm/node"/>
    <xsl:for-each select="/osm/way/tag[@k='addr:conscriptionnumber']/..">
    <way id='{@id}' version='{number(@version+0)}' changeset='{@changeset}' action='modify'>
    <xsl:copy-of select="./nd"/>
    <xsl:copy-of select="./tag[@k!='addr:housenumber']"/>
    <tag k="addr:housenumber" v="{./tag[@k='addr:conscriptionnumber']/@v}{substring('/',0 != string-length(./tag[@k='addr:streetnumber']/@v),1)}{./tag[@k='addr:streetnumber']/@v}"/>
    </way>
    </xsl:for-each>
    <xsl:copy-of select="/osm/relation"/>
    </osm>
    </xsl:template>
    </xsl:stylesheet>