Is it compulsory to use templates for XSLT when converting XML to HTML?



I apologize for asking a relatively basic question about XSLT, but I cannot find a satisfactory answer anywhere. I have tried several online tutorials (icnluding the w3 schools) and Sal Mangano's excellent book.


Most tutorials and explanations advice using <xsl:template> and <xsl:apply-templates>for transforming XML into HTML. However, when I am doing very simple transpositions I can achieve everything I need without templates, with only something like this:



<xsl:for-each select="...">
<xsl:value-of select="..." />
</xsl:for-each>


This approach is slightly less verbose and it seems to be equally effective. However, I wonder if I am missing something. Is there any reason why I should use templates even for simple transformations? Thank you.


No comments:

Post a Comment