@Override
   public void map(LongWritable key, Text value1,Context context) throws IOException, InterruptedException {

	   String xmlString = value1.toString();
       SAXBuilder builder = new SAXBuilder();
       Reader in = new StringReader(xmlString);
       
       try {
    	  
           Document doc = builder.build(in);
           Element root = doc.getRootElement();
           
           String link="";
           String pageTitle =root.getChild("title").getTextTrim() ;            
           String pageText =root.getChild("revision").getChild("text").getTextTrim();
           pageTitle = pageTitle.replace(' ', '_');
           
           /* Pattern to extract text inside "[[ ]]" */
   			//Pattern pattern = Pattern.compile("\\[\\[.*?\\]\\]");
            Pattern pattern = Pattern.compile("\\[\\[.*?\\]\\]");
   			Matcher matcher = pattern.matcher(pageText);
   			String[] tempArray;
   			while (matcher.find()) {
//   				link = matcher.group(0).replace('[', ' ').replace(']', ' ').trim();
   				link = matcher.group(0).substring(2, matcher.group(0).length() - 2);
   				
   				if(link.contains("[[")){
   					tempArray = link.split("\\[\\[");
   					link = tempArray[tempArray.length - 1]; 
   				}else if(link.contains("]]")){
   					tempArray = link.split("\\]\\]");
   					link = tempArray[0]; 
   				}
	   			/* Fetching the first page when a '|' occurs */
	   			int pipePos = link.indexOf('|');
	   			if(pipePos >= 0){
	   				link = (link.substring(0, pipePos));
	   			}
	   			/* Replacing spaces with '_' */
	   			link = link.replace(' ', '_');
	   			
	   			/* Excluding interwiki links, section linking and table row linking */
	   			if ( link.indexOf(':') < 0  && link.indexOf('#') < 0 && !link.equals(pageTitle)) {
	   				context.write(new Text(pageTitle + "    " + 1.0 + "    "), new Text(link));
	   			}
	   			link = "";
   		}
           
       } catch (JDOMException ex) {
           Logger.getLogger(parserXmlMap.class.getName()).log(Level.SEVERE, null, ex);
       } catch (IOException ex) {
           Logger.getLogger(parserXmlMap.class.getName()).log(Level.SEVERE, null, ex);
       }
   
   }