title: How can I read all data from text plain using xslt in Java?
body: <p>I have the following text file (.txt):</p>
  
  <pre><code>IT000000000000000545Panquecitos 2 100gr BIM OLA
  IT000000000000000797Dalmata 45g MLA
  IT000000000000001782Quequito max 80g Arrorico BIM
  </code></pre>
  
  <p>I read my file and I get an XML, but my code reads only the first row and I need to read all data. For example:</p>
  
  <pre><code>&lt;items&gt;
     &lt;item&gt;
        &lt;nick&gt;IT&lt;/nick&gt;
        &lt;num&gt;000000000000000545&lt;/nick&gt;
        &lt;desc&gt;Panquecitos 2 100gr BIM OLA&lt;/nick&gt;
     &lt;/item&gt;
     &lt;item&gt;
        &lt;nick&gt;IT&lt;/nick&gt;
        &lt;num&gt;000000000000000797&lt;/nick&gt;
        &lt;desc&gt;Dalmata 45g MLA&lt;/nick&gt;
     &lt;/item&gt;
     ...
  &lt;/items&gt;
  </code></pre>
  
  <p>This is my code to read the file:</p>
  
  <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt;
  &lt;xsl:variable name="vText" select="replace(unparsed-text('file:///C:/Users/Quality/Desktop/test.txt'),'\r','')"/&gt;
  &lt;xsl:template name="main" match="/"&gt;
  &lt;items&gt;
  &lt;xsl:for-each select="$vText"&gt;
     &lt;item&gt;
           &lt;xsl:element name="nick"&gt;&lt;xsl:value-of select="substring($vText,1,2)"&gt;&lt;/xsl:value-of&gt;&lt;/xsl:element&gt;
           &lt;xsl:element name="num"&gt;&lt;xsl:value-of select="substring($vText,3,18)"/&gt;&lt;/xsl:element&gt;
           &lt;xsl:element name="desc"&gt;&lt;xsl:value-of select="substring($vText,21,40)"/&gt;&lt;/xsl:element&gt;
     &lt;/item&gt;
  &lt;/xsl:for-each&gt;
  &lt;/items&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>