Returns the XML representation of an ST_Geometry value.
geometry-expression.ST_AsXML([ format])
Name | Type | Description |
---|---|---|
format |
VARCHAR(128) |
A string defining the output text format to use when converting the geometry-expression to an XML representation. If not specified, the st_geometry_asxml_format option is used to choose the XML representation. See st_geometry_asxml_format option. |
LONG VARCHAR Returns the XML representation of the geometry-expression.
The ST_AsXML method returns an XML string representing the geometry. GML, KML and SVG are the supported XML formats. The format parameter specifies parameters that control the conversion to XML. If format is not specified, the value of the st_geometry_asxml_format option is used to select the output format. See st_geometry_asxml_format option.
The format string defines an output format and parameters to the format. The format string has one of the following formats:
format-name |
format-name(parameter1=value1;parameter2=value2;...) |
parameter1=value1;parameter2=value2;... |
The first format specifies the format name and no parameters. All format parameters use their default values. The second format specifies the format name and a list of named parameter values. Parameters that are not supplied use their default values. The last format specifies only parameter values, and the format name defaults to 'GML'.
The following format names may be used:
GML The Geography Markup Language format defined by ISO 19136 and the OGC.
KML The Keyhole Markup Language format defined by the OGC.
SVG The Scalable Vector Graphics (SVG) 1.1 format defined by the World Wide Web Consortium (W3C).
The following format parameters can be specified:
Format Name | Parameter Name | Default Value | Allowed Values | Description |
---|---|---|---|---|
GML | Version | 3 |
|
The version parameter controls the version of the GML specification used. |
GML | Namespace | none |
|
The namespace parameter specifies the output format convention for namespace. |
GML | SRSNameFormat | short |
|
The SRSNameFormat parameter specifies the format for the srsName attribute. |
GML | SRSDimension | No | Yes or No | The SRSDimension parameter specifies the number of coordinate values for the given geometry. This only applies to GML(version=3). |
GML | SRSFillAll | No | Yes or No | The SRSFillAll parameter specifies whether or not SRS attributes should be propagated to child geometry elements. As an example a MultiGeometry or MultiPolygon would propagate the attributes to its child geometries. |
GML | UseDeprecated | No | Yes or No | The UseDeprecated parameter only applies to GML(version=3). It is used to output older GML representations where possible. As an example a Surface may be output as a Polygon if the geometry contains no CircularStrings. |
GML | Attribute | Automatically generated optional attributes | One or more attributes may be specified for the top level geometry element only | Any legal XML attributes may be specified. |
GML | SubElement | Automatically generated GML sub elements | One or more sub elements may be specified for the top level geometry element only | Any legal XML elements may be specified. |
KML | Version | 2 | 2 | KML version 2.2 is supported. |
KML | Attribute | Automatically generated optional attributes | One or more attributes may be specified for the top level geometry element only | Any legal XML attributes may be specified. |
KML | Namespace | none |
|
The namespace parameter specifies the output format convention for namespace. |
KML | SubElement | Automatically generated KML sub elements | One or more sub elements may be specified for the top level geometry element only | Any legal XML elements may be specified. As an example extrude, tessellate and altitudeMode elements may be specified. |
SVG | Approximate | Yes | Yes or No | The Approximate parameter specifies whether or not to reduce the size of the output SVG document with a slight reduction in visible detail. The SVG data is approximated by not including points which are within the line width of the last point. With multiple megabyte geometries this can result in compression rates of 80% or more. |
SVG | Attribute | Automatically generated optional attributes | One or more SVG attributes that can be applied to SVG shape elements | By default, optional SVG shape attributes such as fill, stroke and stroke-width are generated. If the Attributes parameter is specified, then no optional SVG shape attributes are generated, and the Attribute value is used instead. Ignored if PathDataOnly=Yes is specified. The maximum length of the Attribute value is about 1000 bytes. |
SVG | DecimalDigits | Based on the number of decimal digits in the spatial reference system's snap to grid grid-size. The maximum default value is 5 and the minimum is 0. | integer | The DecimalDigits parameter limits the number of digits after the decimal place for coordinates generated in the SVG output. Specifying a negative number of digits indicates that the full precision of coordinates should be included in the SVG output. |
SVG | PathDataOnly | No (a complete SVG document is generated) | Yes or No | The PathDataOnly parameter specifies whether or not only data for the SVG Path Element should be generated. The PathDataOnly example below demonstrates how PathDataOnly=Yes can be used to build a complete SVG document that can be displayed. By default a complete SVG document is generated. The path data returned by PathDataOnly=Yes can be used to build more flexible SVG documents containing other elements, such as text. |
SVG | RandomFill | Yes | Yes or No | The RandomFill parameter specifies whether or not polygons should be filled by a randomly generated color. The sequence of colors used does not follow a well-defined sequence, and typically changes each time SVG output is generated. No indicates that only an outline of each polygon is drawn. The RandomFill parameter is ignored if the Attribute or PathDataOnly=Yes parameter is specified. |
SVG | Relative | Yes | Yes or No | The Relative parameter specifies if coordinates should be output in relative (offset) or absolute formats. Relative coordinate data is typically more compact than absolute coordinate data. |
When converting a geometry value to XML, the server uses the ST_AsXML method. The st_geometry_asxml_format option defines the format that is used for the conversion. See st_geometry_asxml_format option.
By default, ST_AsXML uses the original format for a geometry, if it is available. Otherwise, the internal format is used. For more information about internal and original formats, see STORAGE FORMAT clause, CREATE SPATIAL REFERENCE SYSTEM statement.
SQL/MM (ISO/IEC 13249-3: 2006) Vendor extension
If the st_geometry_asxml_format option has its default value of 'GML', then the following returns the result <Point srsName="EPSG:4326"><pos>1 2 3 4</pos></Point>
.
SELECT NEW ST_Point( 1.0, 2.0, 3.0, 4.0, 4326 ).ST_AsXML() |
If the st_geometry_asxml_format option has its default value of 'GML', then the following returns the result <Point srsName="EPSG:4326"><pos>1 2 3 4</pos></Point>
.
SELECT CAST( NEW ST_Point( 1.0, 2.0, 3.0, 4.0, 4326 ) AS XML) |
The following example returns the result <Point srsName="EPSG:4326"><coordinates>1,2</coordinates></Point>
.
SELECT NEW ST_Point( 1.0, 2.0, 3.0, 4.0, 4326 ).ST_AsXML('GML(Version=2)') |
The following returns a complete SVG document with polygons filled with random colors.
SELECT NEW ST_Polygon( 'Polygon(( 0 0, 0 20, 60 10, 0 0 ))' ) .ST_AsXML( 'SVG' ) |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |