CFDI
view release on metacpan or search on metacpan
lib/CFDI/Location/XPath.pm view on Meta::CPAN
our $VERSION = 0.4;
sub new{
my $invocant = shift;
my $class = ref $invocant || $invocant;
my $content = shift;
return unless defined $content && ref $content eq CONTENT;
bless {_current=>'/',_rootRef=>$content,_currentRef=>$content},$class;
}
sub xpath($_){
return unless $#_ == 1;
local $_;
my $self;
$_[0] && ref $_[0] ? ($self,$_) : ($_,$self) = @_;
return unless defined && !ref && length;
return unless defined $self && $self->isa(__PACKAGE__);
my $abs = ord '/' eq ord;
substr $_,0,1,'' if $abs;
my @path = m!([^/]+)!g;
my $xpath;
lib/CFDI/Macros/Excel.pm view on Meta::CPAN
use CFDI::Location::XPath;
use CFDI::Report::Default;
use CFDI::Output::CSV;
require Exporter;
our @EXPORT = qw(xcel xcel2 xcel3 xcel4 xcel5 excel excel2 excel3 excel4 excel5);
our @ISA = qw(Exporter);
our $VERSION = 0.21;
sub reporte(_){
return unless my @xml = findxml $_[0];
push @xpathheader,'xml';
my $reporte = [\@xpathheader];
foreach my $xml (@xml){
my $content = eval{parse $xml};
warn("$xml: $@"),next if $@;
my $xpath = CFDI::Location::XPath->new($content);
my @reg = map{xpath$xpath}@xpathdata;
next unless @reg;
push @reg,$xml;
lib/CFDI/Output/CSV.pm view on Meta::CPAN
package CFDI::Output::CSV;
use strict;
require Exporter;
our @EXPORT = qw(output);
our @ISA = qw(Exporter);
our $VERSION = 0.2;
sub output(_){
local $_ = shift;
return unless defined && ref eq 'ARRAY';
join$/,map{join',',map{defined$_?'"'.$_.'"':'""'}@$_}@$_;
}
1;
lib/CFDI/Parser/Path.pm view on Meta::CPAN
package CFDI::Parser::Path;
use strict;
use File::Spec;
use Cwd;
require Exporter;
our @EXPORT = qw(findxml);
our @ISA = qw(Exporter);
our $VERSION = 0.3;
sub findxml(_){
die 'path not defined' unless defined $_[0];
die "cannot read path $_[0]" unless -e $_[0] && -r _;
die "path $_[0] is not a directory" unless -d _;
my ($wd,@paths,@xml) = (getcwd,$_[0]);
while(@paths){
my $path = shift @paths;
next unless -e $path && -r _ && -d _;
opendir DIR,$path or next;
chdir $path or next;
foreach(grep !/^\./,readdir DIR){
lib/CFDI/Parser/XML.pm view on Meta::CPAN
our $VERSION = 0.85;
our $BUFLEN = 256;
=todo
namespaces...
<?proc some="calue"?> #processing instructions
#entities() < & & " &#something;
$attr{'xml:space'} eq 'default'){ #remove space
=cut
sub parse(_){
my $file = shift;
die "file required$/" unless defined $file;
local $_ = '';
die "cannot access file $file$/" unless -e $file && -r _;
open(XML,'<:encoding(UTF-8)',$file) or die "cannot open file $file as UTF-8: $!$/";
my ($t,$squote,$dquote,$cmntOpen,$char,$buf,@tokns,$dec,$hasTags) = (0,0,0,0);
local $SIG{__DIE__} = sub {close XML or warn "cannot close file $file: $!$/"};
my ($chars,$buffer,$BOM);
die "file required$/" unless defined $file;
die "cannot access file $file$/" unless -e $file && -r _;
( run in 0.286 second using v1.01-cache-2.11-cpan-65fba6d93b7 )