[MOBY] Re: [MOBY-l] XML namespaces

Mark Wilkinson markw at illuminae.com
Sat Oct 25 09:26:55 EDT 2003


Ken, 

This is the code to parse the XML that you sent.  As I said, it uses
CommonSubs to do the parsing for you, **without** you having to worry
about the moby: namespace.  The one aspect that it doesn't look after
right now is CrossReferences, but I will write that subroutine today.

I have some concerns about your XML, though... you have a
Cross-reference block associated with a contained (HASA) String object. 
Although this is absolutely fine and legal, I would have expected that
block to be associated with the primary tag of the Object, not a
contained tag... did you really mean to put it there?

Anyway, here's the code.  I haven't actually tested it, but I copied and
pasted from services that I know to function correctly (regardless of
namespaced XML) so I assume that it will work either verbatim, or with a
small amount of tweaking.

sub AnalyzeKensSequences {
	my ($self, $query) = @_;
	# first, get the valid URI for the namespace that we accept
    use MOBY::CommonSubs qw(:all);    
    my ($NSURI) = validateNamespaces('NCBI_gi');  # get teh URI
representation of this namespace
	
	unless ($NSURI){  
		print STDERR "the namespace NCBI_gi does not exist in the MOBY
namespace ontology\n";
		return SOAP::Data->type('base64' => responseHeader() .
responseFooter());  # base 64 encode it (optional)
	}

	my @input_nodes = getInputArticles($query);
	my $response;
	foreach (@input_nodes){
		my $input =  $_->[0];  # we only allow one input object per query
		my ($gi) = getSimpleArticleIDs($NSURI, [$input]);
        my ($seq) = getNodeContentWithArticle($_, "String",
"SequenceString");
        my ($length) = getNodeContentWithArticle($_, "Integer",
"Length");
        my $data;  # do something with the sequence data
        # ... ANALYSIS .... whatever
        $response .=simpleResponse($data);        
	}
    $response =  responseHeader() . $response . responseFooter();
    my $SOAPResponse = SOAP::Data->type('base64' => $response);
    return $SOAPResponse	
}



On Fri, 2003-10-24 at 09:56, Ken Steube wrote:
> On Fri, 24 Oct 2003, Mark Wilkinson wrote:
> > On Fri, 2003-10-24 at 07:58, Paul Gordon wrote:
> > > While I agree that if you declare it as the default name space, you
> > > don't need the moby:, I **strongly** suggest you use an
> > > XML parser that supports namespaces.
> >
> > I agree 110%.  If we put as much energy into re-coding the registry as
> > we did complaining about the moby: namespace the problem wouldn't exist
> > anymore.
> >
> > One thing for certain: we are *not* going to encourage slipshod XML, or
> > redefine the XML specification itself just for our own convenience!  We
> > have to maintain some credibility... even if it means an extra line or
> > two of code here and there in the short-term.
> 
> I understand all that, but I'm not interested in solving your XML
> parsing problems for you.  I'd rather write services at this time.
> 
> Call it complaining if you want, but I've asked you a question you
> can't answer:
> 
> Why do you want to use two different XML namespaces '' and 'moby:' at
> this time?  My interpretation of that would be that there are two
> different data object ontologies, which is not the case at this time.
> If the data doesn't require it, you don't want to use the extra level
> of complication but instead reserve it for when you do need it.
> 
> The reason I have to ask this question is that my very simple XML
> input has all these tags:
> 
> 	<moby:queryInput>
> 	<moby:Simple>
> 	<moby:GenericSequence>
> 	<moby:Integer>
> 	<moby:String>
> 	<CrossReference>
> 	<Object>
> 
> To parse reliably I have to check twice that many because they may or
> may not have an XML namespace.  Chances are pretty good that people
> aren't going to do all this right and services will be unreliable.
> 
> All I'm asking is to make a simple choice: use the namespace or don't.
> 
> > Ken, if you send me the XML message that is causing you headaches I will
> > fix the CommonSubs routine that is failing.  There should be little need
> > for you to ever worry about the moby: prefix if you are using the
> > CommonSubs routines...
> 
> CommonSubs isn't anywhere near to giving us what we need to parse MOBY
> input XML. Take a look at the example below.
> 
> For each MOBY object I need to be able to parse it to get all these things:
> 
> 	class
> 
> 	namespace
> 
> 	id
> 
> 	articleName
> 
> 	value
> 
> And I need parsing to do this too:
> 
> 	all the above for any XML objects included within the top-level obj
> 
> 	content of xref block
> 
> Ken
> 
> 
> 
> <?xml version='1.0' encoding='UTF-8'?>
> <moby:MOBY xmlns:moby='http://www.biomoby.org/moby-s'>
> <moby:Query>
>   <moby:queryInput>
>     <moby:Simple>
>       <moby:AminoAcidSequence namespace='AGI_LocusCode' id='At3g19100' moby:articleName='seqA'>
>         <moby:Integer namespace='' id='' articleName='Length'>947</moby:Integer>
>         <moby:String  namespace='' id='' articleName='SequenceString'>
> 	  <CrossReference>
> 	    <Object namespace='taxon' id='9913'/>
> 	    <Object namespace='Global_Keyword' id='Bos taurus'/>
> 	    <Object namespace='NCBI_Acc' id='M80838'/>
> 	  </CrossReference>
> 	  sequence a
> 	</moby:String>
>       </moby:AminoAcidSequence>
>     </moby:Simple>
>   </moby:queryInput>
>   <moby:queryInput>
>     <moby:Simple>
>       <moby:AminoAcidSequence namespace='NCBI_gi' id='At3g19101' moby:articleName='seqB'>
>         <moby:Integer namespace='' id='' articleName='Length'>947</moby:Integer>
>         <moby:String  namespace='' id='' articleName='SequenceString'>sequence b</moby:String>
>       </moby:AminoAcidSequence>
>     </moby:Simple>
>   </moby:queryInput>
> </moby:Query>
> </moby:MOBY>
> 
> 
> _______________________________________________
> moby-l mailing list
> moby-l at biomoby.org
> http://biomoby.org/mailman/listinfo/moby-l
-- 
Mark Wilkinson <markw at illuminae.com>
Illuminae



More information about the moby-l mailing list