XTM::topic - Topic Map management, Topic
use XTM::topic;
my $t = new XTM::topic;...print join (",", @{$t->occurrences()});print "bliss and happiness" if $t->has_instanceOf ('t-billionair');
# now this time I am providing the id myselfmy $t2 = new XTM::topic (id => '1234');
# there is also a cheap way to populate the topic with a defaultmy $t3 = new XTM::topic (id => '1234', populate => \&XTM::topic::default_populate);
# see XTM::generic for more methods
This package provides the primitive class Topic for Topic Maps.
Constructor The constructor expects a hash with following (optional) fields: a topic id (unique in the map in use), if not given, it will be generated a code reference to a subroutine populating the topic. There are the following predefined subroutines: This routine expects as first parameter a "XTM::topic"-blessed object and fills in the PSI topic as 'instanceOf', global scope where appropriate. It also generates in a fairly ad-hoc manner a 'baseName' from the topic id (substituting '-' by ' ').
$t = new XTM::topic ('id' => 'x123');
Methods Following accessor methods are available via XTM::generic (see that package how to set/add values): @{ $t->baseNames}
returns list reference of XTM::baseName nodes. @{ $t->instanceOfs}
returns list reference of XTM::instanceOf nodes. $t->subjectIdentity
returns a XTM::subjectIdentity node Other methods are: print $t->id
$t->id ("x123");
returns the id of the topic. If provided with a non-empty scalar parameter, this value will be used to change the id. @{ $t->occurrences }
$t->occurrences ( $coderef )
$t->occurrences ( $arrayref )
returns the occurrences of the topic as a list reference. If provided with a CODEREF parameter, this subroutine will be used to filter the occurrences. If provided with a ARRAYREF parameter, this will be used as new value. $t->map
$t->map ( $newmap )
is an accessor method for the "map" component. $t->has_instanceOf ( $type_topic_id )
returns true if the topic is a direct subtype of a topic specified as "tid" for the only parameter.
Example:
print "bliss and happiness" if $t->has_instanceOf ('t-billionair');
$t->add_defaults
This methods add default values according to the XTM standard. Specifically, it assures that $t->canonicalize
This method simplifies the topic by eliminating duplicates as prescribed in F.6. @{ $t->connected }
returns a list reference of all topic references mentioned in this topic. These references might be 'internal' or 'external' ones.
Example:
foreach (@{$t->connected}) {print "$t->id mentions $_\n";}
$t->xml ( $xmlwriter )
returns an XML representation of the topic.
Example:
$xmlwriter = new XML::Writer ...
...
$t->xml($xmlwriter); # outputs all onto $xmlwriter XTM, XTM::generic Copyright 200[1-2], Robert Barta <[email protected]>, All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. http://www.perl.com/perl/misc/Artistic.html