Styling a WMS GetFeatureInfo response with ArcGIS Server 10

The GetFeatureInfo operation on a WMS is designed to return attributes of features in the map. The WMS spec doesn’t really define the schema for the GetFeatureInfo response, so you’ll see it handled differently as you look at various WMS implementations. With an ArcGIS Server WMS, you can request the feature info in various formats, including HTML, XML, and plain text.

For example, here’s a GetFeatureInfo request along with its response in the default HTML format:




Default GetFeatureInfo response

In many cases, the default response in HTML, XML, or plain text may be good enough for your own purposes, but there may be times when you want to customize the response format or schema. Perhaps you want your own look and feel to the response, or for interoperability reasons maybe you want to get the feature information back in a standard schema like GML or GeoJSON.

In ArcGIS Server 10, both server administrators and WMS clients can customize the GetFeatureInfo response using XSLT templates. This blog post explains the basic steps.


When you work with a WMS created by ArcGIS Server, the GetFeatureInfo response is generated by applying an XSLT template on a raw internal XML format. This internal XML just contains a list of fields and values of identified features. A default XSLT template for the particular format (HTML, text, etc.) is applied to make the final response look readable.

Knowing this workflow, you can customize both the format and schema of the GetFeatureInfo response. You need to understand:

  • The raw internal XML format of the ArcGIS Server WMS GetFeatureInfo response
  • The default XSLT templates that come with ArcGIS Server for the different types of supported formats

Let’s tackle these one at a time.

The raw internal XML format

Here’s an example of the raw internal XML GetFeatureInfo response from an ArcGIS Server 10.0-produced WMS:

<?xml version="1.0" encoding="UTF-8"?>
<esri_wms:FeatureInfoResponse version="1.3.0" xmlns:xsi="" xmlns:esri_wms="" xmlns="">
  <esri_wms:FeatureInfoCollection layername="fields">
        <!-- there could be more <esri_wms:Field> -->
    <!-- there could be more <esri_wms:FeatureInfo> -->
  <!-- there could be more <esri_wms:FeatureInfoCollection> -->

Notice that:

  • The root tag <FeatureInfoResponse> can contain multiple <FeatureInfoCollection> elements.
  • Each <FeatureInfoCollection> element contains the attribute fields and values of all identified features from a single WMS layer.
  • The information for a single identified feature is contained in a <FeatureInfo> tag. Notice the name-value pair for each field.

Since the whole idea of XSLT transformation involves converting one format of information to another, it’s really important to take some time to understand the above format before you continue.

Default XSLT templates in ArcGIS Server

The ArcGIS Server 10.0 installation comes with XSLT templates for the supported formats listed in the WMS’s capabilities files. You can see these default templates if you open <ArcGIS Server install location>StylesWMS. As indicated by their names, each template is used to produce the default GetFeatureInfo response in a given format. In example at the beginning of this post, the HTML table with the blue caption was produced thanks to the default XSLT for the HTML format.

XSLT templates in ArcGIS Server 10

If you ever need to get the raw XML as the response, you can set the GetFeatureInfo request parameter INFO_FORMAT to application/vnd.esri.wms_raw_xml. You might do this if you wanted to create your own template and you needed some understanding of the raw format.

How to customize your WMS GetFeatureInfo response

Given all of the information above, let’s explore a couple of ways you can customize the WMS GetFeatureInfo response in ArcGIS Server 10.0.

Modify the default XSLT templates in ArcGIS Server

You’ve seen where the default XSLT templates live, and one option is to just open them up and start tweaking the styles to fit your liking. Remember, though, that if you change these templates, it will affect any WMS published through ArcGIS Server. For this reason, avoid trying to put any map-service-specific logic into the templates.

Here’s an example change to featureinfo_text_html.xsl, the HTML template. If you opened the file in a text editor and replaced the <Style> tag with the following, you would see the table caption color change to red.

  <style type="text/css">
          table, th, td {
            border:1px solid #e5e5e5;
            font-family: arial;
            font-size: 80%;
            color: #333333
          th, td {
            valign: top;
            text-align: center;
          th {
            background-color: #ffb7b7
          caption {
            border:1px solid #e5e5e5;
            font-family: arial;
            font-weight: bold;
            font-size: 80%;
            text-align: left;
            color: #333333;

An example response using this template would look like this:

Default GetFeatureInfo response customized with red 

Override the behavior of the default XSLT template using the xslt_template parameter

xslt_template is an Esri-specific parameter that you can set to the URL of an XSLT template file. The ArcGIS Server-produced WMS will then pick up the template and override the default template.

When using the xslt_template parameter, your XSLT template doesn’t have to follow the same naming convention as the default templates, but it does need to be available through a URL; a local path or UNC path won’t work.

Here’s an example of a GetFeatureInfo request with the xslt_template parameter:


The above URL references an external template that overrides the default template. The customized template looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:esri_wms="" xmlns="">

  <xsl:template match="/">{
  "type": "FeatureCollection",
  "features": [<xsl:for-each select="esri_wms:FeatureInfoResponse/esri_wms:FeatureInfoCollection/esri_wms:FeatureInfo">
      "type": "Feature",
        {<xsl:for-each select="esri_wms:Field">
          "<xsl:value-of select="esri_wms:FieldName"/>":"<xsl:value-of select="esri_wms:FieldValue"/>",</xsl:for-each>
      "layerName":"<xsl:value-of select="../@layername"/>"

The above template has been created to make the WMS return its GetFeatureInfo responses in plain text instead of the default HTML format. In fact, here this plain text is styled in the popular GeoJSON format. GeoJSON can be parsed by many JavaScript libraries, allowing you to integrate your responses with your Web pages in an easy-to-read format.

Here’s an example of using a GetFeatureInfo GeoJSON response as a data source of an Ext.Grid in an OpenLayers Web Map application:

GeoJSON response in a grid 

Click here (or right-click the link and save) to see the code for an example template that could be used to embed a video object in the response.

Embedded video in the response 

Click here (or right-click the link and save) to see the code for a more comprehensive example that heavily customizes the GetFeatureInfo HTML response to embed a JavaScript code snippet. The code plays a tour in the Google Earth plug-in Web application.

Notice that in this XSLT template, there is logic specific to a particular WMS service. Therefore, this template should always be referenced through the xslt_template parameter; it should not be made the default template.

Contributed by Yingqi Tang of the ArcGIS Server development team

This entry was posted in Services and tagged , , . Bookmark the permalink.

Leave a Reply


  1. dsierra says:

    Is it possible to do something like this in ArcGIS Server 9.3.1. somehow? Thanks in advance

  2. anakintang says:

    For ArcGIS Server 9.3.1 WMS, no, because this is a new feature in 10.0. The closest feature in 9.3.1 is the html popup for a map service, which you can also customize using xslt template.