XML-SimpleObject0.53004075500007650000024000000000000763176646700135705ustar00garronstaffXML-SimpleObject0.53/Changes010064400007650000024000000031020763176643200151230ustar00garronstaffRevision history for Perl extension XML::SimpleObject. 0.1 Mon Feb 5 14:54:38 2001 - original version; created by h2xs 1.19 0.2 Fri Feb 8 01:07:32 2001 - fixed documentation typos, thanks Michel - children_names() willl return an array of child element names for a given element - children() called without an argument returns an array of all children element objects (though not in any particular order) 0.3 Mon Apr 16 10:20:04 2001 - fixed children() bugs - fixed name() accessor within 'foreach ($obj->children)' loops 0.4 Sat Jul 7 2001 - changed element treatment to allow all characters (thanks to Pekka Ahmavuo) 0.41 Fri Aug 24 2001 - changed to allow parsing without separate XML::Parser object - changed to handle empty elements properly; thanks to Thomas Ziehmer - changed convert() implementation to allow zero values and some flow enhancements; thanks to Eric Kolve 0.5 Wed Jan 23 2002 - added XML::SimpleObject::LibXML providing the same interface using XML::LibXML; it's faster and uses the libxml DOM methods rather than iterating the tree twice. See the separate perldoc for this module. 0.51 Sat Jan 26 2002 - fixed Makefile.PL to include dependencies 0.52 Tue Mar 6 2003 - applied patch to SimpleObject.pm to permit inheritance (thanks to Cliff Stanford) - fixed changes with libxml 1.53 to work with constant XML_TEXT_NODE - added XML::SimpleObject::Enhanced.pm (need to document) 0.53 Tue Mar 6 2003 - bad dist fix XML-SimpleObject0.53/Enhanced004075500007650000024000000000000761404651400152565ustar00garronstaffXML-SimpleObject0.53/Enhanced/Enhanced.pm010064400007650000024000000020470763176644700174150ustar00garronstaffpackage XML::SimpleObject::Enhanced; use strict; use warnings; our $VERSION = '0.53'; use XML::SimpleObject 0.53; our @ISA = qw(XML::SimpleObject); my $shiftwidth = 2; sub _space($) { my $offset = shift || 0; return " " x ($offset * $shiftwidth); } sub output($;$); sub output($;$) { my $self = shift; my $indent = shift || 0; my %attribs = $self->attributes; my $xml = _space($indent) . "<" . $self->name; $xml .= " $_=\"" . $attribs{$_} . '"' foreach (keys %attribs); my @data = split /\n/, $self->value; my ($nl, $in, $in1); if (@data > 1) { $nl = "\n"; $in = _space($indent); $in1 = _space($indent + 1); } else { $nl = $in = $in1 = ''; } $xml .= ">$nl"; $xml .= $in1 . "$_$nl" foreach (grep s/^\s*(\S.*?)\s*/$1/, @data); $xml .= output($_, $indent + 1) foreach $self->children; $xml .= $in . "name. ">\n"; return $xml; } sub append { my $self = shift; while (my $new = shift) { my @array = ($new); $self->{$new->{_NAME}} = \@array; } } 1; XML-SimpleObject0.53/Enhanced/Makefile.old010064400007650000024000000413410761333706400175540ustar00garronstaff# This Makefile is for the XML::SimpleObject::Enhanced extension to perl. # # It was generated automatically by MakeMaker version # 6.03 (Revision: 1.63) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # # ANY CHANGES MADE HERE WILL BE LOST! # # MakeMaker ARGV: () # # MakeMaker Parameters: # NAME => q[XML::SimpleObject::Enhanced] # VERSION_FROM => q[Enhanced.pm] # --- MakeMaker post_initialize section: # --- MakeMaker const_config section: # These definitions are from config.sh (via /Library/Perl/darwin/Config.pm) # They may have been overridden via Makefile.PL or on the command line AR = ar CC = cc CCCDLFLAGS = CCDLFLAGS = DLEXT = bundle DLSRC = dl_dyld.xs LD = cc LDDLFLAGS = -flat_namespace -bundle -undefined suppress -L/usr/local/lib LDFLAGS = -flat_namespace -L/usr/local/lib LIBC = /usr/lib/libc.dylib LIB_EXT = .a OBJ_EXT = .o OSNAME = darwin OSVERS = 6.2 RANLIB = /usr/bin/ar ts SO = dylib EXE_EXT = FULL_AR = /usr/bin/ar # --- MakeMaker constants section: AR_STATIC_ARGS = cr NAME = XML::SimpleObject::Enhanced DISTNAME = XML-SimpleObject-Enhanced NAME_SYM = XML_SimpleObject_Enhanced VERSION = 0.6 VERSION_SYM = 0_6 XS_VERSION = 0.6 INST_ARCHLIB = blib/arch INST_SCRIPT = blib/script INST_BIN = blib/bin INST_LIB = blib/lib INSTALLDIRS = site PREFIX = /usr/local SITEPREFIX = /usr/local VENDORPREFIX = /usr/local INSTALLPRIVLIB = /Library/Perl INSTALLSITELIB = /Library/Perl INSTALLVENDORLIB = /Network/Library/Perl INSTALLARCHLIB = /Library/Perl/darwin INSTALLSITEARCH = /Library/Perl/darwin INSTALLVENDORARCH = /Network/Library/Perl/darwin INSTALLBIN = /usr/local/bin INSTALLSITEBIN = /usr/local/bin INSTALLVENDORBIN = /usr/local/bin INSTALLSCRIPT = /usr/local/bin PERL_LIB = /Library/Perl PERL_ARCHLIB = /Library/Perl/darwin SITELIBEXP = /Library/Perl SITEARCHEXP = /Library/Perl/darwin LIBPERL_A = libperl.a FIRST_MAKEFILE = Makefile MAKE_APERL_FILE = Makefile.aperl PERLMAINCC = $(CC) PERL_INC = /Library/Perl/darwin/CORE PERL = /usr/bin/perl FULLPERL = /usr/bin/perl PERLRUN = $(PERL) FULLPERLRUN = $(FULLPERL) PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" ABSPERL = $(PERL) ABSPERLRUN = $(ABSPERL) ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" FULL_AR = /usr/bin/ar PERL_CORE = 0 NOOP = $(SHELL) -c true NOECHO = @ VERSION_MACRO = VERSION DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" XS_VERSION_MACRO = XS_VERSION XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc MAKEMAKER = /Library/Perl/ExtUtils/MakeMaker.pm MM_VERSION = 6.03 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. FULLEXT = XML/SimpleObject/Enhanced BASEEXT = Enhanced PARENT_NAME = XML::SimpleObject DLBASE = $(BASEEXT) VERSION_FROM = Enhanced.pm OBJECT = LDFROM = $(OBJECT) LINKTYPE = dynamic # Handy lists of source code files: XS_FILES= C_FILES = O_FILES = H_FILES = MAN1PODS = MAN3PODS = INST_MAN1DIR = blib/man1 MAN1EXT = 1 INSTALLMAN1DIR = /usr/local/share/man/man1 INSTALLSITEMAN1DIR = /usr/local/man/man$(MAN1EXT) INSTALLVENDORMAN1DIR = /usr/local/man/man$(MAN1EXT) INST_MAN3DIR = blib/man3 MAN3EXT = 3 INSTALLMAN3DIR = /usr/local/share/man/man3 INSTALLSITEMAN3DIR = /usr/local/man/man$(MAN3EXT) INSTALLVENDORMAN3DIR = /usr/local/man/man$(MAN3EXT) PERM_RW = 644 PERM_RWX = 755 # work around a famous dec-osf make(1) feature(?): makemakerdflt: all .SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that # some make implementations will delete the Makefile when we rebuild it. Because # we call false(1) when we rebuild it. So make(1) is not completely wrong when it # does so. Our milage may vary. # .PRECIOUS: Makefile # seems to be not necessary anymore .PHONY: all config static dynamic test linkext manifest # Where is the Config information that we are using/depend on CONFIGDEP = $(PERL_ARCHLIB)/Config.pm $(PERL_INC)/config.h # Where to put things: INST_LIBDIR = $(INST_LIB)/XML/SimpleObject INST_ARCHLIBDIR = $(INST_ARCHLIB)/XML/SimpleObject INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) INST_STATIC = INST_DYNAMIC = INST_BOOT = EXPORT_LIST = PERL_ARCHIVE = PERL_ARCHIVE_AFTER = TO_INST_PM = Enhanced.pm PM_TO_BLIB = Enhanced.pm \ blib/lib/XML/SimpleObject/Enhanced.pm # --- MakeMaker tool_autosplit section: # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;' # --- MakeMaker tool_xsubpp section: # --- MakeMaker tools_other section: SHELL = /bin/sh CHMOD = chmod CP = cp LD = cc MV = mv NOOP = $(SHELL) -c true RM_F = rm -f RM_RF = rm -rf TEST_F = test -f TOUCH = touch UMASK_NULL = umask 0 DEV_NULL = > /dev/null 2>&1 # The following is a portable way to say mkdir -p # To see which directories are created, change the if 0 to if 1 MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath # This helps us to minimize the effect of the .exists files A yet # better solution would be to have a stable file in the perl # distribution with a timestamp of zero. But this solution doesn't # need any changes to the core distribution and works with older perls EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime # Here we warn users that an old packlist file was found somewhere, # and that they should call some uninstall routine WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \ -e 'print "WARNING: I have found an old package in\n";' \ -e 'print "\t$$ARGV[0].\n";' \ -e 'print "Please make sure the two installations are not conflicting\n";' UNINST=0 VERBINST=0 MOD_INSTALL = $(PERL) "-I$(INST_LIB)" "-I$(PERL_LIB)" "-MExtUtils::Install" \ -e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');" DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \ -e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", $$arg=shift, "|", $$arg, ">";' \ -e 'print "=over 4";' \ -e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \ -e 'print "=back";' UNINSTALL = $(PERLRUN) "-MExtUtils::Install" \ -e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \ -e 'print " packlist above carefully.\n There may be errors. Remove the";' \ -e 'print " appropriate files manually.\n Sorry for the inconveniences.\n"' # --- MakeMaker dist section: ZIPFLAGS = -r TO_UNIX = @$(NOOP) TAR = tar POSTOP = @$(NOOP) ZIP = zip DIST_DEFAULT = tardist CI = ci -u SHAR = shar COMPRESS = gzip --best DIST_CP = best PREOP = @$(NOOP) TARFLAGS = cvf DISTVNAME = $(DISTNAME)-$(VERSION) SUFFIX = .gz RCS_LABEL = rcs -Nv$(VERSION_SYM): -q # --- MakeMaker macro section: # --- MakeMaker depend section: # --- MakeMaker cflags section: # --- MakeMaker const_loadlibs section: # --- MakeMaker const_cccmd section: # --- MakeMaker post_constants section: # --- MakeMaker pasthru section: PASTHRU = LIB="$(LIB)"\ LIBPERL_A="$(LIBPERL_A)"\ LINKTYPE="$(LINKTYPE)"\ PREFIX="$(PREFIX)"\ OPTIMIZE="$(OPTIMIZE)"\ PASTHRU_DEFINE="$(PASTHRU_DEFINE)"\ PASTHRU_INC="$(PASTHRU_INC)" # --- MakeMaker c_o section: # --- MakeMaker xs_c section: # --- MakeMaker xs_o section: # --- MakeMaker top_targets section: all :: pure_all manifypods @$(NOOP) pure_all :: config pm_to_blib subdirs linkext @$(NOOP) subdirs :: $(MYEXTLIB) @$(NOOP) config :: Makefile $(INST_LIBDIR)/.exists @$(NOOP) config :: $(INST_ARCHAUTODIR)/.exists @$(NOOP) config :: $(INST_AUTODIR)/.exists @$(NOOP) $(INST_AUTODIR)/.exists :: /Library/Perl/darwin/CORE/perl.h @$(MKPATH) $(INST_AUTODIR) @$(EQUALIZE_TIMESTAMP) /Library/Perl/darwin/CORE/perl.h $(INST_AUTODIR)/.exists -@$(CHMOD) $(PERM_RWX) $(INST_AUTODIR) $(INST_LIBDIR)/.exists :: /Library/Perl/darwin/CORE/perl.h @$(MKPATH) $(INST_LIBDIR) @$(EQUALIZE_TIMESTAMP) /Library/Perl/darwin/CORE/perl.h $(INST_LIBDIR)/.exists -@$(CHMOD) $(PERM_RWX) $(INST_LIBDIR) $(INST_ARCHAUTODIR)/.exists :: /Library/Perl/darwin/CORE/perl.h @$(MKPATH) $(INST_ARCHAUTODIR) @$(EQUALIZE_TIMESTAMP) /Library/Perl/darwin/CORE/perl.h $(INST_ARCHAUTODIR)/.exists -@$(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) help: perldoc ExtUtils::MakeMaker # --- MakeMaker linkext section: linkext :: $(LINKTYPE) @$(NOOP) # --- MakeMaker dlsyms section: # --- MakeMaker dynamic section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make dynamic" #dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM) dynamic :: Makefile $(INST_DYNAMIC) $(INST_BOOT) @$(NOOP) # --- MakeMaker dynamic_bs section: BOOTSTRAP = # --- MakeMaker dynamic_lib section: # --- MakeMaker static section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make static" #static :: Makefile $(INST_STATIC) $(INST_PM) static :: Makefile $(INST_STATIC) @$(NOOP) # --- MakeMaker static_lib section: # --- MakeMaker manifypods section: manifypods : pure_all @$(NOOP) # --- MakeMaker processPL section: # --- MakeMaker installbin section: # --- MakeMaker subdirs section: # none # --- MakeMaker clean section: # Delete temporary files but do not touch installed files. We don't delete # the Makefile here so a later make realclean still has a makefile to use. clean :: -rm -rf ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def lib$(BASEEXT).def $(BASEEXT).exp $(BASEEXT).x core core.*perl.*.? *perl.core -mv Makefile Makefile.old $(DEV_NULL) # --- MakeMaker realclean section: # Delete temporary files (via clean) and also delete installed files realclean purge :: clean rm -rf $(INST_AUTODIR) $(INST_ARCHAUTODIR) rm -rf $(DISTVNAME) rm -f blib/lib/XML/SimpleObject/Enhanced.pm rm -rf Makefile Makefile.old # --- MakeMaker dist_basics section: distclean :: realclean distcheck $(NOECHO) $(NOOP) distcheck : $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck skipcheck : $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck manifest : $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest veryclean : realclean $(RM_F) *~ *.orig */*~ */*.orig # --- MakeMaker dist_core section: dist : $(DIST_DEFAULT) @$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \ -e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "Makefile";' tardist : $(DISTVNAME).tar$(SUFFIX) zipdist : $(DISTVNAME).zip $(DISTVNAME).tar$(SUFFIX) : distdir $(PREOP) $(TO_UNIX) $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(COMPRESS) $(DISTVNAME).tar $(POSTOP) $(DISTVNAME).zip : distdir $(PREOP) $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(POSTOP) uutardist : $(DISTVNAME).tar$(SUFFIX) uuencode $(DISTVNAME).tar$(SUFFIX) \ $(DISTVNAME).tar$(SUFFIX) > \ $(DISTVNAME).tar$(SUFFIX)_uu shdist : distdir $(PREOP) $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar $(RM_RF) $(DISTVNAME) $(POSTOP) # --- MakeMaker dist_dir section: distdir : $(RM_RF) $(DISTVNAME) $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" # --- MakeMaker dist_test section: disttest : distdir cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL cd $(DISTVNAME) && $(MAKE) $(PASTHRU) cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) # --- MakeMaker dist_ci section: ci : $(PERLRUN) "-MExtUtils::Manifest=maniread" \ -e "@all = keys %{ maniread() };" \ -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \ -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");' # --- MakeMaker install section: install :: all pure_install doc_install install_perl :: all pure_perl_install doc_perl_install install_site :: all pure_site_install doc_site_install install_vendor :: all pure_vendor_install doc_vendor_install pure_install :: pure_$(INSTALLDIRS)_install doc_install :: doc_$(INSTALLDIRS)_install @echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod pure__install : pure_site_install @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site doc__install : doc_site_install @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site pure_perl_install :: @$(MOD_INSTALL) \ read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ write $(INSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(INSTALLPRIVLIB) \ $(INST_ARCHLIB) $(INSTALLARCHLIB) \ $(INST_BIN) $(INSTALLBIN) \ $(INST_SCRIPT) $(INSTALLSCRIPT) \ $(INST_MAN1DIR) $(INSTALLMAN1DIR) \ $(INST_MAN3DIR) $(INSTALLMAN3DIR) @$(WARN_IF_OLD_PACKLIST) \ $(SITEARCHEXP)/auto/$(FULLEXT) pure_site_install :: @$(MOD_INSTALL) \ read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ write $(INSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(INSTALLSITELIB) \ $(INST_ARCHLIB) $(INSTALLSITEARCH) \ $(INST_BIN) $(INSTALLSITEBIN) \ $(INST_SCRIPT) $(INSTALLSCRIPT) \ $(INST_MAN1DIR) $(INSTALLSITEMAN1DIR) \ $(INST_MAN3DIR) $(INSTALLSITEMAN3DIR) @$(WARN_IF_OLD_PACKLIST) \ $(PERL_ARCHLIB)/auto/$(FULLEXT) pure_vendor_install :: @$(MOD_INSTALL) \ $(INST_LIB) $(INSTALLVENDORLIB) \ $(INST_ARCHLIB) $(INSTALLVENDORARCH) \ $(INST_BIN) $(INSTALLVENDORBIN) \ $(INST_SCRIPT) $(INSTALLSCRIPT) \ $(INST_MAN1DIR) $(INSTALLVENDORMAN1DIR) \ $(INST_MAN3DIR) $(INSTALLVENDORMAN3DIR) doc_perl_install :: -@$(MKPATH) $(INSTALLARCHLIB) -@$(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLPRIVLIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(INSTALLARCHLIB)/perllocal.pod doc_site_install :: -@$(MKPATH) $(INSTALLARCHLIB) -@$(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> $(INSTALLSITEARCH)/perllocal.pod doc_vendor_install :: uninstall :: uninstall_from_$(INSTALLDIRS)dirs uninstall_from_perldirs :: @$(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist uninstall_from_sitedirs :: @$(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist # --- MakeMaker force section: # Phony target to force checking subdirectories. FORCE: @$(NOOP) # --- MakeMaker perldepend section: # --- MakeMaker makefile section: # We take a very conservative approach here, but it\'s worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. Makefile : Makefile.PL $(CONFIGDEP) @echo "Makefile out-of-date with respect to $?" @echo "Cleaning current config before rebuilding Makefile..." -@$(RM_F) Makefile.old -@$(MV) Makefile Makefile.old -$(MAKE) -f Makefile.old clean $(DEV_NULL) || $(NOOP) $(PERLRUN) Makefile.PL @echo "==> Your Makefile has been rebuilt. <==" @echo "==> Please rerun the make command. <==" false # --- MakeMaker staticmake section: # --- MakeMaker makeaperl section --- MAP_TARGET = perl FULLPERL = /usr/bin/perl $(MAP_TARGET) :: static $(MAKE_APERL_FILE) $(MAKE) -f $(MAKE_APERL_FILE) $@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) @echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) @$(PERLRUNINST) \ Makefile.PL DIR= \ MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= # --- MakeMaker test section: TEST_VERBOSE=0 TEST_TYPE=test_$(LINKTYPE) TEST_FILE = test.pl TEST_FILES = TESTDB_SW = -d testdb :: testdb_$(LINKTYPE) test :: $(TEST_TYPE) @echo 'No tests defined for $(NAME) extension.' test_dynamic :: pure_all testdb_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) test_ : test_dynamic test_static :: test_dynamic testdb_static :: testdb_dynamic # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. ppd: @$(PERL) -e "print qq{\n\t$(DISTNAME)\n\t\n\t\n}" > $(DISTNAME).ppd @$(PERL) -e "print qq{\t\n}" >> $(DISTNAME).ppd @$(PERL) -e "print qq{\t\t\n\t\t\n\t\t\n\t\n\n}" >> $(DISTNAME).ppd # --- MakeMaker pm_to_blib section: pm_to_blib: $(TO_INST_PM) @$(PERLRUNINST) "-MExtUtils::Install" \ -e "pm_to_blib({qw{Enhanced.pm blib/lib/XML/SimpleObject/Enhanced.pm}},'$(INST_LIB)/auto','$(PM_FILTER)')" @$(TOUCH) $@ # --- MakeMaker selfdocument section: # --- MakeMaker postamble section: # End. XML-SimpleObject0.53/Enhanced/Makefile.PL010064400007650000024000000003770761333704100173100ustar00garronstaffuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'XML::SimpleObject::Enhanced', 'VERSION_FROM' => 'Enhanced.pm', # finds $VERSION ); XML-SimpleObject0.53/Enhanced/test.pl010064400007650000024000000012260761333735600166550ustar00garronstaff# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use XML::SimpleObject; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): XML-SimpleObject0.53/ex.pl010064400007650000024000000024240742315371000145730ustar00garronstaffuse XML::Parser; use XML::SimpleObject; my $XML = < /etc/dosemu.conf dosemu.conf-drdos703.eval 20 /etc/passwd 948 EOF my $xmlobj = new XML::SimpleObject(XML => $XML, ErrorContext => 2); #my $parser = new XML::Parser (ErrorContext => 2, Style => "Tree"); #my $xmlobj = new XML::SimpleObject ($parser->parse($XML)); print "\n"; { print "Files: \n"; foreach my $element ($xmlobj->child("files")->children("file")) { print " filename: " . $element->child("name")->value . "\n"; if ($element->attribute("type")) { print " type: " . $element->attribute("type") . "\n"; } print " bytes: " . $element->child("bytes")->value . "\n"; } } print "\n"; { my $filesobj = $xmlobj->child("files")->child("file"); foreach my $child ($filesobj->children) { print "child: ", $child->name, ": ", $child->value, "\n"; } } print "\n"; { my $filesobj = $xmlobj->child("files"); foreach my $childname ($filesobj->children_names) { print "$childname has children: "; print join (", ", $filesobj->child($childname)->children_names), "\n"; } } print "\n"; XML-SimpleObject0.53/LibXML004075500007650000024000000000000763176651500146515ustar00garronstaffXML-SimpleObject0.53/LibXML/ex.pl010064400007650000024000000023760742370677600157100ustar00garronstaffuse XML::SimpleObject::LibXML; my $XML = < /etc/dosemu.conf dosemu.conf-drdos703.eval cool20 /etc/passwd 948 EOF my $xmlobj = new XML::SimpleObject::LibXML(XML => $XML); # or: # my $parser = new XML::LibXML; # my $xmlobj = new XML::SimpleObject::LibXML ($parser->parse_string($XML)); print "\n"; { print "Files: \n"; foreach my $element ($xmlobj->child("files")->children("file")) { print " filename: " . $element->child("name")->value . "\n"; if ($element->attribute("type")) { print " type: " . $element->attribute("type") . "\n"; } print " bytes: " . $element->child("bytes")->value . "\n"; } } print "\n"; { my $filesobj = $xmlobj->child("files")->child("file"); foreach my $child ($filesobj->children) { print "child: ", $child->name, ": ", $child->value, "\n"; } } print "\n"; { my $filesobj = $xmlobj->child("files"); foreach my $childname ($filesobj->children_names) { print "$childname has children: "; print join (", ", $filesobj->child($childname)->children_names), "\n"; } } print "\n"; XML-SimpleObject0.53/LibXML/LibXML.pm010064400007650000024000000165700763176645600163670ustar00garronstaffpackage XML::SimpleObject::LibXML; use strict; use XML::LibXML; our $VERSION = '0.53'; sub attributes { my $self = shift; my $name = shift; my %attributes; my @attrs = $self->{_DOM}->getAttributes; foreach my $attribute (@attrs) { $attributes{$attribute->getName} = $attribute->value; } return %attributes; } sub attribute { my $self = shift; my $name = shift; my ($found) = $self->{_DOM}->findnodes("\@$name"); if ($found) { return $found->value; } } sub value { my $node = shift; my ($found) = $node->{_DOM}->findnodes("text()"); if ($found) { return $found->getData(); } } sub name { $_[0]->{_DOM}->getName; } sub child { my $self = shift; my $tag = shift; if (ref $self->{_DOM} eq "XML::LibXML::Document") { my $node = new XML::SimpleObject::LibXML ($self->{_DOM}->documentElement()); return $node; } else { my ($element) = $self->{_DOM}->getElementsByTagName($tag); return unless ($element); my $node = new XML::SimpleObject::LibXML ($element); return $node; } } sub children_names { my $self = shift; my @elements; foreach my $node ($self->{_DOM}->getChildnodes) { next if ($node->nodeType == 3); push @elements, $node->getName; } return @elements; } sub children { my $self = shift; my $tag = shift; if (ref $self->{_DOM} eq "XML::LibXML::Document") { my $node = new XML::SimpleObject::LibXML ($self->{_DOM}->documentElement()); return $node; } else { if ($tag) { my @nodelist; foreach my $node ($self->{_DOM}->getElementsByTagName($tag)) { next if ($node->nodeType == 3); push @nodelist, new XML::SimpleObject::LibXML ($node); } return @nodelist; } else { my @nodelist; foreach my $node ($self->{_DOM}->getChildnodes()) { next if ($node->nodeType == 3); push @nodelist, new XML::SimpleObject::LibXML ($node); } return @nodelist; } } } sub new { my $class = shift; if (ref($_[0]) =~ /^XML\:\:LibXML/) { my $self = {}; bless ($self,$class); $self->{_DOM} = $_[0]; return $self; } else { my %args = @_; my $parser = new XML::LibXML; my $dom = $parser->parse_string($args{XML}); my $self = {}; bless ($self,$class); $self->{_NAME} = ""; $self->{_DOM} = $dom; return $self; } } 1; __END__ =head1 NAME XML::SimpleObject::LibXML - Perl extension allowing a simple(r) object representation of an XML::LibXML DOM object. =head1 SYNOPSIS use XML::SimpleObject::LibXML; # Construct with the key/value pairs as argument; this will create its # own XML::LibXML object. my $xmlobj = new XML::SimpleObject(XML => $XML); # ... or construct with the parsed tree as the only argument, having to # create the XML::Parser object separately. my $parser = new XML::LibXML; my $dom = $parser->parse_file($file); # or $parser->parse_string($xml); my $xmlobj = new XML::SimpleObject::LibXML ($dom); my $filesobj = $xmlobj->child("files")->child("file"); $filesobj->name; $filesobj->value; $filesobj->attribute("type"); %attributes = $filesobj->attributes; @children = $filesobj->children; @some_children = $filesobj->children("some"); @children_names = $filesobj->children_names; =head1 DESCRIPTION This is a short and simple class allowing simple object access to a parsed XML::LibXML tree, with methods for fetching children and attributes in as clean a manner as possible. My apologies for further polluting the XML:: space; this is a small and quick module, with easy and compact usage. Some will rightfully question placing another interface over the DOM methods provided by XML::LibXML, but my experience is that people appreciate the total simplicity provided by this module, despite its limitations. =head1 USAGE =item $xmlobj = new XML::SimpleObject::LibXML($parser->parse_string($XML)) $parser is an XML::LibXML object. After creating $xmlobj, this object can now be used to browse the XML tree with the following methods. =item $xmlobj->child('NAME') This will return a new XML::SimpleObject::LibXML object using the child element NAME. =item $xmlobj->children('NAME') Called with an argument NAME, children() will return an array of XML::SimpleObject::LibXML objects of element NAME. Thus, if $xmlobj represents the top-level XML element, 'children' will return an array of all elements directly below the top-level that have the element name NAME. =item $xmlobj->children Called without arguments, 'children()' will return an array of XML::SimpleObjects::LibXML objects for all children elements of $xmlobj. Unlike XML::SimpleObject, XML::SimpleObject::LibXML retains the order of these children. =item $xmlobj->children_names This will return an array of all the names of child elements for $xmlobj. You can use this to step through all the children of a given element (see EXAMPLES), although multiple elements of the same name will not be identified. Use 'children()' instead. =item $xmlobj->value If the element represented by $xmlobj contains any PCDATA, this method will return that text data. =item $xmlobj->attribute('NAME') This returns the text for an attribute NAME of the XML element represented by $xmlobj. =item $xmlobj->attributes This returns a hash of key/value pairs for all elements in element $xmlobj. =head1 EXAMPLES Given this XML document: /etc/dosemu.conf dosemu.conf-drdos703.eval /etc/passwd 948 You can then interpret the tree as follows: my $parser = new XML::LibXML; my $xmlobj = new XML::SimpleObject::LibXML ($parser->parse_string($XML)); print "Files: \n"; foreach my $element ($xmlobj->child("files")->children("file")) { print " filename: " . $element->child("name")->value . "\n"; if ($element->attribute("type")) { print " type: " . $element->attribute("type") . "\n"; } print " bytes: " . $element->child("bytes")->value . "\n"; } This will output: Files: filename: /etc/dosemu.conf type: symlink bytes: 20 filename: /etc/passwd bytes: 948 You can use 'children()' without arguments to step through all children of a given element: my $filesobj = $xmlobj->child("files")->child("file"); foreach my $child ($filesobj->children) { print "child: ", $child->name, ": ", $child->value, "\n"; } For the tree above, this will output: child: bytes: 20 child: dest: dosemu.conf-drdos703.eval child: name: /etc/dosemu.conf Using 'children_names()', you can step through all children for a given element: my $filesobj = $xmlobj->child("files"); foreach my $childname ($filesobj->children_names) { print "$childname has children: "; print join (", ", $filesobj->child($childname)->children_names), "\n"; } This will print: file has children: bytes, dest, name By always using 'children()', you can step through each child object, retrieving them with 'child()'. =head1 AUTHOR Dan Brian =head1 SEE ALSO perl(1), XML::SimpleObject, XML::Parser, XML::LibXML. =cut XML-SimpleObject0.53/LibXML/Makefile.PL010064400007650000024000000007020742470470400166660ustar00garronstaffuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. print "NOTE: XML::SimpleObject::LibXML requires XML::LibXML. If you have XML::Parser you can install XML::SimpleObject instead.\n Checking for XML::LibXML ... \n"; require XML::LibXML; print "OK\n"; WriteMakefile( 'NAME' => 'XML::SimpleObject::LibXML', 'VERSION_FROM' => 'LibXML.pm', # finds $VERSION ); XML-SimpleObject0.53/LibXML/test.pl010064400007650000024000000025170761333633600162400ustar00garronstaff# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use XML::SimpleObject::LibXML; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): my $XML = < /etc/dosemu.conf dosemu.conf-drdos703.eval 0 /etc/passwd 948 END my $parser = new XML::LibXML; my $xmlobj = new XML::SimpleObject::LibXML ($parser->parse_string($XML)); print "Files: \n"; foreach my $element ($xmlobj->child("files")->children("file")) { print " filename: " . $element->child("name")->value . "\n"; if ($element->attribute("type")) { print " type: " . $element->attribute("type") . "\n"; } print " bytes: " . $element->child("bytes")->value . "\n"; } XML-SimpleObject0.53/Makefile.PL010064400007650000024000000007020742470466600156060ustar00garronstaffuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. print "NOTE: XML::SimpleObject requires XML::Parser. If you have XML::LibXML, you can install XML::SimpleObject::LibXML instead.\n Checking for XML::Parser ... \n"; require XML::Parser; print "OK\n"; WriteMakefile( 'NAME' => 'XML::SimpleObject', 'VERSION_FROM' => 'SimpleObject.pm', # finds $VERSION ); XML-SimpleObject0.53/MANIFEST010064400007650000024000000001150742470475400147610ustar00garronstaffChanges MANIFEST Makefile.PL SimpleObject.pm test.pl ex.pl LibXML/LibXML.pm XML-SimpleObject0.53/README010064400007650000024000000021330761335706700145130ustar00garronstaff ================================================================== XML::SimpleObject Copyright 2001-2003 by Dan Brian. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. ================================================================== DESCRIPTION This is a small and simple package that takes the output of an XML parser and gives simple methods for accessing the structure of an XML document. It is very lightweight, but provides the simplest access to an XML document possible. It does not subclass XML::Parser or XML::LibXML; rather, it is meant to serve purely as an object struct for an outgoing tree. I originally wrote the module as an example of parsing without handlers. REQUIREMENTS You need either XML::Parser (for XML::SimpleObject) or XML::LibXML (for XML::SimpleObject::LibXML). Tested on Linux, FreeBSD, and Win32 under perl5.6.0 and perl5.6.1. INSTALLATION (cd LibXML/; if installing the LibXML version) perl Makefile.PL make make install Then look at ex.pl. That pretty much sums up the functionality. XML-SimpleObject0.53/SimpleObject.pm010064400007650000024000000161660763176647300165710ustar00garronstaffpackage XML::SimpleObject; use strict; use XML::Parser; our $VERSION = '0.53'; sub attributes { my $self = shift; my $name = shift; if ($self->{_ATTRS}) { return (%{$self->{_ATTRS}}); } } sub attribute { my $self = shift; my $name = shift; if ($self->{_ATTRS}) { return ${$self->{_ATTRS}}{$name}; } } sub value { $_[0]->{_VALUE}; } sub name { $_[0]->{_NAME}; } sub child { my $self = shift; my $tag = shift; if (ref($self->{$tag}) eq "ARRAY") { if (wantarray) { return (@{$self->{$tag}}); } else { return (${$self->{$tag}}[0]); } } return; } sub children_names { my $self = shift; my @elements; foreach my $key (keys %{$self}) { if (ref($self->{$key}) eq "ARRAY") { push @elements, $key; } } return (@elements); } sub children { my $self = shift; my $tag = shift; if ($tag) { if (ref($self->{$tag}) eq "ARRAY") { return (@{$self->{$tag}}); } } else { my @children; foreach my $key (keys %{$self}) { if (ref($self->{$key}) eq "ARRAY") { push @children, @{$self->{$key}}; } } return @children; } } sub convert { my $self = shift; my $array = shift; unless (ref($array) eq "ARRAY") { die "not an array: $array\n" } # first element will always be a hashref if (ref $array->[0] eq "HASH") { $self->{_ATTRS} = shift @$array; } while (defined (my $tag = shift @$array)) { my $content = shift @$array; if ($tag eq "0") { $self->{_VALUE} .= $content; } elsif (ref $content eq "ARRAY") { my $class = ref $self; push @{$self->{$tag}}, new $class ($content, $tag); } } } sub new { my $class = shift; if (ref $_[0] eq "ARRAY") { my $table = shift; my $name = shift; my $self = {}; bless ($self,$class); $self->{_NAME} = $name; $self->convert($table); return $self; } else { my %args = @_; my $parser = new XML::Parser (ErrorContext => $args{ErrorContext}, Style => 'Tree'); my $table = $parser->parse($args{XML}); my $self = {}; bless ($self,$class); $self->{_NAME} = ""; $self->convert($table); return $self; } } 1; __END__ =head1 NAME XML::SimpleObject - Perl extension allowing a simple object representation of a parsed XML::Parser tree. =head1 SYNOPSIS use XML::SimpleObject; # Construct with the key/value pairs as argument; this will create its # own XML::Parser object. my $xmlobj = new XML::SimpleObject(XML => $XML, ErrorContext => 2); # ... or construct with the parsed tree as the only argument, having to # create the XML::Parser object separately. my $parser = new XML::Parser (ErrorContext => 2, Style => "Tree"); my $xmlobj = new XML::SimpleObject ($parser->parse($XML)); my $filesobj = $xmlobj->child("files")->child("file"); $filesobj->name; $filesobj->value; $filesobj->attribute("type"); %attributes = $filesobj->attributes; @children = $filesobj->children; @some_children = $filesobj->children("some"); @chilren_names = $filesobj->children_names; =head1 DESCRIPTION This is a short and simple class allowing simple object access to a parsed XML::Parser tree, with methods for fetching children and attributes in as clean a manner as possible. My apologies for further polluting the XML:: space; this is a small and quick module, with easy and compact usage. See XML::SimpleObject::LibXML for the same interface for XML::LibXML. =head1 USAGE =item $xmlobj = new XML::SimpleObject($parser->parse($XML)) $parser is an XML::Parser object created with Style "Tree": my $parser = new XML::Parser (ErrorContext => 2, Style => "Tree"); After creating $xmlobj, this object can now be used to browse the XML tree with the following methods. =item $xmlobj->child('NAME') This will return a new XML::SimpleObject object using the child element NAME. =item $xmlobj->children('NAME') Called with an argument NAME, children() will return an array of XML::SimpleObject objects of element NAME. Thus, if $xmlobj represents the top-level XML element, 'children' will return an array of all elements directly below the top-level that have the element name NAME. =item $xmlobj->children Called without arguments, 'children()' will return an array of XML::SimpleObject s for all children elements of $xmlobj. These are not in the order they occur in the XML document. =item $xmlobj->children_names This will return an array of all the names of child elements for $xmlobj. You can use this to step through all the children of a given element (see EXAMPLES). Each name will occur only once, even if multiple children exist with that name. =item $xmlobj->value If the element represented by $xmlobj contains any PCDATA, this method will return that text data. =item $xmlobj->attribute('NAME') This returns the text for an attribute NAME of the XML element represented by $xmlobj. =item $xmlobj->attributes This returns a hash of key/value pairs for all elements in element $xmlobj. =head1 EXAMPLES Given this XML document: /etc/dosemu.conf dosemu.conf-drdos703.eval /etc/passwd 948 You can then interpret the tree as follows: my $parser = new XML::Parser (ErrorContext => 2, Style => "Tree"); my $xmlobj = new XML::SimpleObject ($parser->parse($XML)); print "Files: \n"; foreach my $element ($xmlobj->child("files")->children("file")) { print " filename: " . $element->child("name")->value . "\n"; if ($element->attribute("type")) { print " type: " . $element->attribute("type") . "\n"; } print " bytes: " . $element->child("bytes")->value . "\n"; } This will output: Files: filename: /etc/dosemu.conf type: symlink bytes: 20 filename: /etc/passwd bytes: 948 You can use 'children()' without arguments to step through all children of a given element: my $filesobj = $xmlobj->child("files")->child("file"); foreach my $child ($filesobj->children) { print "child: ", $child->name, ": ", $child->value, "\n"; } For the tree above, this will output: child: bytes: 20 child: dest: dosemu.conf-drdos703.eval child: name: /etc/dosemu.conf Using 'children_names()', you can step through all children for a given element: my $filesobj = $xmlobj->child("files"); foreach my $childname ($filesobj->children_names) { print "$childname has children: "; print join (", ", $filesobj->child($childname)->children_names), "\n"; } This will print: file has children: bytes, dest, name By always using 'children()', you can step through each child object, retrieving them with 'child()'. =head1 AUTHOR Dan Brian =head1 SEE ALSO perl(1), XML::Parser. =cut XML-SimpleObject0.53/test.pl010064400007650000024000000012260734160145200151350ustar00garronstaff# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use XML::SimpleObject; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code):