source: main/trunk/release-kits/shared/linux/XML-Parser/64-bit/perl-5.24/XML/Parser/Style/Objects.pm@ 31805

Last change on this file since 31805 was 31805, checked in by ak19, 7 years ago

Committing the perl 5.24 that Dr Bainbridge successfully built on Ubuntu 16.06 against (a locally compiled, non-system) perl 5.24 perl. It is a byproduct of compiling up a gs3-svn on the Ubuntu 16.04 with the perl 5.24 in the PATH. This perl-5.24 folder was copied from the gs3-svn's gs2build/perllib/cpan folder. It's being committed into the release-kits area as other versions before have been, as it's needed for release-kits, to generate binaries that will work with perl 5.24. However, the version we generated only has Expat.so, not le Expat.bs. Not sure if that's still necessary, and if so, how it should be generated. See http://www.cryst.bbk.ac.uk/CCSG/programming/perl/PerlDoc/lib/ExtUtils/Mkbootstrap.html for ideas, if the bs extension stands for bootstrap as it seems to.

File size: 1.7 KB
Line 
1# $Id: Objects.pm,v 1.1 2003-08-18 20:20:51 matt Exp $
2
3package XML::Parser::Style::Objects;
4use strict;
5
6sub Init {
7 my $expat = shift;
8 $expat->{Lists} = [];
9 $expat->{Curlist} = $expat->{Tree} = [];
10}
11
12sub Start {
13 my $expat = shift;
14 my $tag = shift;
15 my $newlist = [ ];
16 my $class = "${$expat}{Pkg}::$tag";
17 my $newobj = bless { @_, Kids => $newlist }, $class;
18 push @{ $expat->{Lists} }, $expat->{Curlist};
19 push @{ $expat->{Curlist} }, $newobj;
20 $expat->{Curlist} = $newlist;
21}
22
23sub End {
24 my $expat = shift;
25 my $tag = shift;
26 $expat->{Curlist} = pop @{ $expat->{Lists} };
27}
28
29sub Char {
30 my $expat = shift;
31 my $text = shift;
32 my $class = "${$expat}{Pkg}::Characters";
33 my $clist = $expat->{Curlist};
34 my $pos = $#$clist;
35
36 if ($pos >= 0 and ref($clist->[$pos]) eq $class) {
37 $clist->[$pos]->{Text} .= $text;
38 } else {
39 push @$clist, bless { Text => $text }, $class;
40 }
41}
42
43sub Final {
44 my $expat = shift;
45 delete $expat->{Curlist};
46 delete $expat->{Lists};
47 $expat->{Tree};
48}
49
501;
51__END__
52
53=head1 NAME
54
55XML::Parser::Style::Objects
56
57=head1 SYNOPSIS
58
59 use XML::Parser;
60 my $p = XML::Parser->new(Style => 'Objects', Pkg => 'MyNode');
61 my $tree = $p->parsefile('foo.xml');
62
63=head1 DESCRIPTION
64
65This module implements XML::Parser's Objects style parser.
66
67This is similar to the Tree style, except that a hash object is created for
68each element. The corresponding object will be in the class whose name
69is created by appending "::" and the element name to the package set with
70the Pkg option. Non-markup text will be in the ::Characters class. The
71contents of the corresponding object will be in an anonymous array that
72is the value of the Kids property for that object.
73
74=head1 SEE ALSO
75
76L<XML::Parser::Style::Tree>
77
78=cut
Note: See TracBrowser for help on using the repository browser.