| 1 | package Chart::Sequence::SAXBuilder; | ||
| 2 | |||
| 3 | $VERSION = 0.000_1; | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Chart::Sequence::SAXBuilder - Build a Chart::Sequence from XML | ||
| 8 | |||
| 9 | =head1 SYNOPSIS | ||
| 10 | |||
| 11 | my $h = Chart::Sqeuence::Builder->new; | ||
| 12 | my $h = Chart::Sqeuence::Builder->new( | ||
| 13 | Sequence => $prexisting_object | ||
| 14 | ); | ||
| 15 | |||
| 16 | my $sequences = Pipeline( $h )->parse_file( "foo.seqml" ); | ||
| 17 | print @$sequences . " found in foo.seqml\n"; | ||
| 18 | |||
| 19 | =head1 DESCRIPTION | ||
| 20 | |||
| 21 | Requires the (otherwise optional) XML::Filter::Dispatcher. | ||
| 22 | |||
| 23 | Namespace: | ||
| 24 | |||
| 25 | http://slaysys.com/Chart-Sequence/seqml/0.1 | ||
| 26 | |||
| 27 | Ignores all elements not in this namespace. Dies if no <seq:sequence> | ||
| 28 | element was found (unless a preexisting sequence was passed in). | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | 1 | ▶ | use XML::Filter::Dispatcher qw( :xstack xvalue ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 33 | @ISA = qw( XML::Filter::Dispatcher ); | ||
| 34 | |||
| 35 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 36 | my $ns = "http://slaysys.com/Chart-Sequence/seqml/0.1"; | ||
| 37 | |||
| 38 | 0 | ▶ | use Chart::Sequence (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 39 | use Chart::Sequence::Node (); | ||
| 40 | use Chart::Sequence::Message (); | ||
| 41 | |||
| 42 | sub new { | ||
| 43 | my $proto = shift; | ||
| 44 | my %options = @_; | ||
| 45 | |||
| 46 | $proto->SUPER::new( | ||
| 47 | Namespaces => { "seq" => $ns }, | ||
| 48 | Rules => [ | ||
| 49 | "seq:*" => [ "string()" => sub { xset } ], # set data members | ||
| 50 | "seq:*[*]" => sub { | ||
| 51 | die "Unrecognized SeqML element <$_[1]->{Name}>\n"; | ||
| 52 | }, | ||
| 53 | "seq:sequence" => sub { xadd( | ||
| 54 | $options{Sequence} || Chart::Sequence->new | ||
| 55 | )}, | ||
| 56 | "seq:node" => sub { | ||
| 57 | xadd( nodes => Chart::Sequence::Node->new ) | ||
| 58 | }, | ||
| 59 | "seq:message" => sub { | ||
| 60 | xadd( messages => Chart::Sequence::Message->new ) | ||
| 61 | }, | ||
| 62 | "start-document::*" => sub { xpush []; }, # ARRAY to hold seqs | ||
| 63 | "/end-document::*" => sub { xpop; }, # return ARRAY of seqs | ||
| 64 | ], | ||
| 65 | ); | ||
| 66 | } | ||
| 67 | |||
| 68 | 1; | ||
| 69 | |||
| 70 | =head1 LIMITATIONS | ||
| 71 | |||
| 72 | =head1 COPYRIGHT | ||
| 73 | |||
| 74 | Copyright 2002, R. Barrie Slaymaker, Jr., All Rights Reserved | ||
| 75 | |||
| 76 | =head1 LICENSE | ||
| 77 | |||
| 78 | You may use this module under the terms of the BSD, Artistic, oir GPL licenses, | ||
| 79 | any version. | ||
| 80 | |||
| 81 | =head1 AUTHOR | ||
| 82 | |||
| 83 | Barrie Slaymaker <barries@slaysys.com> | ||
| 84 | |||
| 85 | =cut | ||
| 86 | |||
| 87 | 1; | ||