Nic Miloslav     Example 7    KEYWORDS      EXAMPLES      AUTHORS     

Contents of original elements can be recovered from original sources in two basic ways. Stylesheet 1 uses xsl:value-of construct. In this case the contents of the element is used without any further processing. Construct xsl:apply-templates in Stylesheet 2 is different. The parser further processes selected elements, for which a template is defined..


     XML     HOME     XSL 1     XSL 2      
<xslTutorial >
<employee>
<firstName>Joe</firstName>
<surname>Smith</surname>
</employee>
</xslTutorial>

     XSL 1     HOME     XML     HTML 1     OUTPUT 1     
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="employee">
<B><xsl:value-of select="."/></B>
</xsl:template>
<xsl:template match="surname">
<i><xsl:value-of select="."/></i>
</xsl:template>
</xsl:stylesheet>

     HTML 1     HOME     XML     XSL 1     OUTPUT 1     
<B> Joe Smith </B>

     OUTPUT 1     HOME     XML     XSL 1     HTML 1     
Joe Smith

     XSL 2     HOME     XML     HTML 2     OUTPUT 2     
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="employee">
<B><xsl:apply-templates select="firstName"/></B>
<B><xsl:apply-templates select="surname"/></B>
</xsl:template>
<xsl:template match="surname">
<i> <xsl:value-of select="."/></i>
</xsl:template>
</xsl:stylesheet>

     HTML 2     HOME     XML     XSL 2     OUTPUT 2     
<B>Joe</B>
<B>
<i>Smith</i></B>

     OUTPUT 2     HOME     XML     XSL 2     HTML 2     
JoeSmith