Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Thanked 0 Times in 0 Posts

    to exculde some search terms in the xml code


    I have an xml code which searches for names in a webpage and checks against a article content. Now i have certain names in this webpage which need to be excluded for the search.

    my code goes like this=

    <Content type="html" view="profile">
        <script type="text/javascript">
    		//This will hold all the drug code
    		//The key/index will be the drug names
    		var drugReference = [];		
    		//The url using which master list of drugs can be downloaded
    		var drugListUrl = "http://rest.kegg.jp/list/drug";
    		//Prefix of the url using which specifications of a particular drug
    		//can be fetched
    		var drugSpecsUrlPrefix = "http://www.kegg.jp/entry/"
    		//This will hold the entire article content
    		var articleContent = "";
    		//This method is used to make a call to retrieve the article content
    		function getContent(){
    		//The getContent callback function 
    		//After retrieving the article content make a call to the function
    		//that will link the drug names
    		function getContentCallback(response){
    			if (response != null){			
    				articleContent = response.toUpperCase();				
    				alert("Sorry!!!. Unable to retrieve the article content");
    		//This method is used to make a request to get the entire list of drug names
    		function linkText(){     		
    			var params ;
    			gadgets.sciverse.makeRequest(drugListUrl, requestCallBack, params);
    		//The makeRequest callback function
    		function requestCallBack (response){
    			//Get the contents of the drug listing
    			var relevantData = response.text;
    			//Each line represents a particular drug. 
    			//Split and get each drug into an array
    			var drugs = relevantData.split("\n");
    			//Array to hold the terms to be linked in the article
    			var terms  = [];
    			for(var i=0; i < drugs.length; i++) {				
    				//Each line will have a drug code and multiple drug names
    				//seperated by a tab. Split the drug code and names first
    				var drug = drugs[i].split('\t');
    				var drugCode = drug[0];				
    				var drugNames = drug[1].split(";");
    				//Split the multiple drug names and map each name to the drug code
    				for(var j = 0; j < drugNames.length ; j++){						
    					var temp = drugNames[j].toUpperCase();
    					//From the drug names, extract only the names
    					//and exclude the words in the paranthesis
    					//Ex : dr:D07380	Letosteine (INN); Viscotiol (TN)
    					//we will extract only the  words LETOSTEINE
    					//and VISCOTIOL and then map these to the drug code dr:D07380
    					//we do not consider (INN) and (TN) which are part of the
    					//drug names. This is because in an article we may not
    					//find the terms such as the ones in the paranthesis
    					var index = temp.indexOf("(");					
    					if(index > 0){
    						temp = temp.substring(0,index);
    					//Trim any extra whitespace characters and get the drug name
    					var actDrugName = $.trim(temp);					
    					//Store the drug code with the drug name as the key to it
    					drugReference[actDrugName] = drugCode;
    					//If the drug name is found in the article content
    					//then add it to the list of terms to be linked
    					if(articleContent.indexOf(actDrugName) > 0){
    			//other required parameters to be used while linking
                var categories = ["all"];
                var frequency = "every";
                var occurrence = 1;
                // Link the drug names that have been added to the terms array
            // The linkText callback function.
            function linkTextCallback(term, posx, posy){		
    			var drugName = term.toUpperCase();
    			//Get the drug code for the drug that has been selected
    			var drugCode = drugReference[drugName]			
                //Open window with the specifications for the drug that is selected
    			var drugSpecsUrl =drugSpecsUrlPrefix + drugCode;			
            //Resize the gadget on load
            gadgets.util.registerOnLoadHandler(function() {gadgets.window.adjustHeight();});

    The http://rest.kegg.jp/list/drug is the url where the list of names available and i need to excluded some so please tell me how would i omit that.

    Last edited by WA; 07-12-2012 at 07:53 PM.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts