Bug 526979 - XMLDocumentService.cleanTags() duplicate text fragments.

Change-Id: I7ef8436cf99caba7e4070606eda52eb8be132e6e
Signed-off-by: Antonio Campesino <antonio.campesino.robles@ericsson.com>
diff --git a/plugins/org.eclipse.gendoc.documents/src/org/eclipse/gendoc/documents/XMLDocumentService.java b/plugins/org.eclipse.gendoc.documents/src/org/eclipse/gendoc/documents/XMLDocumentService.java
index 7cd56d0..8a6621d 100644
--- a/plugins/org.eclipse.gendoc.documents/src/org/eclipse/gendoc/documents/XMLDocumentService.java
+++ b/plugins/org.eclipse.gendoc.documents/src/org/eclipse/gendoc/documents/XMLDocumentService.java
@@ -27,6 +27,7 @@
 import java.util.regex.Pattern;
 
 import javax.xml.namespace.NamespaceContext;
+import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
@@ -325,8 +326,8 @@
         // 1. Find next node with starting tag character
 
         Node firstNode = findNodeWithOneTag(currentNode);
-        firstNode = getBestAscendantUntil(currentNode, firstNode); // firstNode == null if not contained in current node
-        
+        if (firstNode != null && getBestAscendantUntil(currentNode, firstNode)== null)  //if not contained in current node
+        	firstNode = null;
         Node next = cleanTags(currentNode, tagLabels, firstNode);
         if (currentNode == null || currentNode.getParentNode() == null)
         {
@@ -338,6 +339,8 @@
         while (next != null)
         {
             nextStartNode = findNodeWithStartTag(next, currentNode);
+            if (nextStartNode != null && getBestAscendantUntil(currentNode, nextStartNode)== null)  //if not contained in current node
+            	nextStartNode = null;
             next = cleanTags(currentNode, tagLabels, nextStartNode);
             if (currentNode == null || currentNode.getParentNode() == null)
             {