Mark Overmeer > Geo-GML-0.15 > Geo::GML



Annotate this POD


New  2
Open  0
View/Report Bugs
Module Version: 0.15   Source   Latest Release: Geo-GML-0.16


Geo::GML - Geography Markup Language processing


 Geo::GML has extra code in

   is a XML::Compile::Cache
   is a XML::Compile::Schema
   is a XML::Compile


 use Geo::GML ':gml321';

 my $gml = Geo::GML->new('READER', version => '3.2.1');

 # see XML::Compile::Cache on how to use readers and writers
 my $data = $gml->reader("gml:GridCoverage")->($xmlmsg);
 my $xml  = $gml->writer($sometype)->($doc, $perldata);

 # or without help of the cache, XML::Compile::Schema
 my $r    = $gml->compile(READER => $sometype);
 my $data = $r->($xml);

 # super simple
 my ($type, $data) = Geo::GML->from('data.xml');

 # overview (large) on all defined elements

 # To discover the perl datastructures to be passed
 print $gml->template("gml:Surface");

 # autoloaded logic to convert Geo::Point into GML
 $data->{...somewhere...} = $gml->GPtoGML($objects);


Provides access to the GML definitions specified in XML. The details about GML structures can differ, and therefore you should be explicit which versions you understand and produce.

If you need the <b>most recent</b> version of GML, then you get involved with the ISO19139 standard. See CPAN module Geo::ISO19139.

The first releases of this module will not powerful, but hopefully people contribute. For instance, an example conversion script between various versions is very welcome! It would be nice to help each other. I will clean-up the implementation, to make it publishable, but do not have the knowledge about what is needed.




Read a EOP structure from a data source, which can be anything acceptable by dataToXML(): a XML::LibXML::Element, XML as string or ref-string, filename, filehandle or known namespace.

Returned is the product (the type of the root node) and the parsed data-structure. The EOP version used for decoding is autodetected, unless specified.

See examples/


  my ($type, $data) = Geo::GML->from('data.xml');


 Option            --Defined in     --Default
 allow_undeclared                     <true>
 any_element         XML::Compile::Cache  ATTEMPT
 hook                XML::Compile::Schema  undef
 hooks               XML::Compile::Schema  []
 ignore_unused_tags  XML::Compile::Schema  <false>
 key_rewrite         XML::Compile::Schema  []
 opts_readers        XML::Compile::Cache  []
 opts_rw             XML::Compile::Cache  <some>
 opts_writers        XML::Compile::Cache  []
 prefixes                             undef
 schema_dirs         XML::Compile     undef
 typemap             XML::Compile::Schema  {}
 version                              <required>

. allow_undeclared => BOOLEAN

In the optimal case, all types used in your application are declared during the initiation phase of your program. This will make it easy to write a fast daemon application, or transform your program into a daemon later. So: "false" would be a good setting. However, on the moment, the developer of this module has no idea which types people will use. Please help me with the specs!

All any elements will be ATTEMPTed to be processed at run-time by default.

The GML specification will require PREFIXED key rewrite, because the complexity of namespaces is enormous. Besides, mixed elements are processed as STRUCTURAL by default (mixed in texts ignored).

. any_element => CODE|'TAKE_ALL'|'SKIP_ALL'|'ATTEMPT'


. hooks => ARRAY-OF-HOOK

. ignore_unused_tags => BOOLEAN|REGEXP

. key_rewrite => HASH|CODE|ARRAY-of-HASH-and-CODE

. opts_readers => HASH|ARRAY-of-PAIRS

. opts_rw => HASH|ARRAY-of-PAIRS

. opts_writers => HASH|ARRAY-of-PAIRS

. prefixes => ARRAY|HASH

Prefix abbreviations, to be used by cache object. Which prefixes are defined depends on the schema version.


. typemap => HASH


Only used when the object is created directly from this base-class. It determines which GML syntax is to be used. Can be a VERSION like "3.1.1" or a NAMESPACE URI like 'NS_GML_300'.



See "Accessors" in XML::Compile::Schema

$obj->addHooks(HOOK, [HOOK, ...])

See "Accessors" in XML::Compile::Schema

$obj->addKeyRewrite(PREDEF|CODE|HASH, ...)

See "Accessors" in XML::Compile::Schema



See "Accessors" in XML::Compile

$obj->addSchemas(XML, OPTIONS)

