MS RFC 51: XML Mapfile Format

Date:

2009/01/16

Authors:

Alan Boudreault

Contact:

aboudreault at mapgears.com

Last Edited:

2009/03/09

Version:

MapServer 6.0

Overview

Presently, MapServer supports only normal mapfiles that are parsed by Flex. The current mapfiles are parsed very fast by MapServer but can not be parsed by any other software due to the parser complexity. So, a client interface to build mapfiles is difficult to make.

The need we are trying to address is the ability to build MapFile Editors that would be facilitated by the existence of a XML mapfile format (since the current mapfile format makes it impossible to write a forward-compatible parser). XML is seen as a solution that can provide a strict syntax to mapfiles to have a strong validation with XML Schema.

This RFC proposes the addition of XML Mapfile support.

Technical Solution

It was decided that for the time being we should develop a XML schema and a XSLT to convert from XML to text mapfile. If the new XML format takes off then we may consider implementing support for it directly in MapServer in a future release.

Mapfiles

An example of XML mapfile layer definition (prototype):

 <Layer>
  <name>popplace</name>
  <type>POINT</type>
  <debug>5</debug>
  <status>ON</status>
  <Metadata>
    <item name="DESCRIPTION">Cities</item>
    <item name="TEST">TESTING</item>
    <item name="RESULT_FIELDS">NAME</item>
  </Metadata>
  <data>popplace</data>
  <labelItem>Name</labelItem>
  <classItem>Capital</classItem>

  <Class>
    <name>Cities</name>
    <expression>1</expression>
    <template>ttt_query.html</template>
    <symbol>2</symbol>
    <size>8</size>
    <Label type="TRUETYPE">
      <colorAttribute>[COULEUR]</colorAttribute>
      <font>sans</font>
      <angle>0</angle>
      <size>8</size>
      <outlineColor red="255" green="255" blue="255"/>
    </Label>
    <color red="0" green="255" blue="0"/>
  </Class>

  <Class>
    <name>Cities</name>
    <expression>/2|3/</expression>
    <template>ttt_query.html</template>
    <tolerance>5</tolerance>
    <Label type="TRUETYPE">
      <colorAttribute>[COULEUR]</colorAttribute>
      <font>[FONT]</font>
      <angle>[ANGLE]</angle>
      <size>8</size>
      <outlineColor red="255" green="255" blue="255"/>
      <position>AUTO</position>
      <partials>FALSE</partials>
    </Label>
    <Style>
      <symbol>7</symbol>
      <size>6</size>
      <colorAttribute>[COULEUR]</colorAttribute>
    </Style>
  </Class>
</Layer>

Future Enhancement

In the future, some enhancement could be good to added:

  • Special tags for all WMS options (including styles)

  • Reusable xml block with ID

Documentation

TBD

Backwards Incompatibility

No issues expected.

Bug ID

https://github.com/MapServer/MapServer/issues/2872