The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

TM::FAQ - Topic Maps, Frequently Angering Quirks

FAQ, TIPS AND PITFALLS

  • Q: How can I get rid of these annoying topics occurrence, name, etc. which I have not put into the map in the first place, but which are in there in all cases?

    A: These infrastructure topics are needed to make the map complete (everything used is defined). If you want to filter these out, you can get them first via

        my @infra = $tm->mids (keys %{$TM::PSI::topicmaps->{mid2iid}})

    To deduct them from the list of all topics

        my @all = $tm->midlets;

    You can do:

        # make lookup for speed
        my %infra;
        @infra{ @infra } = (1) x @infra;
    
        my @non_infra = grep (!$infra{$_}
                           && !$tm->retrieve ($_),
                        $tm->midlets);

    The retrieve looks up whether the topic is an assertion. Most likely, you would not want these as well then.

  • Q: How can I get all names and/or occurrences of a topic?

    A: If you have a topic identifier mytopic in your hand, then you can get all characteristics (= names and occurrences, but not associations) with

        my @cs = $tm->match_forall (char => 1, irole => $tm->mids ('mytopic'));

    Then you can filter occording the type, the scope, the data type value or the KIND. The latter tells you whether an assertion is a name or occurrence. For example those occurrences which are occurrences and not anything specials as, say, homepage:

        my @occs  = map { $_->[0] } map { TM::get_x_players ($tm, $_, 'tm://value') } grep ($_->[TM->TYPE] eq 'tm://occurrence', @cs);
  • Q: How do these get_x_role functions work? What does does not honor subclassing mean?

    A: @@@@@@@@@@@@@

    (is-father-of) father: godzilla child: kidzilla

    father subclasses parent

    dann kriegst du mit

      get_x_role ($tm, $a, '...father')     =======> godzilla
      get_x_role ($tm, $a, '...parent')     =======> nix
      get_role   ($tm, $a, '...parent')     =======> godzilla
  • Timestamps of resources

    @@@ files have UNIX time resolution (second), TM uses HiRes::Time @@@@

COPYRIGHT AND LICENSE

Copyright 200[3-6] by Robert Barta, <drrho@cpan.org>

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