Для самого простого прикладу візьмемо наступний XML:
<msgs>
<error>Login or password is wrong</error>
<info>Cookies is disabled</info>
</msgs>
І спробуємо застосувати до нього такий XSLT:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select='msgs/error'>
<div style='color: red'>
<xsl:value-of select='.'/>
<xsl:for-each select="button">
<xsl:element name="input">
<xsl:attribute name="type">button</xsl:attribute>
<xsl:if test="@label">
<xsl:attribute name="name"><xsl:value-of select="@label"/></xsl:attribute>
</xsl:if>
<xsl:attribute name="value"><xsl:value-of select="@val"/></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:attribute name="onclick"><xsl:value-of select="@onclick"/></xsl:attribute>
</xsl:element>
</div></br>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
На виході ми отримуємо чудовий XHTML :) якщо хочете - то навіть HTML5