[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Tue Sep 1 16:27:05 UTC 2009
kawas
Tue Sep 1 12:27:04 EDT 2009
Update of /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY
In directory dev.open-bio.org:/tmp/cvs-serv16387/MOBY-Server/lib/MOBY
Modified Files:
CommonSubs.pm
Log Message:
removed the hard coded references to moby: (namespace prefix) in all places that i found it to be hard coded. Instead, i look for any prefix. Moreover, I removed all references to $element->nodeName and replaced them with references to $element->localname so that we can check the element name without worrying about the xml namespace prefix.
CommonSubs.t seems to run completely normal after making these changes (all tests pass).
moby-live/Perl/MOBY-Server/lib/MOBY CommonSubs.pm,1.7,1.8
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/CommonSubs.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/CommonSubs.pm 2009/04/15 17:45:23 1.7
+++ /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/CommonSubs.pm 2009/09/01 16:27:04 1.8
@@ -413,19 +413,19 @@
$moby = _string_to_DOM($moby);
return undef unless $moby->nodeType == ELEMENT_NODE;
return undef
- unless ($moby->nodeName =~ /^(moby:|)mobyData$/);
+ unless ($moby->localname =~ /^(.*:|)mobyData$/);
my @articles;
foreach my $child ( $moby->childNodes )
{ # there may be more than one Simple/Collection per input; iterate over them
next unless $child->nodeType == ELEMENT_NODE; # ignore whitespace
next
- unless ( $child->nodeName =~ /^(moby:|)(Simple|Collection|Parameter)$/ );
+ unless ( $child->localname =~ /^(.*:|)(Simple|Collection|Parameter)$/ );
my $object;
- if ( $child->nodeName =~ /^(moby:|)Simple$/ ) {
+ if ( $child->localname=~ /^(.*:|)Simple$/ ) {
$object = MOBY::Client::SimpleArticle->new( XML_DOM => $child );
- } elsif ( $child->nodeName =~ /^(moby:|)Collection$/ ) {
+ } elsif ( $child->localname=~ /^(.*:|)Collection$/ ) {
$object = MOBY::Client::CollectionArticle->new( XML_DOM => $child );
- } elsif ( $child->nodeName =~ /^(moby:|)Parameter$/ ) {
+ } elsif ( $child->localname =~ /^(.*:|)Parameter$/ ) {
$object = MOBY::Client::SecondaryArticle->new( XML_DOM => $child );
}
next unless $object;
@@ -438,7 +438,7 @@
sub _getQID {
my ( $XML ) = @_;
my $moby = _string_to_DOM($XML);
- return '' unless ( $moby->nodeName =~ /^(moby:|)mobyData$/ );
+ return '' unless ( $moby->localname =~ /^(.*:|)mobyData$/ );
my $qid = _moby_getAttribute($moby, 'queryID' );
$qid ||= _moby_getAttribute($moby, 'moby:queryID' );
return defined( $qid ) ? $qid : '';
@@ -480,7 +480,7 @@
eval { $DOM = _string_to_DOM($DOM) };
return 0 if $@;
$DOM = $DOM->getDocumentElement if ( $DOM->isa( "XML::LibXML::Document" ) );
- return ($DOM->nodeName =~ /^(moby:|)Simple$/) ? 1 : 0; #Optional 'moby:' namespace prefix
+ return ($DOM->localname =~ /^(.*:|)Simple$/) ? 1 : 0; #Optional 'moby:' namespace prefix
}
sub isCollectionArticle {
@@ -488,7 +488,7 @@
eval {$DOM = _string_to_DOM($DOM) };
return 0 if $@;
$DOM = $DOM->getDocumentElement if ( $DOM->isa( "XML::LibXML::Document" ) );
- return ( $DOM->nodeName =~ /^(moby\:|)Collection$/ ) ? 1 : 0; #Optional 'moby:' prefix
+ return ( $DOM->localname =~ /^(.*:|)Collection$/ ) ? 1 : 0; #Optional 'moby:' prefix
}
sub isSecondaryArticle {
@@ -497,7 +497,7 @@
eval {$DOM = _string_to_DOM($XML)} ;
return 0 if $@;
$DOM = $DOM->getDocumentElement if ( $DOM->isa( "XML::LibXML::Document" ) );
- return ($DOM->nodeName =~ /^(moby\:|)Parameter$/) ? 1 : 0; #Optional 'moby:' prefix
+ return ($DOM->localname =~ /^(.*:|)Parameter$/) ? 1 : 0; #Optional 'moby:' prefix
}
@@ -961,8 +961,8 @@
$XML = _string_to_DOM($XML);
my @xrefs;
my @XREFS;
- return () if ( $XML->nodeName =~ /^(moby:|)Collection$/ );
- if ( $XML->nodeName =~ /^(moby:|)Simple$/ ) {
+ return () if ( $XML->localname =~ /^(.*:|)Collection$/ );
+ if ( $XML->localname =~ /^(.*:|)Simple$/ ) {
foreach my $child ( $XML->childNodes ) {
next unless $child->nodeType == ELEMENT_NODE;
$XML = $child;
@@ -971,17 +971,17 @@
}
foreach ( $XML->childNodes ) {
next unless (($_->nodeType == ELEMENT_NODE)
- || ($_->nodeName =~ /^(moby:|)CrossReference$/) );
+ || ($_->localname && $_->localname =~ /^(.*:|)CrossReference$/) );
foreach my $xref ( $_->childNodes ) {
- next unless ( ($xref->nodeType == ELEMENT_NODE)
- || ($xref->nodeName =~ /^(moby:|)(Xref|Object)$/) );
+ next unless $xref && ( ($xref->nodeType == ELEMENT_NODE)
+ || ($xref->localname && $xref->localname =~ /^(.*:|)(Xref|Object)$/) );
push @xrefs, $xref;
}
}
foreach ( @xrefs ) {
my $x;
- if ($_->nodeName =~ /^(moby:|)Xref$/) { $x = _makeXrefType( $_ ) }
- elsif ($_->nodeName =~ /^(moby:|)Object$/) { $x = _makeObjectType( $_ ) }
+ if ($_->localname =~ /^(.*:|)Xref$/) { $x = _makeXrefType( $_ ) }
+ elsif ($_->localname =~ /^(.*:|)Object$/) { $x = _makeObjectType( $_ ) }
push @XREFS, $x if $x;
}
return @XREFS;
@@ -1338,7 +1338,7 @@
sub _getQueryID {
my ( $query ) = @_;
$query = _string_to_XML($query);
- return '' unless ( $query->nodeName =~ /^(moby:|)mobyData$/ ); #Eddie - unsure
+ return '' unless ( $query->localname =~ /^(.*:|)mobyData$/ ); #Eddie - unsure
return _moby_getAttribute($query, 'queryID' );
}
@@ -1392,19 +1392,19 @@
my $resp = $responses->get_node( $n );
foreach my $response_component ( $resp->childNodes ) {
next unless $response_component->nodeType == ELEMENT_NODE;
- if ( $response_component->nodeName =~ /^(moby:|)Simple$/ )
+ if ( $response_component->localname =~ /^(.*:|)Simple$/ )
{
foreach my $Object ( $response_component->childNodes ) {
next unless $Object->nodeType == ELEMENT_NODE;
$success = 1;
push @objects, $Object;
}
- } elsif ( $response_component->nodeName =~ /^(moby:|)Collection$/ )
+ } elsif ( $response_component->localname =~ /^(.*:|)Collection$/ )
{
my @objects;
foreach my $simple ( $response_component->childNodes ) {
next unless $simple->nodeType == ELEMENT_NODE;
- next unless ( $simple->nodeName =~ /^(moby:|)Simple$/ );
+ next unless ( $simple->localname =~ /^(.*:|)Simple$/ );
foreach my $Object ( $simple->childNodes ) {
next unless $Object->nodeType == ELEMENT_NODE;
$success = 1;
@@ -1498,12 +1498,12 @@
$moby = _string_to_DOM($moby);
return undef
unless ( ($moby->nodeType == ELEMENT_NODE)
- && ( $moby->nodeName =~ /^(moby:|)(queryInput|queryResponse|mobyData)$/ ) );
+ && ( $moby->localname =~ /^(.*:|)(queryInput|queryResponse|mobyData)$/ ) );
my @articles;
foreach my $child ( $moby->childNodes )
{ # there may be more than one Simple/Collection per input; iterate over them
next unless ( ($child->nodeType == ELEMENT_NODE) # ignore whitespace
- && ( $child->nodeName =~ /^(moby:|)(Simple|Collection|Parameter)$/ ) );
+ && ( $child->localname =~ /^(.*:|)(Simple|Collection|Parameter)$/ ) );
my $articleName = _moby_getAttribute($child, 'articleName' );
# push the named child DOM elements (which are <Simple> or <Collection>, <Parameter>)
push @articles, [ $articleName, $child ];
@@ -1548,7 +1548,7 @@
foreach my $in ( @input_nodes ) {
next unless $in;
#$in = "<Simple><Object namespace='' id=''/></Simple>"
- next unless $in->nodeName =~ /^(moby:|)Simple$/; # only allow simples
+ next unless $in->localname =~ /^(.*)Simple$/; # only allow simples
my @simples = $in->childNodes;
foreach ( @simples ) { # $_ = <Object namespace='' id=''/>
next unless $_->nodeType == ELEMENT_NODE;
@@ -1647,7 +1647,7 @@
print STDERR "getInputID method is now deprecated. Please use serviceInputParser or serviceResponseParser\n";
my ( $XML ) = @_;
my $moby = _string_to_DOM($XML);
- return '' unless ( $moby->nodeName =~ /^(moby:|)queryInput|mobyData$/ );
+ return '' unless ( $moby->localname =~ /^(.*:|)queryInput|mobyData$/ );
my $qid = _moby_getAttribute($moby, 'queryID' );
$qid ||= _moby_getAttribute($moby, 'moby:queryID' );
return defined( $qid ) ? $qid : '';
@@ -1665,19 +1665,19 @@
$moby = _string_to_DOM($moby);
return undef unless $moby->nodeType == ELEMENT_NODE;
return undef
- unless ($moby->nodeName =~ /^(moby:|)(queryInput|queryResponse|mobyData)$/);
+ unless ($moby->localname =~ /^(.*:|)(queryInput|queryResponse|mobyData)$/);
my @articles;
foreach my $child ( $moby->childNodes )
{ # there may be more than one Simple/Collection per input; iterate over them
next unless $child->nodeType == ELEMENT_NODE; # ignore whitespace
next
- unless ( $child->nodeName =~ /^(moby:|)(Simple|Collection|Parameter)$/ );
+ unless ( $child->localname =~ /^(.*:|)(Simple|Collection|Parameter)$/ );
my $object;
- if ( $child->nodeName =~ /^(moby:|)Simple$/ ) {
+ if ( $child->localname =~ /^(.*:|)Simple$/ ) {
$object = MOBY::Client::SimpleArticle->new( XML_DOM => $child );
- } elsif ( $child->nodeName =~ /^(moby:|)Collection$/ ) {
+ } elsif ( $child->localname =~ /^(.*:|)Collection$/ ) {
$object = MOBY::Client::CollectionArticle->new( XML_DOM => $child );
- } elsif ( $child->nodeName =~ /^(moby:|)Parameter$/ ) {
+ } elsif ( $child->localname =~ /^(.*:|)Parameter$/ ) {
$object = MOBY::Client::SecondaryArticle->new( XML_DOM => $child );
}
next unless $object;
@@ -1697,12 +1697,12 @@
my ( $moby ) = @_;
$moby = _string_to_DOM($moby);
return undef unless $moby->nodeType == ELEMENT_NODE;
- return undef unless ( $moby->nodeName =~ /^(moby\:|)Collection$/ );
+ return undef unless ( $moby->localname =~ /^(.*:|)Collection$/ );
my @articles;
foreach my $child ( $moby->childNodes )
{ # there may be more than one Simple/Collection per input; iterate over them
next unless $child->nodeType == ELEMENT_NODE; # ignore whitespace
- next unless ( $child->nodeName =~ /^(moby\:|)Simple$/ );
+ next unless ( $child->localname =~ /^(.*:|)Simple$/ );
push @articles, $child; # take the child elements, which are <Simple/> or <Collection/>
}
return @articles; # return them.
@@ -1791,19 +1791,19 @@
my $resp = $responses->get_node( $n );
foreach my $response_component ( $resp->childNodes ) {
next unless $response_component->nodeType == ELEMENT_NODE;
- if ( $response_component->nodeName =~ /^(moby:|)Simple$/ )
+ if ( $response_component->localname =~ /^(.*:|)Simple$/ )
{
foreach my $Object ( $response_component->childNodes ) {
next unless $Object->nodeType == ELEMENT_NODE;
$success = 1;
push @objects, $Object;
}
- } elsif ( $response_component->nodeName =~ /^(moby:|)Collection$/ )
+ } elsif ( $response_component->localname =~ /^(.*:|)Collection$/ )
{
my @objects;
foreach my $simple ( $response_component->childNodes ) {
next unless $simple->nodeType == ELEMENT_NODE;
- next unless ( $simple->nodeName =~ /^(moby:|)Simple$/ );
+ next unless ( $simple->localname =~ /^(.*:|)Simple$/ );
foreach my $Object ( $simple->childNodes ) {
next unless $Object->nodeType == ELEMENT_NODE;
$success = 1;
More information about the MOBY-guts
mailing list