wiki:XMLMapfiles

Version 2 (modified by aboudreault, 15 years ago) ( diff )

Added a few explanations

Using XML Mapfiles

For the release of MapServer 5.6, a XML schema has been defined to encode mapfiles in XML format, this is discussed in more details in MS RFC 51.

MapServer 5.6 does not implement direct support for reading and writing that XML mapfile format, but a XSLT is included with the distribution to convert an XML mapfile into a regular mapfile usable with MapServer.

We hope that the ability for outside contributors to build Mapfile Editors will be facilitated by the existence of this XML mapfile format. If XML mapfile editors become available and popular, then we may consider implementing direct read/write support for the XML format in MapServer in a future release.

Examples

Coming soon ...

Getting Started: where to get the XML schema and XSL file?

The XML schema and the XSL file are included with the distribution in the xmlmapfile directory.

  • mapfile.xsd : The XML schema used to validate a XML mapfile.
  • mapfile.xsl : The XSL file used by XSLT to convert a XML mapfile into a regular mapfile.

What kind of XML files can I create using the schema?

You can create 3 XML file types:

  • A complete XML mapfile: <Map ...></Map>
  • A XML file for your layers: <LayerSet ...><Layer ...></Layer>...</LayerSet>
  • A XML file for your symbols: <SymBolSet><Symbol ...></Symbol></SymbolSet>

There is one exampe of each type in the xmlmapfile/tests directory.

How to use the XML schema?

If you are using a XML editor like XMLSpy or XMLPad, you can easily specify the XML schema used to validate your current XML document. Furthermore, those editors will provide XML completition by listing allowed tags/attributes, automatic validation and more..

If you prefer, you can also use a normal text editor. On Linux, there is a few tools to validate a XML file with its schema. On Ubuntu, you can do the following command:

apt-get install xmlstarlet
xmlstarlet val -e --xsd mapfile.xsd my-new-mapfile.xml

How to convert an XML mapfile to regular mapfile using the XSLT?

If you are using a XML editor, you can easily specify the XSL file to use and transform the document.

On Ubuntu, you can do the following command:

apt-get install xsltproc
xsltproc my-new-mapfile.xml > /tmp/my-regular-mapfile.map

Attachments (2)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.