PerlPoint-Generator-XML

 view release on metacpan or  search on metacpan

lib/PerlPoint/Generator/XML/Default.pm  view on Meta::CPAN

  # don't forget the base class
  $me->SUPER::initBackend;

  # open result file
  my $handle=$me->{targethandle}=new IO::File(">$me->{options}{targetdir}/$me->{options}{prefix}$me->{options}{suffix}");

  # start XML
  print $handle $me->{xml}->xmldecl({version => 1.0,});
  print $handle $me->{xml}->xmldtd(
                                   [
                                    # document type (needs to match the root element)
                                    $me->elementName('__root'),

                                    # external id (e.g. "SYSTEM //W3C//DTD XHTML 1.0 Transitional//EN"
                                    exists $me->{options}{xmldoctypeid} ? $me->{options}{xmldoctypeid} : (),

                                    # DTD (e.g. "perlpoint-simple.dtd"
                                    exists $me->{options}{xmldtd} ? $me->{options}{xmldtd} : (),
                                   ]
                                  ), "\n\n";
 }


# page formatter
sub formatPage
 {
  # get and check parameters
  ((my __PACKAGE__ $me), my ($page, $item))=@_;
  confess "[BUG] Missing object parameter.\n" unless $me;
  confess "[BUG] Object parameter is no ", __PACKAGE__, " object.\n" unless ref $me and $me->isa(__PACKAGE__);
  confess "[BUG] Missing page data parameter.\n" unless $page;
  confess "[BUG] Missing item parameter.\n" unless $item;

  # store this slide
  my $tagname=$me->elementName('__slide');
  push(
       @{$me->{slides}},
       $me->{xml}->$tagname(
                            {
                            },
                            @{$item->{parts}},
                           )
      ) if @{$item->{parts}} and grep(ref($_)!~/::comment$/, @{$item->{parts}});

  # supply nothing
  '';
 }

# finish
sub finish
 {
  # get and check parameters
  (my __PACKAGE__ $me)=@_;
  confess "[BUG] Missing object parameter.\n" unless $me;
  confess "[BUG] Object parameter is no ", __PACKAGE__, " object.\n" unless ref $me and $me->isa(__PACKAGE__);

  # don't forget the base class
  $me->SUPER::finish;

  # write document
  my ($handle, $presentationTag, $docdataTag, $slidesTag)=($me->{targethandle}, $me->elementName('__root'), $me->elementName('__docdata'), $me->elementName('__slides'));
  print $handle $me->{xml}->$presentationTag(
                                             # add meta data part
                                             $me->{xml}->$docdataTag(
                                                                     # the "doc..." options are reserved for this ...
                                                                     map
                                                                      {
                                                                       /^doc(.+)$/;
                                                                       my $tag=$me->elementName("_$1");
                                                                       $me->{xml}->$tag($me->{options}{$_}),
                                                                      } sort grep(/^doc/, keys %{$me->{options}}),
                                                                    ),

                                             # embed slides into a special section
                                             $me->{xml}->$slidesTag(@{$me->{slides}}),
                                            ), "\n\n";


  # close document
  close($handle);
 }


# flag successfull loading
1;


# = POD TRAILER SECTION =================================================================

=pod

=head1 NOTES


=head1 SEE ALSO

=over 4



=back


=head1 SUPPORT

A PerlPoint mailing list is set up to discuss usage, ideas,
bugs, suggestions and translator development. To subscribe,
please send an empty message to perlpoint-subscribe@perl.org.

If you prefer, you can contact me via perl@jochen-stenzel.de
as well.

=head1 AUTHOR

Copyright (c) Jochen Stenzel (perl@jochen-stenzel.de), 2003.
All rights reserved.

This module is free software, you can redistribute it and/or modify it
under the terms of the Artistic License distributed with Perl version
5.003 or (at your option) any later version. Please refer to the
Artistic License that came with your Perl distribution for more
details.

The Artistic License should have been included in your distribution of



( run in 1.490 second using v1.01-cache-2.11-cpan-39bf76dae61 )