>right now, the code will print <HTML> tag everytime //DATA contains somethings
Actually, it will output one <HTML> element for every LINE element in your source document. That's what xsl:for-each does.
>how can i set a condition or set variable to make a comparison between previous DATA content with current DATA content?
You can compare a node with its immediately preceding sibling using
<xsl:if test=". = preceding-sibling::*[1][self::DATA]">
or with all preceding siblings using
<xsl:if test=". = preceding-sibling::DATA">
For grouping in XSLT 2.0, use xsl:for-each-group. If you're stuck with 1.0, it's much more difficult, read about it at
http://www.jenitennison.com/xslt/grouping
But I'd suggest learning the basics first. Your first question suggests you haven't understood things like for-each, template rules, the meaning of "//", etc; don't try any fancy grouping until you've mastered these foundations.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference