Skip to content

Instantly share code, notes, and snippets.

@steko
Last active September 29, 2015 20:48
Show Gist options
  • Save steko/1665666 to your computer and use it in GitHub Desktop.
Save steko/1665666 to your computer and use it in GitHub Desktop.
XSL to extract data from a msGMLOutput XML response

This XSL tries to force the response from a WMS server and get a complete XML instead of a styled HTML page.

Why this works

The URL is like

http://www.cartografiarl.regione.liguria.it/CartoWebNet/CwGetFeatureInfo.aspx?FILE=E:\\Progetti\\MapServer\\tmp\\2053ebdc-2f9f-4adc-99d8-7feae362e11e.gml&XslUrl=http://steko.ominiverdi.org/elettro.xsl

(and lots of other useless bloat parameters that I removed for my own sanity). The XSL can be changed as a parameter, and the server will accept any valid URL (so silly, you say).

Unfortunately, this doesn't seem to work. For some reason, Mapserver is apparently used to generate a GML file without any geospatial attributes.

Most standard templates to get an identity copy of the original XML fail.

Please note that the GML file path is really a temporary file, so after the session has expired it won't work. You need to pass through a WMSGetInfo request.

See also [this thread]/(http://lists.gfoss.it/pipermail/gfoss/2013-May/027445.html) from the GFOSS mailing list.

<GDAL_WMS>
<Service name="WMS">
<Version>1.3.0</Version>
<ServerUrl>http://www.cartografiarl.regione.liguria.it/MapServer/mapserv.exe?MAP=E:\Progetti\mapfiles\repertoriocartografico\INFRASTRUTTURE\1077GC.map&</ServerUrl>
<Layers>M1077</Layers>
<Styles>default</Styles>
</Service>
<DataWindow>
<UpperLeftX>9</UpperLeftX>
<UpperLeftY>44.0</UpperLeftY>
<LowerRightX>10.0</LowerRightX>
<LowerRightY>43.8</LowerRightY>
<SizeX>640</SizeX>
<SizeY>480</SizeY>
</DataWindow>
<Projection>EPSG:4326</Projection>
<BlockSizeX>256</BlockSizeX>
<BlockSizeY>256</BlockSizeY>
<BandsCount>3</BandsCount>
</GDAL_WMS>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gml="http://www.opengis.net/gml">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:for-each select="*">
<body>
<xsl:copy-of select="./*"/>
</body>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
http://www.cartografiarl.regione.liguria.it/MapServer/mapserv.exe?MAP=E:\Progetti\mapfiles\repertoriocartografico\INFRASTRUTTURE\1077GC.map&service=WMS&version=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&CRS=EPSG:4326&BBOX=9,43.8,10,44.0&WIDTH=640&HEIGHT=480&LAYERS=L2726&STYLES=default

This is the URL to query the WMS server. It doesn't work, because it just gives a blank image. The reason is stated here: http://mapserver.org/ogc/wms_server.html#coordinate-systems-and-axis-orientation

not working:

http://www.cartografiarl.regione.liguria.it/MapServer/mapserv.exe?MAP=E:\Progetti\mapfiles\repertoriocartografico\INFRASTRUTTURE\1077GC.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=9,43.8,10,44.0&CRS=CRS:84&WIDTH=640&HEIGHT=480&LAYERS=L2726&STYLES=&FORMAT=image/png

working (notice the double BBOX=BBOX=): http://www.cartografiarl.regione.liguria.it/MapServer/mapserv.exe?MAP=E:\Progetti\mapfiles\repertoriocartografico\INFRASTRUTTURE\1077GC.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=BBOX=9,43.8,10,44.0&CRS=CRS:84&WIDTH=640&HEIGHT=480&LAYERS=L2726&STYLES=&FORMAT=image/png

BBOX=43.8,9.0,44.0,10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment