title: XSLT: How to get the distinct value from between two xml
body: <p>My aim i just to want to get the distinct the value, i mean, no of 10th <code>td</code> value that is available in the second xml( xml file through 'document' function) and it should not be available in the source xml, this value i am treating as 'dintinct' value. How I can get this? I tried above code and it does not provide exact distinct values that i expect. Any help?</p>
  
  <p><a href="https://stackoverflow.com/questions/28628901/xslt-how-to-compare-two-xml-files-and-how-to-get-distinct-value-from-it">XSLT: How to compare two xml files and how to get distinct value from it</a> based on this question, I tried the following with input xml files, but, even, i am not able to get the distinct text between two files.</p>
  
  <p>For example, as per the correct result, here, this <code>&lt;distint&gt;Meat and edible meat offal.&lt;/distint&gt;</code> not supposed to come. But, right now, it is coming and this is wrong.</p>
  
  <p>XSL file</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"&gt;
  
  &lt;xsl:output method="xml" indent="yes" encoding="UTF-8"/&gt;
  &lt;xsl:variable name="check" select="normalize-space(substring(//document[@indent='-2']/documenttitle,3))"/&gt;
  
  &lt;xsl:template match="/"&gt;    
  &lt;xsl:for-each select="document('Main2.xml')//*[local-name()='tr']/*[local-name()='td'][10][./preceding-sibling::td[5][. != '']]"&gt;
  &lt;xsl:choose&gt;
   &lt;xsl:when test=". = $check"&gt;
   &lt;/xsl:when&gt;
   &lt;xsl:otherwise&gt;
   &lt;xsl:text&gt;
  
   &lt;/xsl:text&gt;
   &lt;distint&gt;&lt;xsl:value-of select="."/&gt;&lt;/distint&gt;
   &lt;/xsl:otherwise&gt;
   &lt;/xsl:choose&gt;
  &lt;/xsl:for-each&gt;  
  
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Source XML</p>
  
  <pre><code>&lt;XML&gt;
      &lt;documents&gt;
      &lt;document indent="-3"&gt;
        &lt;document_prefixtitle&gt;Some text&lt;/document_prefixtitle&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;1 Live animals.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;2 Meat and edible meat offal.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;3 Fish and crustaceans, molluscs and other aquatic invertebrates.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;4 Dairy produce; birds eggs; natural honey; edible products of animal origin, not elsewhere specified or included.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;5 Products of animal origin, not elsewhere specified or included.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;6 Live trees and other plants; bulbs, roots and the like; cut flowers and ornamental foliage.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;7 Edible vegetables and certain roots and tubers.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;8 Edible fruit and nuts; peel of citrus fruit or melons.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;9 Coffee, tea mat, and spices.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;10 Cereals.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;11 Products of the milling industry; malt; starches; inulin; wheat gluten.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;12 Oil seeds and oleaginous fruits; miscellaneous grains, seeds and fruit; industrial or medicinal plants; straw and fodder.&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;13 Example of distint chaptrr fruits; miscellaneous grains&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;document indent="-2"&gt;&lt;documenttitle&gt;14 1Example of distint chaptrr fruits; miscellaneous grains&lt;/documenttitle&gt;&lt;/document&gt;
  &lt;/document&gt;&lt;/documents&gt;&lt;/XML&gt;
  </code></pre>
  
  <p>XML that is taken through 'document' function is:</p>
  
  <pre><code>&lt;table&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Live animals.&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Meat and edible meat offal.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Fish and crustaceans, molluscs and other aquatic invertebrates.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Dairy produce; birds eggs; natural honey; edible products of animal origin, not elsewhere specified or included.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Products of animal origin, not elsewhere specified or included.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Live trees and other plants; bulbs, roots and the like; cut flowers and ornamental foliage.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Edible vegetables and certain roots and tubers.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Edible fruit and nuts; peel of citrus fruit or melons.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Coffee, tea mat, and spices.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Cereals.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Products of the milling industry; malt; starches; inulin; wheat gluten.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Oil seeds and oleaginous fruits; miscellaneous grains, seeds and fruit; industrial or medicinal plants; straw and fodder.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;17&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Live animals new sample.&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Yes&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;18&lt;/td&gt;
  &lt;td&gt;_24&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;20141210&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;Active Live animals new sample.&lt;/td&gt;&lt;/tr&gt;
  
  &lt;/tbody&gt;
  &lt;/table&gt; 
  </code></pre>
  
  <p>As of now, am getting the result as follows</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;distint&gt;Meat and edible meat offal.&lt;/distint&gt;
  &lt;distint&gt;Fish and crustaceans, molluscs and other aquatic invertebrates.&lt;/distint&gt;
  &lt;distint&gt;Dairy produce; birds eggs; natural honey; edible products of animal origin, not elsewhere specified or included.&lt;/distint&gt;
  &lt;distint&gt;Products of animal origin, not elsewhere specified or included.&lt;/distint&gt;
  &lt;distint&gt;Live trees and other plants; bulbs, roots and the like; cut flowers and ornamental foliage.&lt;/distint&gt;
  &lt;distint&gt;Edible vegetables and certain roots and tubers.&lt;/distint&gt;
  &lt;distint&gt;Edible fruit and nuts; peel of citrus fruit or melons.&lt;/distint&gt;
  &lt;distint&gt;Coffee, tea mat, and spices.&lt;/distint&gt;
  &lt;distint&gt;Cereals.&lt;/distint&gt;
  &lt;distint&gt;Products of the milling industry; malt; starches; inulin; wheat gluten.&lt;/distint&gt;
  &lt;distint&gt;Oil seeds and oleaginous fruits; miscellaneous grains, seeds and fruit; industrial or medicinal plants; straw and fodder.&lt;/distint&gt;
  &lt;distint&gt;Live animals new sample.&lt;/distint&gt;
  &lt;distint&gt;Active Live animals new sample.&lt;/distint&gt;
  </code></pre>