Re: [xsl] Default Rendering of HTML?

Subject: Re: [xsl] Default Rendering of HTML?
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Sun, 21 Nov 2004 21:35:16 +0100
Shawn wrote:
	<xsl:template match="/news">
		<xsl:apply-templates/>
	</xsl:template>

This template is redundant, the XSLT processor already provides such a template for every elemen for you.

	<xsl:template match="item">
		<p>
			<span>
				<xsl:attribute name="class">newsDate</xsl:attribute>
				<xsl:value-of select="date"/>
			</span>

This is overly verbose, writing <span class="newsdate"><xsl:value-of select="date"/></span> should work as well.

<xsl:value-of select="text"/>
This will insert the value of the first text node of the text element
into the result, which is probably white space.
You want
 <xsl>copy-of select="text"/>
here.

Check you favorite XSLT book, one of the online tutorials or
the spec for details of xsl:value-of ann xsl:copy-of (and preferably
xsl:copy too) in order to notice the difference.

J.Pietschmann

Current Thread
  • [xsl] Default Rendering of HTML?
    • Shawn - Sun, 21 Nov 2004 01:12:46 -0700
      • xptm - Sun, 21 Nov 2004 13:32:32 +0000
        • Shawn - Sun, 21 Nov 2004 13:13:10 -0700
          • J.Pietschmann - Sun, 21 Nov 2004 21:35:16 +0100 <=
          • Shawn - Sun, 21 Nov 2004 13:46:04 -0700
          • Shawn - Sun, 21 Nov 2004 13:42:46 -0700
      • <Possible follow-ups>
      • Passin, Tom - Mon, 22 Nov 2004 11:55:09 -0500