ServDocOutput.pm

Code Index:


#!/usr/bin/perl   # Automatic POD-making requires that :-(
package ServDocOutput;

#----------------------------------------------------------------------


NAME

ServDocOutput - common procs for ServDoc-Output-Modules


VERSION

$Id: ServDocOutput.pm,v 1.1 2004/01/03 20:43:26 uherbst Exp $


SYNOPSIS

  use ServDocOutput;

common functions for ServDoc output-modules

  my ($short_desc,$long_desc,$text,$textref,@headings)
    = get_and_normalize_SDitem_data($xmltree->{SDitem}->[$i]);


DESCRIPTION

In this perlmodule are common used procedures for more than one output module.

#----------------------------------------------------------------------

require Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
use English;
use Getopt::Long;    # command line options

# Data::Dumper is not included in standard perl,
# but it is VERY helpful in debugging complex
# data structures.
BEGIN {
  $HAS_DATA_DUMPER = 0;
  eval "use Data::Dumper";
  if ( $@ eq "" ) { $HAS_DATA_DUMPER = 1 }
}

@ISA = qw(Exporter);

# Which function are public ?
@EXPORT = qw(
  get_and_normalize_SDitem_data
);

# CVS (and RCS) uses a version numbering style,
# which isn't compatible with perl's
# versioning-style for modules.
# This transformation is copied from LWP/Simple.pm
$VERSION = sprintf( "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/ );

#----------------------------------------------------------------------


get_and_normalize_SDitem_data

  my ($short_desc,$long_desc,$text,$textref,@headings)
    = get_and_normalize_SDitem_data($xmltree->{SDitem}->[$i]);

Input: a reference to the SDitem structure.

Output: a list with the data:

short_desc
The short description field

long_desc
The long description field

text
The non-table text from the data field (maybe empty)

tableref
The reference to the table-data in the data field (maybe empty)

headings
array of heading levels.

sub get_and_normalize_SDitem_data {

  my $itemref = shift;
  my ($short_desc,$long_desc,$text,$tableref,@headings);

  $short_desc = $itemref->{short}->[0]->{content};
  $long_desc  = $itemref->{long}->[0]->{content};
  $text       = $itemref->{data}->[0]->{content};
  $tableref   = $itemref->{data}->[0]->{table};

  # Get headings
  if (!defined($itemref->{title}->[0]->{h0})) {
    die "title format isn't correct";
  }

  my $x="h0";
  while ($itemref->{title}->[0]->{$x}->[0]->{content}) {
    push @headings,$itemref->{title}->[0]->{$x}->[0]->{content};
    $x++;     # h0->h1, h1->h2,...
  }
  
  # normalize short, long, text
  
  return ($short_desc,$long_desc,$text,$tableref,@headings);
}

#----------------------------------------------------------------------


AUTHORS

Ulrich Herbst <ulrich.herbst@gmx.de>

1;