DBIx-XML-DataLoader

 view release on metacpan or  search on metacpan

DataLoader/MapIt.pm  view on Meta::CPAN

push @mapclasses, $rootelement;
push @mapclasses, $all_tables;
push @mapclasses, \@tables;
push @mapclasses, $doc_key;

my $temp="/tmp";

=pod
## just messing around here  disreguard for now
if($filename !~ /\</){
my @fname=split m[/], $filename;
my $file=pop @fname;
my $temp="/tmp/".$file.".map";
open(TMP, ">$temp")||die "could not open temp $temp $@";
use Data::Dumper;
#$Data::Dumper::Purity=1;
#$Data::Dumper::Terse =1;
print TMP Data::Dumper->Dump(\@mapclasses);
}
=cut

DataLoader/XMLWriter.pm  view on Meta::CPAN

my $tableroot=$all_data{$keys}->{node};
my %table_doc;
INFO: for my $info (@info){
my $value=$info->{val};
### here we set any values that have xpaths starting from the document root
## this seems to work
if($info->{xpath} =~ m[^/]){
## do root doc stuff here
my $xpath=$info->{xpath};
$xpath =~ s[^/+][];
my @path=split m[/], $xpath;
my $the_root=shift @path;
my $path_cnt=scalar @path;
#my $value=$info->{val};
	if($path_cnt==1){
	if(!$doc{$the_root}[$rootcnt]->{$path[$path_cnt-1]}[0]){
	$doc{$the_root}[$rootcnt]->{$path[$path_cnt-1]}[0]=$value;
	next INFO;}
	 if($doc{$the_root}[$rootcnt]->{$path[$path_cnt-1]}[0]){
        if($doc{$the_root}[$rootcnt]->{$path[$path_cnt-1]}[0] ne $value){
	$rootcnt++;

DataLoader/XMLWriter.pm  view on Meta::CPAN

## here we check to see if this table has a parent in the xml output document
my $xpath=$info->{xpath};
if(($xpath =~ /^parent/i)or($xpath =~ m[^\.\./])){
$table_pass{parent}->{$lpcnt}->{value}=$value;
$table_pass{parent}->{$lpcnt}->{xpath}=$info->{xpath};
$table_pass{parent}->{$lpcnt}->{attribute}=$info->{attribute};
$table_pass{parent}->{hasone}="yes";
next INFO;
}
$info->{xpath} =~ s[^\./][];
my @current_xpath=split m[/], $info->{xpath};
my $path_cnt=scalar  @current_xpath;
if($table_node ne $doc_root){
#######################################################
if($path_cnt == 1){
if($table_node ne $info->{item_node}){
if($info->{attribute}){
$table_doc{$current_xpath[0]}[0]->{$info->{attribute}}=$value;
next INFO;
} # end if
if(!$info->{attribute}){

DataLoader/XMLWriter.pm  view on Meta::CPAN

################################################

} # end if $table_node eq doc_root

}  ## end INFO loop
############ here we start to rconstruct the rest of our doc;
if(!%table_doc){next LOOPCNT;}
my $table_data=\%table_doc;

if($table_pass{parent}->{hasone} eq "no"){ 
my @path=split m[/], $table_xpath;
my $path_cnt=scalar @path;
# we have no parent so lets just add the table our doc hash
my $depth=0;

if($path_cnt == 1){

if($doc{$the_root}[$rootcnt]->{$table_node}){$depth=scalar @{$doc{$the_root}[$rootcnt]->{$table_node}};}

$doc{$doc_root}[$rootcnt]->{$table_node}[$depth]=$table_data;
next LOOPCNT;

DataLoader/XMLWriter.pm  view on Meta::CPAN

if($table_pass{parent}->{hasone} eq "yes"){

my $xpath=$table_pass{parent}->{$lpcnt}->{xpath};
my $value=$table_pass{parent}->{$lpcnt}->{value};
my $node_type="content";
if($table_pass{parent}->{$lpcnt}->{attribute}){
$node_type=$table_pass{parent}->{$lpcnt}->{attribute};
}


my @xpath_array=split m[/], $xpath;
my $xpath_node=pop @xpath_array;
my $parent_node=unshift @xpath_array;
$parent_node=~s/parent:://;

# here we check to see if this is a attribute or element content
my $element;
my $attribute;

if($xpath_node !~ /\@/){$element=$xpath_node;}
if($xpath_node =~ /\@/){$attribute=$xpath_node;$attribute =~ s/\@//;}

my @path=split m[/], $table_xpath;
my $table_node=pop @path;
my $path_cnt=scalar @path;

my $p_node_location_cnt;
PNODE: for my $pnode (@path){
$p_node_location_cnt++;
if($pnode eq $parent_node){last PNODE;}
}

if($path_cnt==1){

examples/query_db.pl  view on Meta::CPAN

	if($doc_key_value){$doc_key_hash{$doc_key}=$doc_key_value;}
} 

TABLE: foreach my $tab (@tables){
	my $table=$tab;
	my $table_stuff=pop @{$table_info{$tab}};
	my $table_xpath=$table_stuff->{xpath};
	my $table_child=$table_stuff->{child};
	my $table_parent=$table_stuff->{parent};
	my $table_dbh=$table_stuff->{dbname};
	my @table_path=split m[/], $table_xpath;
	my $table_node=pop @table_path;
	$all_data{$table}->{child}=$table_child;
	$all_data{$table}->{parent}=$table_parent;
	$all_data{$table}->{xpath}= $table_xpath;
	$all_data{$table}->{node}=$table_node;
	$all_data{$table}->{dbname}=$table_dbh;
	my $dbh=$db_connections->{$table_stuff->{dbname}};
	my @where;
	## here we get our keys for the db query we will need
	my @tabkeys_array=@{$table_stuff->{'keys'}};

examples/query_db.pl  view on Meta::CPAN

				my $xpath;
				my $date;
				TEST_NODE: for my $test_node (@{$table_info{$tab}}){
					if($test_node->{col} =~ /^$key$/i){
						$xpath=$test_node->{xpath};
						$date=$test_node->{date};
						last TEST_NODE;
					}

				}
				my @item_xpath=split m[/], $xpath;
				my $item_node=pop @item_xpath;
				my $attr;
				if($item_node =~ /\@/){$item_node =~s/\@//;
					$attr=$item_node;
					if($xpath !~ /^parent::/){
						$item_node = pop @item_xpath;
						if((!$item_node) or ($item_node=".")){
							$item_node=$table_node;
						}
					}



( run in 1.455 second using v1.01-cache-2.11-cpan-71847e10f99 )