[MOBY-l] jMoby bug?

Benjamin Good bmg at sfu.ca
Wed Feb 2 16:52:52 UTC 2005


It seems that there is an error with the toXML method in the class 
MobyDataSimpleInstance .  When the class is in CENTRAL_XML_MODE as in 
when it is being used as a service input in a template service that is 
sent to central to find other services, this method returns something 
that looks like this:
>>> <Input>
>>> <Simple
>>> xmlns="http://www.biomoby.org/moby"xmlns:moby="http://
>>> www.biomoby.org/moby" moby:articleName="dummy">
>>> <Object namespace="NCBI_gi" id="111076"/></Simple></Input>

When in fact I think it should look something like this:

>>> <Input>
>>> <Simple articleName="dummy">
>>> <objectType>Object</objectType>
>>> <Namespace>NCBI_gi</Namespace></Simple>
>>> </Input>


The problem method is below, followed by a corrected version.  Please 
let me know if I have interpreted this correctly.

cheers
-Ben

/**
      * Produces a full-blown XML fragment that depending on the value 
of getXmlMode() is either
      * a template for use in MOBY Central services, or a Simple element 
for use in calling a service
      * instance.
      *
      * @return the MOBY XML representation of the data instance

     public String toXML(){
	if(xmlMode == SERVICE_XML_MODE)
	    return "<Simple xmlns=\""+MobyPrefixResolver.MOBY_XML_NAMESPACE+
		(getName() != null ? "\" xmlns:moby=\""+
		 MobyPrefixResolver.MOBY_XML_NAMESPACE+"\" moby:articleName=\"" + 
getName() : "")+
		"\">" + dataValue + "</Simple>";
	else{
	    MobyNamespace[] ns = getNamespaces();
	    String result = "<Simple 
xmlns=\""+MobyPrefixResolver.MOBY_XML_NAMESPACE+"\">\n<objectType>" +
		getDataType().getName() + "</objectType>\n";
	    for(int i = 0; ns != null && i < ns.length; i++){
		result += "<Namespace>" + ns[i].getName() + "</Namespace>\n";
	    }
	    result += "</Simple>";
	    return result;
	}
     }
     */

     public String toXML(){
     	if(xmlMode == SERVICE_XML_MODE)
     	    return "<Simple "+
     		(getName() != null ? " xmlns:moby=\""+
     		 MobyPrefixResolver.MOBY_XML_NAMESPACE+"\" moby:articleName=\"" + 
getName() : "")+
     		"\">" + dataValue + "</Simple>";
     	else{
     	    MobyNamespace[] ns = getNamespaces();
     	    String result = "<Simple>\n<objectType>" +
     		getDataType().getName() + "</objectType>\n";
     	    for(int i = 0; ns != null && i < ns.length; i++){
     		result += "<Namespace>" + ns[i].getName() + "</Namespace>\n";
     	    }
     	    result += "</Simple>";
     	    return result;
     	}
         }





More information about the moby-l mailing list