I have the following XML document (just an excerpt):
<osm>
<node id="1" version="1" timestamp="2016-02-29T01:33:20Z" lat="0.0" lon="0.657002">
<tag k="Stat_nr" v="40045"/>
<tag k="Ortsgr_kl" v="0"/>
<tag k="Town_ID" v="0000"/>
<tag k="Name2" v="City2"/>
<tag k="Name1" v="City1"/>
<tag k="ID" v="8942835"/>
</node>
<node id="2" version="1" timestamp="2016-02-29T01:33:20Z" lat="0.93198" lon="0.000">
<tag k="Land" v="D"/>
<tag k="ID_Ref" v=""/>
<tag k="Stat_nr" v="40045"/>
<tag k="Name1" v="ExampleCity"/>
<tag k="ID" v="0000"/>
</node>
</osm>
What i would like to do is get the following result:
<osm>
<node id="1" version="1" timestamp="2016-02-29T01:33:20Z" lat="0.0" lon="0.657002">
<tag k="Stat_nr" v="40045"/>
<tag k="Name1" v="City1"/>
<tag k="ID" v="8942835"/>
<tag k="test" v="8942835"/>
</node>
<node id="2" version="1" timestamp="2016-02-29T01:33:20Z" lat="0.93198" lon="0.000">
<tag k="Stat_nr" v="40045"/>
<tag k="Name1" v="ExampleCity"/>
<tag k="ID" v="0000"/>
<tag k="test" v="0000"/>
</node>
</osm>
Delete everything except each of the following tags:
<tag k="Stat_nr">
<tag k="Name1" >
<tag k="ID" >
But also add a new tag copying the values from the k="ID" v=
:
<tag k="test" v="8942835"/>
<tag k="test" v="0000"/>
Given your XML, repaired to be well-formed by using the same case on the closing
osm
tag as the openingosm
tag,this XSLT, based on the identity transformation with one template added to squelch the requested
tag
elements and one template added to append the requestedtag
elements,will produce this XML,
as requested.