Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] Parsing the BioPortal web service response

Pradnya Gawade pgawade at openclinica.com
Mon Jan 23 06:29:41 PST 2012


Sorry about the typo; JSPN should be JSON.

 

________________________________

From: bioontology-support-bounces at lists.stanford.edu
[mailto:bioontology-support-bounces at lists.stanford.edu] On Behalf Of
Pradnya Gawade
Sent: Monday, January 23, 2012 9:25 AM
To: Paul R Alexander
Cc: bioontology-support at lists.stanford.edu
Subject: Re: [bioontology-support] Parsing the BioPortal web service
response

 

Hi Paul,

 

Thanks for your response. I will take a look at the Xpath code that you
sent as sample but I am more interested in knowing about JSPN support
you mentioned. Could you please provide more details or point me to some
reference on it. I am going to display the ontology contents on my web
page using jsTree jQuery plug-in and making use of JSON plugin for the
same. So BioPortal web service support for JSPN sounds like it might
work with my implementation best. Please let me know more information of
you have on it.

 

Thank you,

Pradnya

 

 

________________________________

From: Paul R Alexander [mailto:palexander at stanford.edu] 
Sent: Friday, January 20, 2012 9:18 PM
To: Pradnya Gawade
Cc: bioontology-support at lists.stanford.edu
Subject: Re: [bioontology-support] Parsing the BioPortal web service
response

 

Pradnya,

You can use an XPath with the Document object in order to get nodes at a
particular level of the DOM hierarchy. Here is some untested sample code
for doing this using XML from the get terms service:
  XPath xpath = XPathFactory.newInstance().newXPath();
  XPathExpression expr = xpath.compile("/success/data/classBean");
  Object result = expr.evaluate(doc, XPathConstants.NODESET);
  NodeList nodes = (NodeList) result;

Also, if you're more comfortable working with JSON then you can try our
JSON support, which is currently in alpha. To get results in JSON, just
add an "Accept: application/json" header to your request. This should
work for all of the Ontology Management services (IE for BioPortal, but
not Annotator or Resource Index).

Best,
Paul R Alexander
Web / UI Developer
NCBO BioPortal
Stanford Center for Biomedical Informatics Research


On 1/20/12 6:23 AM, Pradnya Gawade wrote: 

Hello,

 

I am planning to integrate my web application with BioPortal by using
REST web services API and would like to know more about how people parse
the web service response from BioPortal.

Some where I found the sample code to parse these xmls using DOM parser
which I am using right now and it works for simple cases but I think it
is not reliable because it is difficult to handle nested elements and
things like this with this way where you fetch the elements using
methods like getElementsByTagName(String ..).

Some sample code is here:

 

DocumentBuilderFactory docBuilderFactory =
DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

Document doc = docBuilder.parse(uri);                 

doc.getDocumentElement().normalize();

NodeList listClassBean1 = doc.getElementsByTagName("classBean");

 

 

 I am not able to specify the level of elements in the hierarchy I want
to go up to as in the BioPortal web service response, "classBean" is at
multiple levels. I am thinking there might be better ways to do this may
be using APIs like castor or some how making use of schema files.
However BioPortal say they do not provide schema files. Could any body
please provide any suggests as to how they are doing it? Presently I am
planning to take a look at castor to see how I can use it with BioPortal
web services. 

I will really appreciate the quick response from some body.

 

- Pradnya








_______________________________________________
bioontology-support mailing list
bioontology-support at lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/bioontology-support
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/bioontology-support/attachments/20120123/1287e64b/attachment-0001.html>


More information about the bioontology-support mailing list