logo
Selecting Drivers < The Trick is To Keep Breathing < < Home 

PrevUpNext

Selecting Drivers

Obviously a different parser has to be used for an XTM file than for an AsTMa= or LTM file. Other topic map content may be in a TM backend database, some content may only exist virtually, being emulated by a dedicated package.

While you may be mostly fine with system defaults, in some cases you may want to have precise control on how files and other external sources are to be interpreted. By default, when parsing the Tau expression, the infrastructure tries to identify which driver to use for which part of that composite map denoted by the Tau expression.

For this purpose a pattern matching approach is used to map regular expression patterns to driver package names. When selecting drivers, the package is using the hash %TM::schemes. It comes with some predefined mappings, but you can override values there:

# defaults
$TM::schemes{'null:'}            = 'TM::Materialized::Memory';
$TM::schemes{'file:.*\.atm$'}    = 'TM::Materialized::AsTMa';

# this is something new
$TM::schemes{'mine:server\.com'} = 'My::Private::TopicMap::Driver';
The string mine:server\.com will be used as regular expression: whenever in a Tau expression a map matches this expression, then the given package will be used.

If you would like to learn about the defaults do a

use Data::Dumper;
print Dumper \%TM::schemes;
in a test script.

A second, alternative way to specify a driver is to specify it directly in the Tau expression

http://.../map.xtm { My::BorkenXTM }
In this case the resource is loaded and is processed using My::BorkenXTM (I love typos) as package to parse it.