[OSM-dev] Tags with namespace: and invalid XML from WFS service

Jukka Rahkonen jukka.rahkonen at latuviitta.fi
Tue Nov 1 14:07:59 GMT 2011


Hi,

This is for information if somebody gets interested in setting up WFS
services. If OSM data is imported into PostGIS with osm2pgsql the
resulting attribute names containing colons (addr:streetname etc.) must be
renamed. Otherwise WFS server is creating invalid XML. Here is a start of
the WFS feature type schema without renaming.

<xs:complexType name="osm_pointType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="osm_id" type="int" nillable="true" minOccurs="0"
maxOccurs="1"/>
maxOccurs="1"/><xs:element name="access" type="string" nillable="true"
minOccurs="0" maxOccurs="1"/>
<xs:element name="addr:housenumber" type="string" nillable="true"
minOccurs="0" maxOccurs="1"/>

What happens is that osm2pgsql is converting some tags into attributes,
and WFS server is converting attributes into XML elements. "name" in XML
element is defined to be of type NCName
(http://www.w3schools.com/schema/el_element.asp) and NCName does not allow
the use of colon character
(http://stackoverflow.com/questions/1631396/what-is-an-xsncname-type-and-when-should-it-be-used).
Therefore addr:housenumber will lead to invalid XML.

There is nothing wrong with the OSM XML format, this is just a reminder
for those who would like use WFS or explode tags into <xs:element for some
other reason.

-Jukka Rahkonen-






More information about the dev mailing list