Changeset 7869e48 for perl/modules/Jabber/lib/XML/Stream
- Timestamp:
- Jan 12, 2013, 1:43:13 PM (12 years ago)
- Children:
- e3a0d71, 4485285
- Parents:
- 4626016
- git-author:
- Jason Gross <jgross@mit.edu> (01/12/13 13:13:18)
- git-committer:
- Jason Gross <jgross@mit.edu> (01/12/13 13:43:13)
- Location:
- perl/modules/Jabber/lib/XML/Stream
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/Jabber/lib/XML/Stream/Namespace.pm
rc2bed55 r7869e48 25 25 =head1 NAME 26 26 27 XML::Stream::Namespace - Object to make defining Namespaces easier in 27 XML::Stream::Namespace - Object to make defining Namespaces easier in 28 28 XML::Stream. 29 29 … … 49 49 GetAttributes() returns a hash ( attrib1=>"value1",attrib2=>"value2") 50 50 GetStream() returns the following string: 51 "xmlns:mynamespace='http://www.nynamespace.com/xmlns' 52 mynamespace:attrib1='value1' 51 "xmlns:mynamespace='http://www.nynamespace.com/xmlns' 52 mynamespace:attrib1='value1' 53 53 mynamespace:attrib2='value2'" 54 54 … … 71 71 # of the stream to foo.bar.org:1234... 72 72 # 73 # <stream:stream 73 # <stream:stream 74 74 # xmlns:stream="http://etherx.jabber.org/streams" 75 75 # to="foo.bar.org" 76 # xmlns="foo:bar" 76 # xmlns="foo:bar" 77 77 # xmlns:mynamespace="http://www.mynamespace.org/xmlns" 78 78 # mynamespace:foo="bar" 79 79 # mynamespace:bob="vila"> 80 80 # 81 81 82 82 83 83 =head1 AUTHOR … … 183 183 $string .= "='".$self->GetAttributes($attrib)."'"; 184 184 } 185 185 186 186 return $string; 187 187 } -
perl/modules/Jabber/lib/XML/Stream/Node.pm
rc2bed55 r7869e48 85 85 86 86 remove_child(node) - removes the child node from the current node. 87 87 88 88 remove_cdata() - removes all of the cdata children from the current node. 89 89 … … 120 120 121 121 XPath(path) - run XML::Stream::XPath on this node. 122 122 123 123 XPathCheck(path) - run XML::Stream::XPath on this node and return 1 or 0 124 124 to see if it matches or not. … … 266 266 267 267 return $cdata; 268 } 268 } 269 269 270 270 … … 286 286 splice(@{$self->{CHILDREN}},$index,1); 287 287 } 288 } 288 } 289 289 290 290 … … 294 294 return () unless exists($self->{ATTRIBS}); 295 295 return %{$self->{ATTRIBS}}; 296 } 296 } 297 297 298 298 … … 308 308 309 309 sub put_attrib 310 { 310 { 311 311 my $self = shift; 312 312 my (%att) = @_; … … 366 366 my ($tag) = @_; 367 367 368 $self->{TAG} = $tag; 368 $self->{TAG} = $tag; 369 369 } 370 370 … … 513 513 514 514 $self->debug(2,"Node: _handle_close: check2(",$#{$self->{SIDS}->{$sid}->{node}},")"); 515 515 516 516 if($#{$self->{SIDS}->{$sid}->{node}} == -1) 517 517 { … … 521 521 { 522 522 my $stream_prefix = $self->StreamPrefix($sid); 523 523 524 524 if(defined($self->{SIDS}->{$sid}->{node}->[0]) && 525 525 ($self->{SIDS}->{$sid}->{node}->[0]->get_tag() =~ /^${stream_prefix}\:/)) … … 542 542 { 543 543 my $xmlns = $node->get_attrib("xmlns"); 544 544 545 545 $self->ProcessSASLPacket($sid,$node) 546 546 if ($xmlns eq &XML::Stream::ConstXMLNS("xmpp-sasl")); -
perl/modules/Jabber/lib/XML/Stream/Parser.pm
rc2bed55 r7869e48 324 324 $self->{CNAME}->[$self->{CURR}] = $name; 325 325 } 326 326 327 327 $self->{XML} = substr($self->{XML},$close+1,length($self->{XML})-$close-1); 328 328 next; … … 337 337 return $self->returnData(0); 338 338 } 339 339 340 340 &{$self->{HANDLER}->{characters}}($self,substr($self->{XML},9,$cdataclose-9)); 341 341 342 342 $self->{XML} = substr($self->{XML},$cdataclose+3,length($self->{XML})-$cdataclose-3); 343 343 next; … … 510 510 return unless ($self->{DOC} == 1); 511 511 512 if ($self->{STYLE} eq "debug") 512 if ($self->{STYLE} eq "debug") 513 513 { 514 514 my $str = $cdata; … … 530 530 push @{$self->{TREE}[$#{$self->{TREE}}]}, 0; 531 531 push @{$self->{TREE}[$#{$self->{TREE}}]}, $cdata; 532 } 532 } 533 533 } 534 534 } -
perl/modules/Jabber/lib/XML/Stream/Tree.pm
rc2bed55 r7869e48 142 142 push @{$self->{SIDS}->{$sid}->{tree}[$#{$self->{SIDS}->{$sid}->{tree}}]}, 0; 143 143 push @{$self->{SIDS}->{$sid}->{tree}[$#{$self->{SIDS}->{$sid}->{tree}}]}, $cdata; 144 } 144 } 145 145 } 146 146 … … 187 187 if(defined($self->{SIDS}->{$sid}->{tree}->[0]) && 188 188 ($self->{SIDS}->{$sid}->{tree}->[0] =~ /^${stream_prefix}\:/)) 189 { 189 { 190 190 my @tree = @{$self->{SIDS}->{$sid}->{tree}}; 191 191 $self->{SIDS}->{$sid}->{tree} = []; … … 196 196 my @tree = @{$self->{SIDS}->{$sid}->{tree}}; 197 197 $self->{SIDS}->{$sid}->{tree} = []; 198 198 199 199 my @special = 200 200 &XML::Stream::XPath( … … 384 384 return 1; 385 385 } 386 386 387 387 #--------------------------------------------------------------------- 388 388 # Return the raw CDATA value without mark ups, or the value of the … … 592 592 593 593 my $str = ""; 594 if (ref($parseTree->[0]) eq "") 594 if (ref($parseTree->[0]) eq "") 595 595 { 596 596 if ($parseTree->[0] eq "0") … … 608 608 { 609 609 $str .= ">"; 610 610 611 611 my $index = 1; 612 612 while($index <= $#{$parseTree->[1]}) … … 616 616 $index += 2; 617 617 } 618 618 619 619 $str .= $rawXML if defined($rawXML); 620 620 $str .= "</".$parseTree->[0].">"; -
perl/modules/Jabber/lib/XML/Stream/XPath/Op.pm
rc2bed55 r7869e48 50 50 $self->{TYPE} = shift; 51 51 $self->{VALUE} = shift; 52 52 53 53 return $self; 54 54 } … … 165 165 { 166 166 push(@valid_elems,$elem); 167 } 168 } 169 170 $$ctxt->setList(@valid_elems); 171 167 } 168 } 169 170 $$ctxt->setList(@valid_elems); 171 172 172 if ($#valid_elems == -1) 173 173 { … … 224 224 225 225 my @valid_elems; 226 226 227 227 foreach my $elem (@elems) 228 228 { 229 229 push(@valid_elems,$self->descend($elem)); 230 230 } 231 231 232 232 $$ctxt->setList(@valid_elems); 233 233 … … 247 247 248 248 my @valid_elems; 249 249 250 250 if (($self->{VALUE} eq "*") || (&XML::Stream::GetXMLData("tag",$elem) eq $self->{VALUE})) 251 251 { 252 252 push(@valid_elems,$elem); 253 253 } 254 254 255 255 foreach my $child (&XML::Stream::GetXMLData("child array",$elem,"*")) 256 256 { 257 257 push(@valid_elems,$self->descend($child)); 258 258 } 259 259 260 260 return @valid_elems; 261 261 } … … 326 326 } 327 327 } 328 328 329 329 $$ctxt->setList(@valid_elems); 330 330 … … 343 343 my $elem = shift; 344 344 return &XML::Stream::GetXMLData("value",$elem); 345 } 345 } 346 346 347 347 … … 374 374 $tmp_ctxt->setList($$ctxt->getList()); 375 375 $tmp_ctxt->in_context(0); 376 376 377 377 if (!$self->{OP_L}->isValid(\$tmp_ctxt) || !$self->{OP_R}->isValid(\$tmp_ctxt)) 378 378 { … … 393 393 @valid_elems = $$ctxt->getList(); 394 394 } 395 395 396 396 $$ctxt->setList(@valid_elems); 397 397 … … 414 414 print $space," op_l: "; 415 415 $self->{OP_L}->display($space." "); 416 416 417 417 print $space," op_r: "; 418 418 $self->{OP_R}->display($space." "); … … 449 449 $tmp_ctxt->setList($$ctxt->getList()); 450 450 $tmp_ctxt->in_context(0); 451 451 452 452 if (!$self->{OP_L}->isValid(\$tmp_ctxt) || !$self->{OP_R}->isValid(\$tmp_ctxt)) 453 453 { … … 468 468 @valid_elems = $$ctxt->getList(); 469 469 } 470 470 471 471 $$ctxt->setList(@valid_elems); 472 472 … … 489 489 print $space," op_l: "; 490 490 $self->{OP_L}->display($space." "); 491 491 492 492 print $space," op_r: "; 493 493 $self->{OP_R}->display($space." "); … … 524 524 my @values; 525 525 my %attribs; 526 526 527 527 foreach my $elem (@elems) 528 528 { … … 558 558 return; 559 559 } 560 560 561 561 return 1; 562 562 } … … 607 607 my $opl = $self->{OP_L}->isValid($ctxt); 608 608 my $opr = $self->{OP_R}->isValid($ctxt); 609 609 610 610 if ($opl && $opr) 611 611 { … … 628 628 print $space," op_l: \n"; 629 629 $self->{OP_L}->display($space." "); 630 630 631 631 print $space," op_r: \n"; 632 632 $self->{OP_R}->display($space." "); … … 672 672 my $opl = $self->{OP_L}->isValid(\$tmp_ctxt_l); 673 673 my $opr = $self->{OP_R}->isValid(\$tmp_ctxt_r); 674 674 675 675 if ($opl || $opr) 676 676 { 677 677 push(@valid_elems,$elem); 678 } 679 } 680 681 $$ctxt->setList(@valid_elems); 682 678 } 679 } 680 681 $$ctxt->setList(@valid_elems); 682 683 683 if ($#valid_elems == -1) 684 684 { … … 699 699 print "$space op_l: "; 700 700 $self->{OP_L}->display("$space "); 701 701 702 702 print "$space op_r: "; 703 703 $self->{OP_R}->display("$space "); … … 750 750 my $self = shift; 751 751 my $elem = shift; 752 752 753 753 my $result; 754 754 eval("\$result = &{\$XML::Stream::XPath::VALUES{\$self->{VALUE}}}(\$elem);"); … … 790 790 push(@valid_elems,$elem); 791 791 push(@valid_values,$text); 792 } 792 } 793 793 } 794 794 795 795 $$ctxt->setList(@valid_elems); 796 796 $$ctxt->setValues(@valid_values); 797 797 798 798 if ($#valid_elems == -1) 799 799 { … … 819 819 { 820 820 push(@valid_elems,$elem); 821 } 822 } 823 824 $$ctxt->setList(@valid_elems); 825 821 } 822 } 823 824 $$ctxt->setList(@valid_elems); 825 826 826 if ($#valid_elems == -1) 827 827 { … … 848 848 push(@valid_elems,$elem); 849 849 push(@valid_values,$text); 850 } 850 } 851 851 } 852 852 853 853 $$ctxt->setList(@valid_elems); 854 854 $$ctxt->setValues(@valid_values); 855 855 856 856 if ($#valid_elems == -1) 857 857 { … … 878 878 { 879 879 push(@valid_elems,$elem); 880 } 881 } 882 883 $$ctxt->setList(@valid_elems); 884 880 } 881 } 882 883 $$ctxt->setList(@valid_elems); 884 885 885 if ($#valid_elems == -1) 886 886 { -
perl/modules/Jabber/lib/XML/Stream/XPath/Query.pm
rc2bed55 r7869e48 37 37 bless($self,$proto); 38 38 39 $self->{TOKENS} = [ '/','[',']','@','"',"'",'=','!','(',')',':',' ',',']; 39 $self->{TOKENS} = [ '/','[',']','@','"',"'",'=','!','(',')',':',' ',',']; 40 40 $self->{QUERY} = shift; 41 41 42 42 if (!defined($self->{QUERY}) || ($self->{QUERY} eq "")) 43 43 { 44 44 confess("No query string specified"); 45 45 } 46 46 47 47 $self->parseQuery(); 48 48 49 49 return $self; 50 50 } … … 52 52 53 53 sub getNextToken 54 { 54 { 55 55 my $self = shift; 56 56 my $pos = shift; … … 104 104 my $token_start = ++$$pos; 105 105 my $ident; 106 106 107 107 if (defined($token)) 108 108 { … … 193 193 return; 194 194 } 195 195 196 196 $$pos = $token_start; 197 197 my $val = $self->getNextIdentifier($pos); … … 234 234 235 235 $self->getOp($pos,$token); 236 236 237 237 foreach my $arg ($op_pos..$#{$self->{OPS}}) 238 238 { … … 241 241 242 242 splice(@{$self->{OPS}},$op_pos); 243 243 244 244 } 245 245 elsif ($token eq ")") … … 261 261 confess("Found ',' but not in a function"); 262 262 } 263 263 264 264 } 265 265 elsif ($token eq "=") … … 280 280 } 281 281 $$pos++; 282 282 283 283 my $tmp_op; 284 284 while(!defined($tmp_op)) … … 307 307 confess("Token undefined"); 308 308 } 309 309 310 310 $loop = 0 unless $in_context; 311 311 } -
perl/modules/Jabber/lib/XML/Stream/XPath/Value.pm
rc2bed55 r7869e48 96 96 97 97 sub getAttribs 98 { 98 { 99 99 my $self = shift; 100 100 return unless (scalar(keys(%{$self->{ATTRIBS}})) > 0);
Note: See TracChangeset
for help on using the changeset viewer.