See "Accessors" in XML::Compile::Schema


See "Accessors" in XML::Compile::Schema


See "Accessors" in XML::Compile::Schema


See "Accessors" in XML::Compile::Cache


Returns 'READER', 'WRITER', or 'RW'.


See "Accessors" in XML::Compile::Schema


See "Accessors" in XML::Compile::Cache


See "Accessors" in XML::Compile::Cache


See "Accessors" in XML::Compile::Cache

$obj->useSchema(SCHEMA, [SCHEMA])

See "Accessors" in XML::Compile::Schema


GML version, for instance '3.2.1'.


$obj->compile(('READER'|'WRITER'), TYPE, OPTIONS)

See "Compilers" in XML::Compile::Schema

$obj->compileAll(['READER'|'WRITER'|'RW', [NAMESPACE]])

See "Compilers" in XML::Compile::Cache


See "Compilers" in XML::Compile

$obj->reader(TYPE|NAME, OPTIONS)

See "Compilers" in XML::Compile::Cache

$obj->template('PERL'|'XML', TYPE, OPTIONS)

See XML::Compile::Schema::template(). This will create an example of the data-structure based on GML. All OPTIONS are passed to the template generator, the only reason to have this method, is to avoid the need to collect all the GML XML files yourself.

 Option              --Defined in     --Default
 abstract_types        XML::Compile::Schema  'IGNORE'
 attributes_qualified  XML::Compile::Schema  <undef>
 elements_qualified    XML::Compile::Schema  <undef>
 include_namespaces    XML::Compile::Schema  <true>
 indent                XML::Compile::Schema  " "
 show_comments         XML::Compile::Schema  ALL

. abstract_types => 'ERROR'|'IGNORE'|'ACCEPT'

. attributes_qualified => BOOLEAN

. elements_qualified => 'ALL'|'TOP'|'NONE'|BOOLEAN

. include_namespaces => BOOLEAN

. indent => STRING

. show_comments => STRING|'ALL'|'NONE'


  use Geo::GML;
  use Geo::GML::Util     qw/NS_GML_321/;
  use XML::Compile::Util qw/pack_type/;
  my $gml   = Geo::GML->new(version => NS_GML_321);

  # to simplify the output, reducing often available large blocks
  my @types = qw/gml:MetaDataPropertyType gml:StringOrRefType
  my %hook  = (type => \@collapse_types, replace => 'COLLAPSE');

  # generate the data-structure
  my $type  = 'gml:RectifiedGridCoverage';  # any element name
  print $gml->template(PERL => $type, hook => \%hook);


See "Compilers" in XML::Compile::Cache



See "Helpers" in Geo::GML::GeoPoint



See "Administration" in XML::Compile::Cache


See "Administration" in XML::Compile::Schema


See "Administration" in XML::Compile::Cache



See "Administration" in XML::Compile

$obj->importDefinitions(XMLDATA, OPTIONS)

See "Administration" in XML::Compile::Schema



See "Administration" in XML::Compile


See "Administration" in XML::Compile::Schema

$obj->printIndex([FILEHANDLE], OPTIONS)

List all the elements which can be produced with the schema. By default, this only shows the elements and excludes the abstract elements from the list. The selected FILEHANDLE is the default to print to.

 Option       --Defined in         --Default
 show_declared  XML::Compile::Cache  <true>

. show_declared => BOOLEAN


See "Administration" in XML::Compile::Schema

$obj->walkTree(NODE, CODE)

See "Administration" in XML::Compile



Error: cannot find pre-installed name-space files

Use $ENV{SCHEMA_LOCATION} or new(schema_dirs) to express location of installed name-space files, which came with the XML::Compile distribution package.

Error: don't known how to interpret XML data


This module is part of Geo-GML distribution version 0.15, built on March 19, 2009. Website: All modules in this suite: "Geo::GML", "Geo::ISO19139", "Geo::EOP", "Geo::Point", "Geo::Proj4", "Geo::WKT", and "Math::Polygon".

Please post questions or ideas to|the Geo-Perl mailinglist


License of the CODE

Copyrights of the perl code and the related documentation by 2008-2009 by Mark Overmeer. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See

License of the SCHEMAS

The included schemas are copyrighted by the Open Geospatial Consortium, Inc. They are unmodified copied from the files at Read OGCs disclaimer and copyright statements on documentation and software at The license text is also included in this CPAN distribution.

syntax highlighting: