XML-LibXML-Iterator-1.06 000755 001750 001750 0 13743516157 15255 5 ustar 00shlomif shlomif 000000 000000 README 100644 001750 001750 561 13743516157 16200 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 This archive contains the distribution XML-LibXML-Iterator,
version 1.06:
XML::LibXML's Tree Iteration Class
This software is copyright (c) 2020 by unknown.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
This README file was generated by Dist::Zilla::Plugin::Readme v6.015.
LICENSE 100644 001750 001750 610 13743516157 16320 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 LICENSE
=======
XML::LibXML::Iterator is free software, you may use it and distribute
it under the same terms as Perl itself.
Copyright 2002-2007, Christian Glahn, All rights reserved.
DISCLAIMER
==========
THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
PARTICULAR PURPOSE.
Changes 100644 001750 001750 1331 13743516157 16627 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 History for Perl extension XML::LibXML::Iterator.
1.06 2020-10-20
- Remove stale POD
- Inspired by Lady_Aleena. Thanks!
1.05 2019-08-18
- Fix spelling errors - thanks to Debian.
- https://rt.cpan.org/Ticket/Display.html?id=125837 .
- Convert to http://dzil.org/ .
1.04 2007-09-28
- fixed RT#29262
- minor documentation fixes
1.03 2007-08-06
- fixed RT#28688 by using the provided patch
1.02 2007-06-23
- fixed RT#6873
- cleaned up the tests
- more compliance with the traversal specification
1.01 2007-06-23
- fixed RT related bugs (though with a huge delay, sorry)
1.00 2002-11-08
- extracted the modules from the main XML::LibXML bundle.
dist.ini 100644 001750 001750 744 13743516157 16767 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 name = XML-LibXML-Iterator
version = 1.06
author = unknown
license = Perl_5
copyright_holder = unknown
[@Filter]
-bundle = @SHLOMIF
-remove = License
dist = XML-LibXML-Iterator
[Prereqs / ConfigureRequires]
ExtUtils::MakeMaker = 0
[Prereqs / BuildRequires]
ExtUtils::MakeMaker = 0
[Prereqs]
XML::LibXML = 1.52
XML::NodeFilter = 0
[ReadmeMarkdownFromPod]
[Test::Kwalitee]
[Test::TidyAll]
; authordep Pod::Weaver::PluginBundle::SHLOMIF
; authordep Code::TidyAll::Plugin::TestCount
META.yml 100644 001750 001750 30506 13743516157 16633 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 ---
abstract: "XML::LibXML's Tree Iteration Class"
author:
- unknown
build_requires:
ExtUtils::MakeMaker: '0'
File::Spec: '0'
IO::Handle: '0'
IPC::Open3: '0'
Module::Build: '0.28'
Test::More: '0.88'
XML::LibXML: '1.52'
parent: '0'
perl: '5.006'
configure_requires:
ExtUtils::MakeMaker: '0'
Module::Build: '0.28'
dynamic_config: 0
generated_by: 'Dist::Zilla version 6.015, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: XML-LibXML-Iterator
provides:
XML::LibXML::Iterator:
file: lib/XML/LibXML/Iterator.pm
version: '1.06'
XML::LibXML::NodeList::Iterator:
file: lib/XML/LibXML/NodeList/Iterator.pm
version: '1.06'
requires:
XML::LibXML: '1.52'
XML::NodeFilter: '0'
overload: '0'
strict: '0'
vars: '0'
warnings: '0'
resources:
bugtracker: https://github.com/shlomif/xml-libxml-iterator/issues
homepage: http://metacpan.org/release/XML-LibXML-Iterator
repository: git://github.com/shlomif/xml-libxml-iterator.git
version: '1.06'
x_Dist_Zilla:
perl:
version: '5.032000'
plugins:
-
class: Dist::Zilla::Plugin::Prereqs
config:
Dist::Zilla::Plugin::Prereqs:
phase: test
type: requires
name: '@Filter/TestMoreDoneTesting'
version: '6.015'
-
class: Dist::Zilla::Plugin::AutoPrereqs
name: '@Filter/AutoPrereqs'
version: '6.015'
-
class: Dist::Zilla::Plugin::ExecDir
name: '@Filter/ExecDir'
version: '6.015'
-
class: Dist::Zilla::Plugin::GatherDir
config:
Dist::Zilla::Plugin::GatherDir:
exclude_filename: []
exclude_match: []
follow_symlinks: 0
include_dotfiles: 0
prefix: ''
prune_directory: []
root: .
name: '@Filter/GatherDir'
version: '6.015'
-
class: Dist::Zilla::Plugin::ManifestSkip
name: '@Filter/ManifestSkip'
version: '6.015'
-
class: Dist::Zilla::Plugin::MetaYAML
name: '@Filter/MetaYAML'
version: '6.015'
-
class: Dist::Zilla::Plugin::PruneCruft
name: '@Filter/PruneCruft'
version: '6.015'
-
class: Dist::Zilla::Plugin::Readme
name: '@Filter/Readme'
version: '6.015'
-
class: Dist::Zilla::Plugin::RunExtraTests
config:
Dist::Zilla::Role::TestRunner:
default_jobs: '9'
name: '@Filter/RunExtraTests'
version: '0.029'
-
class: Dist::Zilla::Plugin::ShareDir
name: '@Filter/ShareDir'
version: '6.015'
-
class: Dist::Zilla::Plugin::MakeMaker
config:
Dist::Zilla::Role::TestRunner:
default_jobs: '9'
name: '@Filter/MakeMaker'
version: '6.015'
-
class: Dist::Zilla::Plugin::CheckChangesHasContent
name: '@Filter/CheckChangesHasContent'
version: '0.011'
-
class: Dist::Zilla::Plugin::ConfirmRelease
name: '@Filter/ConfirmRelease'
version: '6.015'
-
class: Dist::Zilla::Plugin::Manifest
name: '@Filter/Manifest'
version: '6.015'
-
class: Dist::Zilla::Plugin::MetaConfig
name: '@Filter/MetaConfig'
version: '6.015'
-
class: Dist::Zilla::Plugin::MetaJSON
name: '@Filter/MetaJSON'
version: '6.015'
-
class: Dist::Zilla::Plugin::MetaProvides::Package
config:
Dist::Zilla::Plugin::MetaProvides::Package:
finder_objects:
-
class: Dist::Zilla::Plugin::FinderCode
name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM'
version: '6.015'
include_underscores: 0
Dist::Zilla::Role::MetaProvider::Provider:
$Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.002004'
inherit_missing: '1'
inherit_version: '1'
meta_noindex: '1'
Dist::Zilla::Role::ModuleMetadata:
Module::Metadata: '1.000037'
version: '0.006'
name: '@Filter/MetaProvides::Package'
version: '2.004003'
-
class: Dist::Zilla::Plugin::MetaResources
name: '@Filter/MetaResources'
version: '6.015'
-
class: Dist::Zilla::Plugin::ModuleBuild
config:
Dist::Zilla::Role::TestRunner:
default_jobs: '9'
name: '@Filter/ModuleBuild'
version: '6.015'
-
class: Dist::Zilla::Plugin::PkgVersion
name: '@Filter/PkgVersion'
version: '6.015'
-
class: Dist::Zilla::Plugin::PodCoverageTests
name: '@Filter/PodCoverageTests'
version: '6.015'
-
class: Dist::Zilla::Plugin::PodSyntaxTests
name: '@Filter/PodSyntaxTests'
version: '6.015'
-
class: Dist::Zilla::Plugin::Test::Compile
config:
Dist::Zilla::Plugin::Test::Compile:
bail_out_on_fail: '0'
fail_on_warning: author
fake_home: 0
filename: t/00-compile.t
module_finder:
- ':InstallModules'
needs_display: 0
phase: test
script_finder:
- ':PerlExecFiles'
skips: []
switch: []
name: '@Filter/Test::Compile'
version: '2.058'
-
class: Dist::Zilla::Plugin::Test::CPAN::Changes
config:
Dist::Zilla::Plugin::Test::CPAN::Changes:
changelog: Changes
name: '@Filter/Test::CPAN::Changes'
version: '0.012'
-
class: Dist::Zilla::Plugin::Test::EOL
config:
Dist::Zilla::Plugin::Test::EOL:
filename: xt/author/eol.t
finder:
- ':ExecFiles'
- ':InstallModules'
- ':TestFiles'
trailing_whitespace: 1
name: '@Filter/Test::EOL'
version: '0.19'
-
class: Dist::Zilla::Plugin::Test::NoTabs
config:
Dist::Zilla::Plugin::Test::NoTabs:
filename: xt/author/no-tabs.t
finder:
- ':InstallModules'
- ':ExecFiles'
- ':TestFiles'
name: '@Filter/Test::NoTabs'
version: '0.15'
-
class: Dist::Zilla::Plugin::Test::TrailingSpace
name: '@Filter/Test::TrailingSpace'
version: 0.2.0
-
class: Dist::Zilla::Plugin::TestRelease
name: '@Filter/TestRelease'
version: '6.015'
-
class: Dist::Zilla::Plugin::PodWeaver
config:
Dist::Zilla::Plugin::PodWeaver:
finder:
- ':InstallModules'
- ':ExecFiles'
plugins:
-
class: Pod::Weaver::Plugin::SingleEncoding
name: '@SHLOMIF/SingleEncoding'
version: '4.015'
-
class: Pod::Weaver::Plugin::WikiDoc
name: '@SHLOMIF/WikiDoc'
version: '0.093004'
-
class: Pod::Weaver::Plugin::EnsurePod5
name: '@CorePrep/EnsurePod5'
version: '4.015'
-
class: Pod::Weaver::Plugin::H1Nester
name: '@CorePrep/H1Nester'
version: '4.015'
-
class: Pod::Weaver::Section::Generic
name: '@SHLOMIF/Name'
version: '4.015'
-
class: Pod::Weaver::Section::Version
name: '@SHLOMIF/Version'
version: '4.015'
-
class: Pod::Weaver::Section::Region
name: '@SHLOMIF/Prelude'
version: '4.015'
-
class: Pod::Weaver::Section::Generic
name: '@SHLOMIF/Synopsis'
version: '4.015'
-
class: Pod::Weaver::Section::Generic
name: '@SHLOMIF/Description'
version: '4.015'
-
class: Pod::Weaver::Section::Generic
name: '@SHLOMIF/Usage'
version: '4.015'
-
class: Pod::Weaver::Section::Generic
name: '@SHLOMIF/Overview'
version: '4.015'
-
class: Pod::Weaver::Section::Generic
name: '@SHLOMIF/Stability'
version: '4.015'
-
class: Pod::Weaver::Section::Collect
name: Requirements
version: '4.015'
-
class: Pod::Weaver::Section::Collect
name: Attributes
version: '4.015'
-
class: Pod::Weaver::Section::Collect
name: Constructors
version: '4.015'
-
class: Pod::Weaver::Section::Collect
name: Methods
version: '4.015'
-
class: Pod::Weaver::Section::Collect
name: Functions
version: '4.015'
-
class: Pod::Weaver::Section::Leftovers
name: '@SHLOMIF/Leftovers'
version: '4.015'
-
class: Pod::Weaver::Section::Region
name: '@SHLOMIF/postlude'
version: '4.015'
-
class: Pod::Weaver::Section::Support
name: '@SHLOMIF/Support'
version: '1.013'
-
class: Pod::Weaver::Section::Authors
name: '@SHLOMIF/Authors'
version: '4.015'
-
class: Pod::Weaver::Section::Bugs
name: '@SHLOMIF/Bugs'
version: '4.015'
-
class: Pod::Weaver::Section::Contributors
name: '@SHLOMIF/Contributors'
version: '0.009'
-
class: Pod::Weaver::Section::Legal
name: '@SHLOMIF/Legal'
version: '4.015'
-
class: Pod::Weaver::Plugin::Transformer
name: '@SHLOMIF/List'
version: '4.015'
name: '@Filter/PodWeaver'
version: '4.008'
-
class: Dist::Zilla::Plugin::UploadToCPAN
name: '@Filter/UploadToCPAN'
version: '6.015'
-
class: Dist::Zilla::Plugin::Prereqs
config:
Dist::Zilla::Plugin::Prereqs:
phase: configure
type: requires
name: ConfigureRequires
version: '6.015'
-
class: Dist::Zilla::Plugin::Prereqs
config:
Dist::Zilla::Plugin::Prereqs:
phase: build
type: requires
name: BuildRequires
version: '6.015'
-
class: Dist::Zilla::Plugin::Prereqs
config:
Dist::Zilla::Plugin::Prereqs:
phase: runtime
type: requires
name: Prereqs
version: '6.015'
-
class: Dist::Zilla::Plugin::ReadmeMarkdownFromPod
config:
Dist::Zilla::Role::FileWatcher:
version: '0.006'
name: ReadmeMarkdownFromPod
version: '0.141140'
-
class: Dist::Zilla::Plugin::Test::Kwalitee
config:
Dist::Zilla::Plugin::Test::Kwalitee:
filename: xt/release/kwalitee.t
skiptest: []
name: Test::Kwalitee
version: '2.12'
-
class: Dist::Zilla::Plugin::Test::TidyAll
name: Test::TidyAll
version: '0.04'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':InstallModules'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':IncModules'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':TestFiles'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':ExtraTestFiles'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':ExecFiles'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':PerlExecFiles'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':ShareFiles'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':MainModule'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':AllFiles'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: ':NoFiles'
version: '6.015'
-
class: Dist::Zilla::Plugin::FinderCode
name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM'
version: '6.015'
zilla:
class: Dist::Zilla::Dist::Builder
config:
is_trial: '0'
version: '6.015'
x_generated_by_perl: v5.32.0
x_serialization_backend: 'YAML::Tiny version 1.73'
x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later'
MANIFEST 100644 001750 001750 753 13743516157 16454 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.015.
Build.PL
Changes
LICENSE
MANIFEST
MANIFEST.SKIP
META.json
META.yml
Makefile.PL
README
README.mkdn
dist.ini
lib/XML/LibXML/Iterator.pm
lib/XML/LibXML/NodeList/Iterator.pm
t/00-compile.t
t/01basic.t
t/02tree.t
t/03list.t
weaver.ini
xt/author/eol.t
xt/author/no-tabs.t
xt/author/pod-coverage.t
xt/author/pod-syntax.t
xt/author/tidyall.t
xt/release/cpan-changes.t
xt/release/kwalitee.t
xt/release/trailing-space.t
Build.PL 100644 001750 001750 2675 13743516157 16644 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06
# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.015.
use strict;
use warnings;
use Module::Build 0.28;
my %module_build_args = (
"build_requires" => {
"ExtUtils::MakeMaker" => 0,
"Module::Build" => "0.28"
},
"configure_requires" => {
"ExtUtils::MakeMaker" => 0,
"Module::Build" => "0.28"
},
"dist_abstract" => "XML::LibXML's Tree Iteration Class",
"dist_author" => [
"unknown"
],
"dist_name" => "XML-LibXML-Iterator",
"dist_version" => "1.06",
"license" => "perl",
"module_name" => "XML::LibXML::Iterator",
"recursive_test_files" => 1,
"requires" => {
"XML::LibXML" => "1.52",
"XML::NodeFilter" => 0,
"overload" => 0,
"strict" => 0,
"vars" => 0,
"warnings" => 0
},
"test_requires" => {
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Test::More" => "0.88",
"XML::LibXML" => "1.52",
"parent" => 0,
"perl" => "5.006"
}
);
my %fallback_build_requires = (
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Module::Build" => "0.28",
"Test::More" => "0.88",
"XML::LibXML" => "1.52",
"parent" => 0,
"perl" => "5.006"
);
unless ( eval { Module::Build->VERSION(0.4004) } ) {
delete $module_build_args{test_requires};
$module_build_args{build_requires} = \%fallback_build_requires;
}
my $build = Module::Build->new(%module_build_args);
$build->create_build_script;
META.json 100644 001750 001750 47166 13743516157 17015 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 {
"abstract" : "XML::LibXML's Tree Iteration Class",
"author" : [
"unknown"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 6.015, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "XML-LibXML-Iterator",
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0",
"Module::Build" : "0.28"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0",
"Module::Build" : "0.28"
}
},
"develop" : {
"requires" : {
"Pod::Coverage::TrustPod" : "0",
"Test::CPAN::Changes" : "0.19",
"Test::Code::TidyAll" : "0.50",
"Test::EOL" : "0",
"Test::Kwalitee" : "1.21",
"Test::More" : "0.96",
"Test::NoTabs" : "0",
"Test::Pod" : "1.41",
"Test::Pod::Coverage" : "1.08",
"Test::TrailingSpace" : "0.0203"
}
},
"runtime" : {
"requires" : {
"XML::LibXML" : "1.52",
"XML::NodeFilter" : "0",
"overload" : "0",
"strict" : "0",
"vars" : "0",
"warnings" : "0"
}
},
"test" : {
"requires" : {
"File::Spec" : "0",
"IO::Handle" : "0",
"IPC::Open3" : "0",
"Test::More" : "0.88",
"XML::LibXML" : "1.52",
"parent" : "0",
"perl" : "5.006"
}
}
},
"provides" : {
"XML::LibXML::Iterator" : {
"file" : "lib/XML/LibXML/Iterator.pm",
"version" : "1.06"
},
"XML::LibXML::NodeList::Iterator" : {
"file" : "lib/XML/LibXML/NodeList/Iterator.pm",
"version" : "1.06"
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/shlomif/xml-libxml-iterator/issues"
},
"homepage" : "http://metacpan.org/release/XML-LibXML-Iterator",
"repository" : {
"type" : "git",
"url" : "git://github.com/shlomif/xml-libxml-iterator.git",
"web" : "https://github.com/shlomif/xml-libxml-iterator"
}
},
"version" : "1.06",
"x_Dist_Zilla" : {
"perl" : {
"version" : "5.032000"
},
"plugins" : [
{
"class" : "Dist::Zilla::Plugin::Prereqs",
"config" : {
"Dist::Zilla::Plugin::Prereqs" : {
"phase" : "test",
"type" : "requires"
}
},
"name" : "@Filter/TestMoreDoneTesting",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::AutoPrereqs",
"name" : "@Filter/AutoPrereqs",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::ExecDir",
"name" : "@Filter/ExecDir",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::GatherDir",
"config" : {
"Dist::Zilla::Plugin::GatherDir" : {
"exclude_filename" : [],
"exclude_match" : [],
"follow_symlinks" : 0,
"include_dotfiles" : 0,
"prefix" : "",
"prune_directory" : [],
"root" : "."
}
},
"name" : "@Filter/GatherDir",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::ManifestSkip",
"name" : "@Filter/ManifestSkip",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::MetaYAML",
"name" : "@Filter/MetaYAML",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::PruneCruft",
"name" : "@Filter/PruneCruft",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::Readme",
"name" : "@Filter/Readme",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::RunExtraTests",
"config" : {
"Dist::Zilla::Role::TestRunner" : {
"default_jobs" : "9"
}
},
"name" : "@Filter/RunExtraTests",
"version" : "0.029"
},
{
"class" : "Dist::Zilla::Plugin::ShareDir",
"name" : "@Filter/ShareDir",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::MakeMaker",
"config" : {
"Dist::Zilla::Role::TestRunner" : {
"default_jobs" : "9"
}
},
"name" : "@Filter/MakeMaker",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::CheckChangesHasContent",
"name" : "@Filter/CheckChangesHasContent",
"version" : "0.011"
},
{
"class" : "Dist::Zilla::Plugin::ConfirmRelease",
"name" : "@Filter/ConfirmRelease",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::Manifest",
"name" : "@Filter/Manifest",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::MetaConfig",
"name" : "@Filter/MetaConfig",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::MetaJSON",
"name" : "@Filter/MetaJSON",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::MetaProvides::Package",
"config" : {
"Dist::Zilla::Plugin::MetaProvides::Package" : {
"finder_objects" : [
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM",
"version" : "6.015"
}
],
"include_underscores" : 0
},
"Dist::Zilla::Role::MetaProvider::Provider" : {
"$Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.002004",
"inherit_missing" : 1,
"inherit_version" : 1,
"meta_noindex" : 1
},
"Dist::Zilla::Role::ModuleMetadata" : {
"Module::Metadata" : "1.000037",
"version" : "0.006"
}
},
"name" : "@Filter/MetaProvides::Package",
"version" : "2.004003"
},
{
"class" : "Dist::Zilla::Plugin::MetaResources",
"name" : "@Filter/MetaResources",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::ModuleBuild",
"config" : {
"Dist::Zilla::Role::TestRunner" : {
"default_jobs" : "9"
}
},
"name" : "@Filter/ModuleBuild",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::PkgVersion",
"name" : "@Filter/PkgVersion",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::PodCoverageTests",
"name" : "@Filter/PodCoverageTests",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::PodSyntaxTests",
"name" : "@Filter/PodSyntaxTests",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::Test::Compile",
"config" : {
"Dist::Zilla::Plugin::Test::Compile" : {
"bail_out_on_fail" : 0,
"fail_on_warning" : "author",
"fake_home" : 0,
"filename" : "t/00-compile.t",
"module_finder" : [
":InstallModules"
],
"needs_display" : 0,
"phase" : "test",
"script_finder" : [
":PerlExecFiles"
],
"skips" : [],
"switch" : []
}
},
"name" : "@Filter/Test::Compile",
"version" : "2.058"
},
{
"class" : "Dist::Zilla::Plugin::Test::CPAN::Changes",
"config" : {
"Dist::Zilla::Plugin::Test::CPAN::Changes" : {
"changelog" : "Changes"
}
},
"name" : "@Filter/Test::CPAN::Changes",
"version" : "0.012"
},
{
"class" : "Dist::Zilla::Plugin::Test::EOL",
"config" : {
"Dist::Zilla::Plugin::Test::EOL" : {
"filename" : "xt/author/eol.t",
"finder" : [
":ExecFiles",
":InstallModules",
":TestFiles"
],
"trailing_whitespace" : 1
}
},
"name" : "@Filter/Test::EOL",
"version" : "0.19"
},
{
"class" : "Dist::Zilla::Plugin::Test::NoTabs",
"config" : {
"Dist::Zilla::Plugin::Test::NoTabs" : {
"filename" : "xt/author/no-tabs.t",
"finder" : [
":InstallModules",
":ExecFiles",
":TestFiles"
]
}
},
"name" : "@Filter/Test::NoTabs",
"version" : "0.15"
},
{
"class" : "Dist::Zilla::Plugin::Test::TrailingSpace",
"name" : "@Filter/Test::TrailingSpace",
"version" : "0.2.0"
},
{
"class" : "Dist::Zilla::Plugin::TestRelease",
"name" : "@Filter/TestRelease",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::PodWeaver",
"config" : {
"Dist::Zilla::Plugin::PodWeaver" : {
"finder" : [
":InstallModules",
":ExecFiles"
],
"plugins" : [
{
"class" : "Pod::Weaver::Plugin::SingleEncoding",
"name" : "@SHLOMIF/SingleEncoding",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Plugin::WikiDoc",
"name" : "@SHLOMIF/WikiDoc",
"version" : "0.093004"
},
{
"class" : "Pod::Weaver::Plugin::EnsurePod5",
"name" : "@CorePrep/EnsurePod5",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Plugin::H1Nester",
"name" : "@CorePrep/H1Nester",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Generic",
"name" : "@SHLOMIF/Name",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Version",
"name" : "@SHLOMIF/Version",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Region",
"name" : "@SHLOMIF/Prelude",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Generic",
"name" : "@SHLOMIF/Synopsis",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Generic",
"name" : "@SHLOMIF/Description",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Generic",
"name" : "@SHLOMIF/Usage",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Generic",
"name" : "@SHLOMIF/Overview",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Generic",
"name" : "@SHLOMIF/Stability",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Collect",
"name" : "Requirements",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Collect",
"name" : "Attributes",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Collect",
"name" : "Constructors",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Collect",
"name" : "Methods",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Collect",
"name" : "Functions",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Leftovers",
"name" : "@SHLOMIF/Leftovers",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Region",
"name" : "@SHLOMIF/postlude",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Support",
"name" : "@SHLOMIF/Support",
"version" : "1.013"
},
{
"class" : "Pod::Weaver::Section::Authors",
"name" : "@SHLOMIF/Authors",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Bugs",
"name" : "@SHLOMIF/Bugs",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Section::Contributors",
"name" : "@SHLOMIF/Contributors",
"version" : "0.009"
},
{
"class" : "Pod::Weaver::Section::Legal",
"name" : "@SHLOMIF/Legal",
"version" : "4.015"
},
{
"class" : "Pod::Weaver::Plugin::Transformer",
"name" : "@SHLOMIF/List",
"version" : "4.015"
}
]
}
},
"name" : "@Filter/PodWeaver",
"version" : "4.008"
},
{
"class" : "Dist::Zilla::Plugin::UploadToCPAN",
"name" : "@Filter/UploadToCPAN",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::Prereqs",
"config" : {
"Dist::Zilla::Plugin::Prereqs" : {
"phase" : "configure",
"type" : "requires"
}
},
"name" : "ConfigureRequires",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::Prereqs",
"config" : {
"Dist::Zilla::Plugin::Prereqs" : {
"phase" : "build",
"type" : "requires"
}
},
"name" : "BuildRequires",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::Prereqs",
"config" : {
"Dist::Zilla::Plugin::Prereqs" : {
"phase" : "runtime",
"type" : "requires"
}
},
"name" : "Prereqs",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::ReadmeMarkdownFromPod",
"config" : {
"Dist::Zilla::Role::FileWatcher" : {
"version" : "0.006"
}
},
"name" : "ReadmeMarkdownFromPod",
"version" : "0.141140"
},
{
"class" : "Dist::Zilla::Plugin::Test::Kwalitee",
"config" : {
"Dist::Zilla::Plugin::Test::Kwalitee" : {
"filename" : "xt/release/kwalitee.t",
"skiptest" : []
}
},
"name" : "Test::Kwalitee",
"version" : "2.12"
},
{
"class" : "Dist::Zilla::Plugin::Test::TidyAll",
"name" : "Test::TidyAll",
"version" : "0.04"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":InstallModules",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":IncModules",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":TestFiles",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":ExtraTestFiles",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":ExecFiles",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":PerlExecFiles",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":ShareFiles",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":MainModule",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":AllFiles",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":NoFiles",
"version" : "6.015"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM",
"version" : "6.015"
}
],
"zilla" : {
"class" : "Dist::Zilla::Dist::Builder",
"config" : {
"is_trial" : 0
},
"version" : "6.015"
}
},
"x_generated_by_perl" : "v5.32.0",
"x_serialization_backend" : "Cpanel::JSON::XS version 4.24",
"x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later"
}
weaver.ini 100644 001750 001750 13 13743516157 17262 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 [@SHLOMIF]
t 000755 001750 001750 0 13743516157 15441 5 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 02tree.t 100644 001750 001750 12027 13743516157 17111 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/t use strict;
use warnings;
use Test::More;
BEGIN { plan tests => 7; }
use XML::LibXML ();
use XML::LibXML::Iterator ();
my $xmlstr = "T";
my $libversion;
eval { $libversion = XML::LibXML::LIBXML_VERSION(); };
sub t01_tree_first_element
{
my $doc = XML::LibXML->new->parse_string('');
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $iterator = XML::LibXML::Iterator->new( $doc->documentElement );
my $node = $iterator->nextNode();
unless ( defined $node )
{
print "# next did not return a node\n";
return 0;
}
unless ( $node->nodeName() eq 'test' )
{
print "# expected 'test' received '" . $node->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t01_tree_first_element() );
sub t06_set_first
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $iterator = XML::LibXML::Iterator->new( $doc->documentElement );
$iterator->first();
unless ( defined $iterator->current() )
{
print "# there is no first node\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "A" )
{
print "# expected nodeName 'A' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t06_set_first() );
sub t07_set_last
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $iterator = XML::LibXML::Iterator->new( $doc->documentElement );
$iterator->last();
unless ( defined $iterator->current() )
{
print "# there is no last node\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "D" )
{
print "# expected nodeName 'D' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t07_set_last() );
sub t02_loop_forward
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $iterator = XML::LibXML::Iterator->new( $doc->documentElement );
my $i = 0;
while ( $iterator->nextNode() )
{
$i++;
}
unless ( $i == 6 )
{
print "# expected 6 iterations done " . $i . "\n";
return 0;
}
$iterator->first();
$i = 0;
while ( $iterator->nextNode() )
{
$i++;
}
unless ( $i == 5 )
{
print "# expected 5 iterations done " . $i . "\n";
return 0;
}
unless ( defined $iterator->current() )
{
print "# wen out of scope\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "D" )
{
print "# expected nodeName 'D' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t02_loop_forward() );
sub t03_loop_backward
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $iterator = XML::LibXML::Iterator->new( $doc->documentElement );
my $i = 0;
$iterator->last();
while ( $iterator->previousNode() )
{
$i++;
}
unless ( $i == 5 )
{
print "# expected 5 iterations done " . $i . "\n";
return 0;
}
return 1;
}
# TEST
ok( t03_loop_backward() );
sub t04_loop_forward_backward
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $iterator = XML::LibXML::Iterator->new( $doc->documentElement );
my $i = 0;
while ( $iterator->nextNode() )
{
$i++;
}
while ( $iterator->previousNode() )
{
$i++;
}
unless ( $i == 11 )
{
print "# expected 11 iterations done " . $i . "\n";
return 0;
}
unless ( defined $iterator->current() )
{
print "# went out of scope!\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "A" )
{
print "# expected nodeName 'A' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t04_loop_forward_backward() );
sub t05_run_iterate
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $iterator = XML::LibXML::Iterator->new( $doc->documentElement );
my $i = 0;
$iterator->iterate( sub { $i++; } );
unless ( $i == 6 )
{
print "# expected 6 iterations done " . $i . "\n";
return 0;
}
return 1;
}
# TEST
ok( t05_run_iterate() );
03list.t 100644 001750 001750 17360 13743516157 17133 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/t use strict;
use warnings;
use Test::More;
BEGIN { plan tests => 9; }
use XML::LibXML ();
use XML::LibXML::NodeList::Iterator ();
my $xmlstr = "T";
sub t01_list_first_element
{
my $doc = XML::LibXML->new->parse_string('');
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $nodelist = $doc->findnodes('/test/*');
my $iterator = XML::LibXML::NodeList::Iterator->new($nodelist);
my $node = $iterator->next();
unless ( defined $node )
{
print "# next did not return a node\n";
return 0;
}
unless ( $node->nodeName() eq 'n1' )
{
print "# expected 'n1' received '" . $node->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t01_list_first_element() );
sub t06_set_first
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $nodelist = $doc->findnodes('//A | //B | //C');
my $iterator = XML::LibXML::NodeList::Iterator->new($nodelist);
$iterator->first();
unless ( defined $iterator->current() )
{
print "# there is no first node\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "A" )
{
print "# expected nodeName 'A' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t06_set_first() );
sub t07_set_last
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $nodelist = $doc->findnodes('//A | //B | //C');
my $iterator = XML::LibXML::NodeList::Iterator->new($nodelist);
$iterator->last();
unless ( defined $iterator->current() )
{
print "# there is no last node\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "C" )
{
print "# expected nodeName 'C' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t07_set_last() );
sub t02_loop_forward
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $nodelist = $doc->findnodes('//A|//B|//C');
my $iterator = XML::LibXML::NodeList::Iterator->new($nodelist);
my $i = 0;
while ( $iterator->nextNode() )
{
$i++;
}
unless ( $i == 4 )
{
print "# expected 4 iterations done " . $i . "\n";
return 0;
}
unless ( defined $iterator->current() )
{
print "# wen out of scope\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "C" )
{
print "# expected nodeName 'C' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
$iterator->first();
$i = 0;
while ( $iterator->nextNode() )
{
$i++;
}
unless ( $i == 3 )
{
print "# expected 3 iterations done " . $i . "\n";
return 0;
}
unless ( defined $iterator->current() )
{
print "# wen out of scope\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "C" )
{
print "# expected nodeName 'C' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t02_loop_forward() );
sub t03_loop_backward
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $nodelist = $doc->findnodes('//A | //B | //C');
my $iterator = XML::LibXML::NodeList::Iterator->new($nodelist);
my $i = 0;
$iterator->last();
while ( $iterator->previousNode() )
{
$i++;
}
unless ( $i == 3 )
{
print "# expected 3 iterations done " . $i . "\n";
return 0;
}
unless ( defined $iterator->current() )
{
print "# went out of scope!\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "A" )
{
print "# expected nodeName 'A' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t03_loop_backward() );
sub t04_loop_forward_backward
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $nodelist = $doc->findnodes('//A | //B | //C');
my $iterator = XML::LibXML::NodeList::Iterator->new($nodelist);
my $i = 0;
while ( $iterator->nextNode() )
{
$i++;
}
while ( $iterator->previousNode() )
{
$i++;
}
unless ( $i == 7 )
{
print "# expected 7 iterations done " . $i . "\n";
return 0;
}
unless ( defined $iterator->current() )
{
print "# went out of scope!\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "A" )
{
print "# expected nodeName 'A' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t04_loop_forward_backward() );
sub t05_run_iterate
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $nodelist = $doc->findnodes('//A | //B | //C');
my $iterator = XML::LibXML::NodeList::Iterator->new($nodelist);
my $i = 0;
$iterator->iterate( sub { $i++; } );
unless ( $i == 4 )
{
print "# expected 4 iterations done " . $i . "\n";
return 0;
}
return 1;
}
# TEST
ok( t05_run_iterate() );
# RT#28688
package MyFilter;
use parent qw(XML::NodeFilter);
use XML::NodeFilter qw(:results);
sub accept_node
{
my $self = shift;
my $node = shift;
if ( !UNIVERSAL::isa( $node, 'XML::LibXML::Element' ) )
{
die "invalid node in MyFilter::accept_node()";
}
return FILTER_DECLINED;
}
package main;
sub t08_last_with_filter
{
my $doc = XML::LibXML->new->parse_string($xmlstr);
unless ( defined $doc )
{
print "# XML string was not parsed properly\n";
return 0;
}
my $nodelist = $doc->findnodes('//*');
my $iterator = XML::LibXML::NodeList::Iterator->new($nodelist);
$iterator->add_filter( MyFilter->new() );
$iterator->last();
unless ( defined $iterator->current() )
{
print "# there is no last node\n";
return 0;
}
unless ( $iterator->current()->nodeName() eq "D" )
{
print "# expected nodeName 'D' received '"
. $iterator->current()->nodeName() . "'\n";
return 0;
}
return 1;
}
# TEST
ok( t08_last_with_filter() );
# END RT#28688
# RT#29262
sub t09_pass_nodes
{
my $doc = XML::LibXML->new->parse_string('');
my $nodelist = $doc->findnodes('/a/*');
my $iterator = XML::LibXML::NodeList::Iterator->new($nodelist);
my $i = 0;
my $cstr = '';
$iterator->iterate(
sub {
my ( $s, $n ) = @_;
if ( defined $n && $n->can('nodeName') )
{
$i++;
$cstr .= $n->nodeName();
}
}
);
unless ( $i == 2 )
{
print "# wrong number of nodes has been processed! $i\n";
return 0;
}
unless ( $cstr eq 'bc' )
{
print "# wrong nodes have been processed! '$cstr'\n";
return 0;
}
return 1;
}
# TEST
ok( t09_pass_nodes() );
# END RT#29262
README.mkdn 100644 001750 001750 25075 13743516157 17177 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 # NAME
XML::LibXML::Iterator - XML::LibXML's Tree Iteration Class
# VERSION
version 1.06
# SYNOPSIS
use XML::LibXML;
use XML::LibXML::Iterator;
my $doc = XML::LibXML->new->parse_string( $somedata );
my $iter= XML::LibXML::Iterator->new( $doc );
$iter->iterator_function( \&iterator_function );
# more control on the flow
while ( $iter->nextNode ) {
# do something
}
# operate on the entire tree
$iter->iterate( \&callback_function );
# DESCRIPTION
XML::LibXML::Iterator is an iterator class for XML::LibXML parsed
documents. This class allows one to iterate the document tree as it were a
linear data structure. It is possible to step back and forth between
the nodes of the tree and do certain operations on that
nodes. Different to XPath the nodes are not prefetched but will be
calculated for each step. Therefore an iterator is sensible towards
the current state of a document tree on each step, while XPath is only
per query executed.
## What is an iterator?
XML::LibXML offers by default a W3C DOM interface on the parsed XML
documents. This tree has per definition four directions to be
traversed: Up, down, foreward and backward. Therefore a tree can be
considered two dimensional. Although a tree is still one more simple
datastructure it is way to complex for some operations. So the
XML::LibXML::Iterator class breaks the for operations down to only
two: backward and forward. For some people this easier to understand
than DOM or SAX as this follows more the way one actually reads an XML
document.
Therefore an iterator has three basic functions:
- nextNode()
- current()
- previousNode()
That's it. With an iterator one does not have to decide when to dive
into a subtree or find a parent. It is not even required to care about
the boundaries of a certain level. The iterator will get the next node
for you until there is no node left to handle.
In short: An iterator will answer the question about what to do next.
## How to use XML::LibXML::Iterator?
XML::LibXML::Iterator requires a parsed document or at least a node to
operate on. This node is passed to the iterator class and will be used
as the **first** node of the iteration. One can always reset the
iterator to the first node by using the first()-function.
Once XML::LibXML::Iterator is initialized the tree can be traversed by
using either next() or previous(). Both function will return a
XML::LibXML::Node object if there is such object available.
Since the current object hold by the iterator class is always
available via the current() function.
The following example may clarify this:
# get the document from wherever you like
my $doc = XML::LibXML->new->parse_stream( *SOMEINPUT );
# get the iterator for the document root.
my $iter = XML::LibXML::Iterator->new( $doc->documentElement );
# walk through the document
while ( $iter->nextNode() ) {
my $curnode = $iter->current();
print $curnode->nodeType();
}
# now get back to the beginning
$iter->first();
my $curnode = $iter->current();
print $curnode->nodeType();
Actually the functions nextNode(), previousNode(), first(), last() and
current() do return the node which is current after the
operation. E.g. nextNode() moves to the next node if possible and then
returns the node. Thus the while-loop in the example can be written
as
while ( $iter->nextNode() ) {
print $_->nodeType();
}
Note, that just relieing on the return value of next() and previous()
is somewhat dangerous, because both functions return **undef** in case
of reaching the iteration boundaries. That means it is not possible
to iterate past the last element or before the first one.
## Node Filters
XML::LibXML::Iterator accepts XML::NodeFilters to limit the nodes made
available to the caller. Any nodefilter applied to
XML::LibXML::Iterator will test if a node returned by the iteration
function is visible to the caller.
Different to the DOM Traversal Specification, XML::LibXML::Iterator
allows filter stacks. This means it is possible to apply more than a
single node filter to your node iterator.
## Complex Iterations
By default XML::LibXML::Iterator will access all nodes of a given DOM
tree. An interation based on the default iterator will access each
single node in the given subtree once. The order how the nodes will be
accessed is given by the following order:
node -> node's childnodes -> node's next sibling
In combination with XML::Nodefilter this is best for a wide range of
scripts and applications. Nevertheless this is still to restrictive
for some applications. XML::LibXML::Iterator allows one to change that
behaviour. This is done by resetting XML::LibXML::Iterator's iterator
function. By using the method iterator\_function() to override the
default iterator function, it is possible to implement iterations
based on any iteration rule imaginable.
A valid iterator function has to take two parameters: As the first
parameter it will receive the iterator object itself, as second the
direction of the iteration will be passed. The direction is either 1
(for next()) or -1 (for previous()). As the iterator-function is
called by next() and previous() the interator-function has to be aware
about the iteration boundaries. In case the iteration would pass the
boundary for that operation, the function has to return
undefined. Also the iterator function has to return the new current node,
instead of setting it itself.
\*DEVELOPER NOTE\* In order a single stepping is rather limited, the
direction is given by the sign of the passed integer value. The value
of the passed parameter will be used as an indication how many steps
should be done. Therefor the interation direction should be tested
relative to '0' and not as a equation. A basic template for a iterator
function therefore will look like this:
sub iterator_func_templ {
my $iter = shift;
my $step = shift;
my $node = undef;
my $current = $iter->current();
if ( $step > 0 ) {
# move forward
}
else {
# move backward
$step *= -1; # remove the sign
}
return $node;
}
## Repeated Operation
Another feature of XML::LibXML::Iterator is the ability to repeat a
single operation on all nodes in scope. Instead of writing a loop one
can specify the operation as a function, that it applied on each node
found. The function that does the trick, is named iterate().
iterate() takes again two parameter: First the iterator object, second
the node to operate on. iterate() will iterate through the entire
document starting with the first node. If one has already started an
iteration, the internal position will be reset to the first node.
The following example will show how this works:
$iter->iterate( sub {my ($iter,$node)=@_; map {$iter->setNodeName( lc $iter->nodeName ) if $iter->nodeType != NAMESPACE_DECLARATION } ($node, $node->attributes); } );
This extra long line lowercases all tagnames and the names of the
attributes in a given subtree.
# METHODS
- new($first\_node)
- default\_iterator
- first()
- next()
- nextNode()
- previous()
- previousNode()
- last()
- current()
- index()
- iterator\_function($funcion\_ref)
- set\_filter(@filter\_list)
- add\_filter(@filter\_list)
- iterate($function\_ref)
# SEE ALSO
[XML::LibXML::Node](https://metacpan.org/pod/XML%3A%3ALibXML%3A%3ANode), [XML::NodeFilter](https://metacpan.org/pod/XML%3A%3ANodeFilter)
# AUTHOR
Christian Glahn,
# COPYRIGHT
(c) 2002-2007, Christian Glahn. All rights reserved.
This package is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
# SUPPORT
## Websites
The following websites have more information about this module, and may be of help to you. As always,
in addition to those websites please use your favorite search engine to discover more resources.
- MetaCPAN
A modern, open-source CPAN search engine, useful to view POD in HTML format.
[https://metacpan.org/release/XML-LibXML-Iterator](https://metacpan.org/release/XML-LibXML-Iterator)
- RT: CPAN's Bug Tracker
The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
[https://rt.cpan.org/Public/Dist/Display.html?Name=XML-LibXML-Iterator](https://rt.cpan.org/Public/Dist/Display.html?Name=XML-LibXML-Iterator)
- CPANTS
The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
[http://cpants.cpanauthors.org/dist/XML-LibXML-Iterator](http://cpants.cpanauthors.org/dist/XML-LibXML-Iterator)
- CPAN Testers
The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
[http://www.cpantesters.org/distro/X/XML-LibXML-Iterator](http://www.cpantesters.org/distro/X/XML-LibXML-Iterator)
- CPAN Testers Matrix
The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
[http://matrix.cpantesters.org/?dist=XML-LibXML-Iterator](http://matrix.cpantesters.org/?dist=XML-LibXML-Iterator)
- CPAN Testers Dependencies
The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
[http://deps.cpantesters.org/?module=XML::LibXML::Iterator](http://deps.cpantesters.org/?module=XML::LibXML::Iterator)
## Bugs / Feature Requests
Please report any bugs or feature requests by email to `bug-xml-libxml-iterator at rt.cpan.org`, or through
the web interface at [https://rt.cpan.org/Public/Bug/Report.html?Queue=XML-LibXML-Iterator](https://rt.cpan.org/Public/Bug/Report.html?Queue=XML-LibXML-Iterator). You will be automatically notified of any
progress on the request by the system.
## Source Code
The code is open to the world, and available for you to hack on. Please feel free to browse it and play
with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
from your repository :)
[https://github.com/shlomif/xml-libxml-iterator](https://github.com/shlomif/xml-libxml-iterator)
git clone git://github.com/shlomif/xml-libxml-iterator.git
# AUTHOR
unknown
# BUGS
Please report any bugs or feature requests on the bugtracker website
[https://github.com/shlomif/xml-libxml-iterator/issues](https://github.com/shlomif/xml-libxml-iterator/issues)
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
# COPYRIGHT AND LICENSE
This software is copyright (c) 2020 by unknown.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
01basic.t 100644 001750 001750 360 13743516157 17167 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/t use strict;
use warnings;
use Test::More;
use vars qw/ $loaded /;
BEGIN { plan tests => 1; }
END
{
# TEST
if ($loaded) { ok(1); }
}
use XML::LibXML::Iterator ();
use XML::LibXML::NodeList::Iterator ();
$loaded = 1;
Makefile.PL 100644 001750 001750 3132 13743516157 17307 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.015.
use strict;
use warnings;
use 5.006;
use ExtUtils::MakeMaker;
my %WriteMakefileArgs = (
"ABSTRACT" => "XML::LibXML's Tree Iteration Class",
"AUTHOR" => "unknown",
"BUILD_REQUIRES" => {
"ExtUtils::MakeMaker" => 0,
"Module::Build" => "0.28"
},
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => 0,
"Module::Build" => "0.28"
},
"DISTNAME" => "XML-LibXML-Iterator",
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.006",
"NAME" => "XML::LibXML::Iterator",
"PREREQ_PM" => {
"XML::LibXML" => "1.52",
"XML::NodeFilter" => 0,
"overload" => 0,
"strict" => 0,
"vars" => 0,
"warnings" => 0
},
"TEST_REQUIRES" => {
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Test::More" => "0.88",
"XML::LibXML" => "1.52",
"parent" => 0
},
"VERSION" => "1.06",
"test" => {
"TESTS" => "t/*.t"
}
);
my %FallbackPrereqs = (
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Module::Build" => "0.28",
"Test::More" => "0.88",
"XML::LibXML" => "1.52",
"XML::NodeFilter" => 0,
"overload" => 0,
"parent" => 0,
"strict" => 0,
"vars" => 0,
"warnings" => 0
);
unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{BUILD_REQUIRES};
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
MANIFEST.SKIP 100644 001750 001750 3 13743516157 17145 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06 ~$
00-compile.t 100644 001750 001750 2713 13743516157 17636 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/t use 5.006;
use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058
use Test::More;
plan tests => 2 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
my @module_files = (
'XML/LibXML/Iterator.pm',
'XML/LibXML/NodeList/Iterator.pm'
);
# no fake home requested
my @switches = (
-d 'blib' ? '-Mblib' : '-Ilib',
);
use File::Spec;
use IPC::Open3;
use IO::Handle;
open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
my @warnings;
for my $lib (@module_files)
{
# see L
my $stderr = IO::Handle->new;
diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
$^X, @switches, '-e', "require q[$lib]"))
if $ENV{PERL_COMPILE_TEST_DEBUG};
my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
binmode $stderr, ':crlf' if $^O eq 'MSWin32';
my @_warnings = <$stderr>;
waitpid($pid, 0);
is($?, 0, "$lib loaded ok");
shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
and not eval { +require blib; blib->VERSION('1.01') };
if (@_warnings)
{
warn @_warnings;
push @warnings, @_warnings;
}
}
is(scalar(@warnings), 0, 'no warnings found')
or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};
author 000755 001750 001750 0 13743516157 17133 5 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt eol.t 100644 001750 001750 573 13743516157 20224 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt/author use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::EOL 0.19
use Test::More 0.88;
use Test::EOL;
my @files = (
'lib/XML/LibXML/Iterator.pm',
'lib/XML/LibXML/NodeList/Iterator.pm',
't/00-compile.t',
't/01basic.t',
't/02tree.t',
't/03list.t'
);
eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files;
done_testing;
no-tabs.t 100644 001750 001750 541 13743516157 21003 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt/author use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15
use Test::More 0.88;
use Test::NoTabs;
my @files = (
'lib/XML/LibXML/Iterator.pm',
'lib/XML/LibXML/NodeList/Iterator.pm',
't/00-compile.t',
't/01basic.t',
't/02tree.t',
't/03list.t'
);
notabs_ok($_) foreach @files;
done_testing;
tidyall.t 100644 001750 001750 522 13743516157 21101 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt/author # This file was automatically generated by Dist::Zilla::Plugin::Test::TidyAll v$VERSION
use Test::More 0.88;
use Test::Code::TidyAll 0.24;
tidyall_ok(
verbose => ( exists $ENV{TEST_TIDYALL_VERBOSE} ? $ENV{TEST_TIDYALL_VERBOSE} : 0 ),
jobs => ( exists $ENV{TEST_TIDYALL_JOBS} ? $ENV{TEST_TIDYALL_JOBS} : 1 ),
);
done_testing;
release 000755 001750 001750 0 13743516157 17251 5 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt kwalitee.t 100644 001750 001750 275 13743516157 21367 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt/release # this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.12
use strict;
use warnings;
use Test::More 0.88;
use Test::Kwalitee 1.21 'kwalitee_ok';
kwalitee_ok();
done_testing;
pod-syntax.t 100644 001750 001750 252 13743516157 21545 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt/author #!perl
# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
use strict; use warnings;
use Test::More;
use Test::Pod 1.41;
all_pod_files_ok();
pod-coverage.t 100644 001750 001750 334 13743516157 22013 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt/author #!perl
# This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests.
use Test::Pod::Coverage 1.08;
use Pod::Coverage::TrustPod;
all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' });
cpan-changes.t 100644 001750 001750 344 13743516157 22106 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt/release use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.012
use Test::More 0.96 tests => 1;
use Test::CPAN::Changes;
subtest 'changes_ok' => sub {
changes_file_ok('Changes');
};
LibXML 000755 001750 001750 0 13743516157 17473 5 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/lib/XML Iterator.pm 100644 001750 001750 37224 13743516157 22012 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/lib/XML/LibXML #
#
package XML::LibXML::Iterator;
$XML::LibXML::Iterator::VERSION = '1.06';
use strict;
use warnings;
use XML::NodeFilter qw(:results);
use vars qw($VERSION);
$VERSION = '1.04';
## no critic
use overload
'++' => sub { $_[0]->nextNode(); $_[0]; },
'--' => sub { $_[0]->previousNode(); $_[0]; },
'<>' => sub { return wantarray ? $_[0]->_get_all() : $_[0]->nextNode(); },
;
## use critic
sub new
{
my $class = shift;
my $node = shift;
return undef unless defined $node;
my $self = bless {}, $class;
$self->{FIRST} = $node;
# $self->first;
$self->{CURRENT} = undef;
$self->{INDEX} = -1;
$self->{ITERATOR} = \&default_iterator;
$self->{FILTERS} = [];
return $self;
}
sub iterator_function
{
my $self = shift;
my $func = shift;
return undef() if defined $func and ref($func) ne "CODE";
$self->first;
if ( defined $func )
{
$self->{ITERATOR} = $func;
}
else
{
$self->{ITERATOR} = \&default_iterator;
}
}
sub set_filter
{
my $self = shift;
$self->{FILTERS} = [@_];
}
sub add_filter
{
my $self = shift;
push @{ $self->{FILTERS} }, @_;
}
sub current { return $_[0]->{CURRENT}; }
sub index { return $_[0]->{INDEX}; }
sub next { return $_[0]->nextNode(); }
sub previous { return $_[0]->previousNode(); }
sub nextNode
{
my $self = shift;
my @filters = @{ $self->{FILTERS} };
my $node = undef;
if ( $self->{INDEX} != -1 )
{
my $fv = FILTER_SKIP;
unless ( scalar @filters > 0 )
{
$fv = FILTER_DECLINED;
}
while (1)
{
$node = $self->{ITERATOR}->( $self, 1 );
last unless defined $node;
foreach my $f (@filters)
{
$fv = $f->accept_node($node);
last if $fv;
}
last if $fv == FILTER_ACCEPT or $fv == FILTER_DECLINED;
}
}
else
{
$node = $self->first();
}
if ( defined $node )
{
$self->{CURRENT} = $node;
if ( $node->isSameNode( $self->{FIRST} ) )
{
$self->{INDEX} = 0;
}
else
{
$self->{INDEX}++;
}
}
return $node;
}
sub previousNode
{
my $self = shift;
my @filters = @{ $self->{FILTERS} };
my $node = undef;
my $fv = FILTER_SKIP;
unless ( scalar @filters > 0 )
{
$fv = FILTER_DECLINED;
}
while (1)
{
$node = $self->{ITERATOR}->( $self, -1 );
last unless defined $node;
foreach my $f (@filters)
{
$fv = $f->accept_node($node);
last if $fv;
}
last if $fv == FILTER_ACCEPT or $fv == FILTER_DECLINED;
}
if ( defined $node )
{
$self->{CURRENT} = $node;
$self->{INDEX}--;
}
return $node;
}
sub first
{
my $self = shift;
if ( scalar @_ )
{
$self->{FIRST} = shift;
}
$self->{CURRENT} = $self->{FIRST};
# this logic is required if the node is not allowed to be shown
my @filters = @{ $self->{FILTERS} || [] };
my $fv = FILTER_DECLINED;
foreach my $f (@filters)
{
$fv = $f->accept_node( $self->{CURRENT} );
last if $fv;
}
$fv ||= FILTER_ACCEPT;
unless ( $fv == FILTER_ACCEPT )
{
return undef;
}
$self->{INDEX} = 0;
return $self->current;
}
sub last
{
my $self = shift;
while ( $self->next ) { }
return $self->current;
}
sub iterate
{
my $self = shift;
my $function = shift;
return undef() unless defined $function and ref($function) eq 'CODE';
my $rv;
my $node = $self->first;
while ($node)
{
$rv = $function->( $self, $node );
$node = $self->next;
}
return $rv;
}
sub default_iterator
{
my $self = shift;
my $dir = shift;
my $node = undef;
if ( $dir < 0 )
{
return undef
if $self->{CURRENT}->isSameNode( $self->{FIRST} )
and $self->{INDEX} <= 0;
$node = $self->{CURRENT}->previousSibling;
return $self->{CURRENT}->parentNode unless defined $node;
while ( $node->hasChildNodes )
{
$node = $node->lastChild;
}
}
else
{
if ( defined $self->{CURRENT} )
{
return undef
if $self->{CURRENT}->isSameNode( $self->{FIRST} )
and $self->{INDEX} > 0;
if ( $self->{CURRENT}->hasChildNodes )
{
$node = $self->{CURRENT}->firstChild;
}
else
{
$node = $self->{CURRENT}->nextSibling;
my $pnode = $self->{CURRENT}->parentNode;
while ( not defined $node )
{
last unless defined $pnode;
$node = $pnode->nextSibling;
$pnode = $pnode->parentNode unless defined $node;
}
}
}
else
{
$self->{CURRENT} = $self->{FIRST};
$node = $self->{CURRENT};
}
}
return $node;
}
# helper function for the <> operator
# returns all nodes that have not yet been accessed
sub _get_all
{
my $self = shift;
my @retval = ();
my $node;
while ( $node = $self->next() )
{
push @retval, $node;
}
return @retval;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
XML::LibXML::Iterator - XML::LibXML's Tree Iteration Class
=head1 VERSION
version 1.06
=head1 SYNOPSIS
use XML::LibXML;
use XML::LibXML::Iterator;
my $doc = XML::LibXML->new->parse_string( $somedata );
my $iter= XML::LibXML::Iterator->new( $doc );
$iter->iterator_function( \&iterator_function );
# more control on the flow
while ( $iter->nextNode ) {
# do something
}
# operate on the entire tree
$iter->iterate( \&callback_function );
=head1 DESCRIPTION
XML::LibXML::Iterator is an iterator class for XML::LibXML parsed
documents. This class allows one to iterate the document tree as it were a
linear data structure. It is possible to step back and forth between
the nodes of the tree and do certain operations on that
nodes. Different to XPath the nodes are not prefetched but will be
calculated for each step. Therefore an iterator is sensible towards
the current state of a document tree on each step, while XPath is only
per query executed.
=head2 What is an iterator?
XML::LibXML offers by default a W3C DOM interface on the parsed XML
documents. This tree has per definition four directions to be
traversed: Up, down, foreward and backward. Therefore a tree can be
considered two dimensional. Although a tree is still one more simple
datastructure it is way to complex for some operations. So the
XML::LibXML::Iterator class breaks the for operations down to only
two: backward and forward. For some people this easier to understand
than DOM or SAX as this follows more the way one actually reads an XML
document.
Therefore an iterator has three basic functions:
=over 4
=item * nextNode()
=item * current()
=item * previousNode()
=back
That's it. With an iterator one does not have to decide when to dive
into a subtree or find a parent. It is not even required to care about
the boundaries of a certain level. The iterator will get the next node
for you until there is no node left to handle.
In short: An iterator will answer the question about what to do next.
=head2 How to use XML::LibXML::Iterator?
XML::LibXML::Iterator requires a parsed document or at least a node to
operate on. This node is passed to the iterator class and will be used
as the B node of the iteration. One can always reset the
iterator to the first node by using the first()-function.
Once XML::LibXML::Iterator is initialized the tree can be traversed by
using either next() or previous(). Both function will return a
XML::LibXML::Node object if there is such object available.
Since the current object hold by the iterator class is always
available via the current() function.
The following example may clarify this:
# get the document from wherever you like
my $doc = XML::LibXML->new->parse_stream( *SOMEINPUT );
# get the iterator for the document root.
my $iter = XML::LibXML::Iterator->new( $doc->documentElement );
# walk through the document
while ( $iter->nextNode() ) {
my $curnode = $iter->current();
print $curnode->nodeType();
}
# now get back to the beginning
$iter->first();
my $curnode = $iter->current();
print $curnode->nodeType();
Actually the functions nextNode(), previousNode(), first(), last() and
current() do return the node which is current after the
operation. E.g. nextNode() moves to the next node if possible and then
returns the node. Thus the while-loop in the example can be written
as
while ( $iter->nextNode() ) {
print $_->nodeType();
}
Note, that just relieing on the return value of next() and previous()
is somewhat dangerous, because both functions return B in case
of reaching the iteration boundaries. That means it is not possible
to iterate past the last element or before the first one.
=head2 Node Filters
XML::LibXML::Iterator accepts XML::NodeFilters to limit the nodes made
available to the caller. Any nodefilter applied to
XML::LibXML::Iterator will test if a node returned by the iteration
function is visible to the caller.
Different to the DOM Traversal Specification, XML::LibXML::Iterator
allows filter stacks. This means it is possible to apply more than a
single node filter to your node iterator.
=head2 Complex Iterations
By default XML::LibXML::Iterator will access all nodes of a given DOM
tree. An interation based on the default iterator will access each
single node in the given subtree once. The order how the nodes will be
accessed is given by the following order:
node -> node's childnodes -> node's next sibling
In combination with XML::Nodefilter this is best for a wide range of
scripts and applications. Nevertheless this is still to restrictive
for some applications. XML::LibXML::Iterator allows one to change that
behaviour. This is done by resetting XML::LibXML::Iterator's iterator
function. By using the method iterator_function() to override the
default iterator function, it is possible to implement iterations
based on any iteration rule imaginable.
A valid iterator function has to take two parameters: As the first
parameter it will receive the iterator object itself, as second the
direction of the iteration will be passed. The direction is either 1
(for next()) or -1 (for previous()). As the iterator-function is
called by next() and previous() the interator-function has to be aware
about the iteration boundaries. In case the iteration would pass the
boundary for that operation, the function has to return
undefined. Also the iterator function has to return the new current node,
instead of setting it itself.
*DEVELOPER NOTE* In order a single stepping is rather limited, the
direction is given by the sign of the passed integer value. The value
of the passed parameter will be used as an indication how many steps
should be done. Therefor the interation direction should be tested
relative to '0' and not as a equation. A basic template for a iterator
function therefore will look like this:
sub iterator_func_templ {
my $iter = shift;
my $step = shift;
my $node = undef;
my $current = $iter->current();
if ( $step > 0 ) {
# move forward
}
else {
# move backward
$step *= -1; # remove the sign
}
return $node;
}
=head2 Repeated Operation
Another feature of XML::LibXML::Iterator is the ability to repeat a
single operation on all nodes in scope. Instead of writing a loop one
can specify the operation as a function, that it applied on each node
found. The function that does the trick, is named iterate().
iterate() takes again two parameter: First the iterator object, second
the node to operate on. iterate() will iterate through the entire
document starting with the first node. If one has already started an
iteration, the internal position will be reset to the first node.
The following example will show how this works:
$iter->iterate( sub {my ($iter,$node)=@_; map {$iter->setNodeName( lc $iter->nodeName ) if $iter->nodeType != NAMESPACE_DECLARATION } ($node, $node->attributes); } );
This extra long line lowercases all tagnames and the names of the
attributes in a given subtree.
=head1 METHODS
=over 4
=item * new($first_node)
=item * default_iterator
=item * first()
=item * next()
=item * nextNode()
=item * previous()
=item * previousNode()
=item * last()
=item * current()
=item * index()
=item * iterator_function($funcion_ref)
=item * set_filter(@filter_list)
=item * add_filter(@filter_list)
=item * iterate($function_ref)
=back
=head1 SEE ALSO
L, L
=head1 AUTHOR
Christian Glahn, Ephish@cpan.orgE
=head1 COPYRIGHT
(c) 2002-2007, Christian Glahn. All rights reserved.
This package is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
=head1 SUPPORT
=head2 Websites
The following websites have more information about this module, and may be of help to you. As always,
in addition to those websites please use your favorite search engine to discover more resources.
=over 4
=item *
MetaCPAN
A modern, open-source CPAN search engine, useful to view POD in HTML format.
L
=item *
RT: CPAN's Bug Tracker
The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
L
=item *
CPANTS
The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
L
=item *
CPAN Testers
The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
L
=item *
CPAN Testers Matrix
The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
L
=item *
CPAN Testers Dependencies
The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
L
=back
=head2 Bugs / Feature Requests
Please report any bugs or feature requests by email to C, or through
the web interface at L. You will be automatically notified of any
progress on the request by the system.
=head2 Source Code
The code is open to the world, and available for you to hack on. Please feel free to browse it and play
with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
from your repository :)
L
git clone git://github.com/shlomif/xml-libxml-iterator.git
=head1 AUTHOR
unknown
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website
L
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2020 by unknown.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
trailing-space.t 100644 001750 001750 1034 13743516157 22476 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/xt/release #!perl
use strict;
use warnings;
use Test::More;
eval "use Test::TrailingSpace";
if ($@)
{
plan skip_all => "Test::TrailingSpace required for trailing space test.";
}
else
{
plan tests => 1;
}
# TODO: add .pod, .PL, the README/Changes/TODO/etc. documents and possibly
# some other stuff.
my $finder = Test::TrailingSpace->new(
{
root => '.',
filename_regex => qr#(?:\.(?:t|pm|pl|xs|c|h|txt|pod|PL)|README|Changes|TODO|LICENSE)\z#,
},
);
# TEST
$finder->no_trailing_space(
"No trailing space was found."
);
NodeList 000755 001750 001750 0 13743516157 21214 5 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/lib/XML/LibXML Iterator.pm 100644 001750 001750 16766 13743516157 23543 0 ustar 00shlomif shlomif 000000 000000 XML-LibXML-Iterator-1.06/lib/XML/LibXML/NodeList # $Id: Iterator.pm,v 1.1.1.1 2002/11/08 17:18:36 phish Exp $
#
package XML::LibXML::NodeList::Iterator;
$XML::LibXML::NodeList::Iterator::VERSION = '1.06';
use strict;
use warnings;
use XML::NodeFilter qw(:results);
use vars qw($VERSION);
$VERSION = "1.03";
## no critic
use overload
'++' => sub { $_[0]->nextNode(); $_[0]; },
'--' => sub { $_[0]->previousNode(); $_[0] },
'<>' => sub { return wantarray ? $_[0]->_get_all : $_[0]->nextNode(); },
;
## use critic
sub new
{
my $class = shift;
my $list = shift;
my $self = undef;
if ( defined $list )
{
$self = bless [ $list, -1, [], ], $class;
}
return $self;
}
sub set_filter
{
my $self = shift;
$self->[2] = [@_];
}
sub add_filter
{
my $self = shift;
push @{ $self->[2] }, @_;
}
# helper function.
sub accept_node
{
foreach ( @{ $_[0][2] } )
{
my $r = $_->accept_node( $_[1] );
return $r if $r;
}
# no filters or all decline ...
return FILTER_ACCEPT;
}
sub first
{
$_[0][1] = 0;
my $s = scalar( @{ $_[0][0] } );
while ( $_[0][1] < $s )
{
last if $_[0]->accept_node( $_[0][0][ $_[0][1] ] ) == FILTER_ACCEPT;
$_[0][1]++;
}
return undef if $_[0][1] == $s;
return $_[0][0][ $_[0][1] ];
}
sub last
{
my $i = scalar( @{ $_[0][0] } ) - 1;
while ( $i >= 0 )
{
if ( $_[0]->accept_node( $_[0][0][$i] ) == FILTER_ACCEPT )
{
$_[0][1] = $i;
last;
}
$i--;
}
if ( $i < 0 )
{
# this costs a lot, but is more safe
return $_[0]->first;
}
return $_[0][0][$i];
}
sub current
{
if ( $_[0][1] >= 0 || $_[0][1] < scalar @{ $_[0][0] } )
{
return $_[0][0][ $_[0][1] ];
}
return undef;
}
sub index
{
if ( $_[0][1] >= 0 || $_[0][1] < scalar @{ $_[0][0] } )
{
return $_[0][1];
}
return undef;
}
sub next { return $_[0]->nextNode(); }
sub previous { return $_[0]->previousNode(); }
sub nextNode
{
my $nlen = scalar @{ $_[0][0] };
if ( $nlen <= ( $_[0][1] + 1 ) )
{
return undef;
}
my $i = $_[0][1];
$i = -1 if $i < 0; # assure that we end up with the first
# element in the first iteration
while (1)
{
$i++;
return undef if $i >= $nlen;
if ( $_[0]->accept_node( $_[0][0]->[$i] ) == FILTER_ACCEPT )
{
$_[0][1] = $i;
last;
}
}
return $_[0][0]->[ $_[0][1] ];
}
sub previousNode
{
if ( $_[0][1] <= 0 )
{
return undef;
}
my $i = $_[0][1];
while (1)
{
$i--;
return undef if $i < 0;
if ( $_[0]->accept_node( $_[0][0]->[$i] ) == FILTER_ACCEPT )
{
$_[0][1] = $i;
last;
}
}
return $_[0][0][ $_[0][1] ];
}
sub iterate
{
my $self = shift;
my $funcref = shift;
my $rv;
return () unless defined $funcref && ref($funcref) eq 'CODE';
$self->[1] = -1; # first element
while ( my $node = $self->next )
{
$rv = $funcref->( $self, $node );
}
return $rv;
}
# helper function for the <> operator
# returns all nodes that have not yet been accessed
sub _get_all
{
my $self = shift;
my @retval = ();
my $node;
while ( $node = $self->next() )
{
push @retval, $node;
}
return @retval;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
XML::LibXML::NodeList::Iterator - Iteration Class for XML::LibXML XPath results
=head1 VERSION
version 1.06
=head1 SYNOPSIS
use XML::LibXML;
use XML::LibXML::NodeList::Iterator;
my $doc = XML::LibXML->new->parse_string( $somedata );
my $nodelist = $doc->findnodes( $somexpathquery );
my $iter= XML::LibXML::NodeList::Iterator->new( $nodelist );
# more control on the flow
while ( $iter->nextNode ) {
# do something
}
# operate on the entire tree
$iter->iterate( \&operate );
=head1 DESCRIPTION
XML::LibXML::NodeList::Iterator is very similar to
XML::LibXML::Iterator, but it does not iterate on the tree structure
but on a XML::LibXML::NodeList object. Because XML::LibXML::NodeList
is basically an array the functionality of
XML::LibXML::NodeList::Iterator is more restircted to stepwise
foreward and backward than XML::LibXML::Iterator is.
=head1 METHODS
=over 4
=item * accept_node
=item * add_filter
=item * current
=item * first
=item * index
=item * iterate
=item * last
=item * new
=item * next
=item * nextNode
=item * previous
=item * previousNode
=item * set_filter
=back
=head1 SEE ALSO
L, L, L
=head1 AUTHOR
Christian Glahn, Ephish@cpan.orgE
=head1 COPYRIGHT
(c) 2002-2007, Christian Glahn. All rights reserved.
This package is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
=head1 SUPPORT
=head2 Websites
The following websites have more information about this module, and may be of help to you. As always,
in addition to those websites please use your favorite search engine to discover more resources.
=over 4
=item *
MetaCPAN
A modern, open-source CPAN search engine, useful to view POD in HTML format.
L
=item *
RT: CPAN's Bug Tracker
The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
L
=item *
CPANTS
The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
L
=item *
CPAN Testers
The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
L
=item *
CPAN Testers Matrix
The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
L
=item *
CPAN Testers Dependencies
The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
L
=back
=head2 Bugs / Feature Requests
Please report any bugs or feature requests by email to C, or through
the web interface at L. You will be automatically notified of any
progress on the request by the system.
=head2 Source Code
The code is open to the world, and available for you to hack on. Please feel free to browse it and play
with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
from your repository :)
L
git clone git://github.com/shlomif/xml-libxml-iterator.git
=head1 AUTHOR
unknown
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website
L
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2020 by unknown.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut