The ST_AsGML() function
The ST_AsGML() function returns the Geography Markup Language (GML) representation of an ST_Geometry spatial type that conforms to either the GML2 or GML3 standard.
Typically, you use the ST_AsGML() function
to retrieve the GML representation of a spatial primitive from the
server and send it to a client, specifying the GML version to use.
For example:
SELECT ST_AsGML(geomcol, 3) FROM mytable
Syntax
ST_AsGML(p ST_Geometry, int Version)
Version
is
the GML version that is used to encode the returned geometry. Specify 2
for
GML2 and 3
for GML3. The default is 2
.
Return type
ST_Geometry
Example
The
first example returns a geometry from the mypoints table as
a GML2 representation. The second example returns the geometry as
a GML3 representation.
SELECT id, ST_AsGML(pt,2) FROM mypoints WHERE id=1
id 1
<gml:Point> <gml:coord><gml:X>-95.7</gml:X>
<gml:Y>38.1</gml:Y></gml:coord></gml:Point>
SELECT id, ST_AsGML(pt,3) AS gml_v32arg, ST_AsGML(pt)
AS gml_v31arg FROM mypoints WHERE id=1
id 1
gml_v32arg <gml:Point><gml:pos>-95.7 38.1</gml:pos></gml:Point>
gml_v31arg <gml:Point><gml:pos>-95.7 38.1</gml:pos></gml:Point>
The $INFORMIXDIR/extend/spatial.version/examples/gml directory contains more information about how to use an XML parser to validate the results of this function.