Lire::DlfSchema(3pm)

Lire::DlfSchema3pm

Interface to lire dlf schema xml specifications

Usage

In DLF converters:

    use Lire::DlfSchema;
    my $schema = Lire::DlfSchema::load_schema( "email" );
    my $fields = $schema->fields();
    my $dlf_id = $schema->field( 'dlf_id' );
    my $dlf_src = $schema->field( 'dlf_source' );

Overview

This module is the interface to the Lire DLF Schemas defined in XML files. A schema defines the order of the fields along with their names, descriptions and types.

Each DlfSchema have at least two predefined fields:

dlf_id

This is an integer which uniquely identify a DLF record in its stream. Its used to link the record to its extended schemas fields and also to link the record to the derived schemas records.

dlf_source

This is an identifier which can be used to track the record the ImportJob that created it.

Accessing a schema object

The way to access a schema for a superservice is through the load_schema() module function. You use it like this:

    my $schema = Lire::DlfSchema::load_schema( $superservice);

This function will return a schema object which can then be used to query information about the schema. This function will die() on error.

has_superservice( $superservice )

Returns true if there is superservice named $schema_name available. An error will be thrown if the schema name isn't valid for a superservice.

has_schema( $schema_name )

Returns true if there is $schema_name available. An error will be thrown if the schema name isn't valid.

superservices()

Returns the name of the available superservices in an array.

schemas()

Returns the name of the available schemas in an array.

Schema object methods

id()

    my $id = $schema->id();

This method will return the id of the schema. This will be the superservice's name for superservice's main schema. (There are other types of schemas (derived and extended schemas) for which the id will be different than the superservice's name.)

superservice()

    my $super = $schema->superservice();

This method will return the superservice's name of the schema.

title( [$new_title] )

This method will return (or change) the human readable title of the schema. (This is the content of the title element in the XML specification.)

description( [$new_description] )

This method will return (or change) the description of the schema. (This is the content of the description element in the XML specification.) Be aware that this will most likely contain DocBook markup.

field_by_pos()

    my $field = $schema->field_by_pos( 0 );

This method takes an integer as parameter and return the field at that position in the schema. Fields are indexed starting at 0. This method will die() if an invalid position is passed as parameter.

The method returns a Lire::Field(3pm) object.

add_field( $field )

Adds the Lire::Field $field to this schema.

has_field()

    if ( $schema->has_field( 'test ) ) { 
        print "schema has field 'test'\n"; 
    }

This method takes a string as parameter and returns a boolean value. That value will be true if there is a field in the schema with that name, it will be false otherwise.

field()

    my $field = $schema->field( 'from_email' );

This method takes a field's name as parameter and returns the Lire::Field(3pm) object describing that field in the schema. The method will die() if there is no field with that name in the schema.

fields()

    my $fields = $schema->fields();
    my @fields = $schema->fields();

In array context, this method will return an array containing all the fields (as Lire::Field(3pm) objects) in the schema. The order of the fields in the array is the order of the fields in the schema.

In scalar context, it will return an array reference. This method is more efficient than creating an array. DO NOT MODIFY THE RETURNED ARRAY.

field_names()

Returns the name of the fields in this schema. The names are in the same order than the fields.

field_count()

    my $number_of_field = $schema->field_count;

This method returns the number of fields in the schema.

timestamp_field()

    my $time_field = $schema->timestamp_field;

This method will return the Lire::Field(3pm) object representing the timestamp field in the schema. The timestamp field is the one that defines the sort order of the DLF records.

is_schema_compatible()

    if ( $schema->is_schema_compatible( $other_schema ) ) {
    }

This method takes a Lire::DlfSchema(3pm) object as parameter and returns a boolean value. That value will be true if the schema passed as parameter is compatible with the other, it will be false otherwise.

For a superservice's schema, the only compatible schema is an object representing the same superservice's schema.

can_join_schema( $schema )

Returns true if $schema can be joined with this schema. For a DlfSchema, this will be true only when $schema is an ExtendedSchema of this schema.

Version

$Id: DlfSchema.pm,v 1.58 2006/07/23 13:16:28 vanbaal Exp $

Releases

7 releases since Debian 3.0 (Woody); the text changed 6 times.

  1. 3.0
  2. 3.1
  3. 4.0
  4. 5.0
  5. 6.0
  6. 7
  7. Arch

Author

  Francis J. Lacoste <[email protected]>

From lire 2.1.1-8 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.