RE: [xsl] Unwanted elements in xsl output

Subject: RE: [xsl] Unwanted elements in xsl output
From: "Rudi Starcevic" <rudi@xxxxxxxxxxxx>
Date: Wed, 9 Jul 2003 21:57:33 +1000
Hi Jarno,

Thanks,

In my Sam's 24 hours book I can't see a mention of the Built in templates
but after I checked the index of my two new Book's by Jenni I see it clearly.

Thanks for the link too.
Great !

Regards
Rudi.

> Hi,
> 
> > <xsl:template match="/">
> > <html>
> > <head><title>Web app. list</title></head>
> > <body>
> > 	<xsl:for-each select="webapps/website">
> > 		<table border="1" summary="Web Application Table">
> > 		<tr>
> > 			<td>Site Name:</td>
> > 			<td><xsl:value-of select="@name"/></td>
> > 		</tr>
> > 		<xsl:apply-templates/>
> 
> Here you ask to process all the child nodes, including the language element
> 
> > 		</table>
> > 	</xsl:for-each>
> > </body>
> > </html>
> > </xsl:template>
> > 
> > <xsl:template match="address">
> 
> and this will match the address elements
> 
> > 	<tr>
> > 		<td>URL:</td>
> > 		<td><xsl:value-of select="."/></td>
> > 	</tr>
> > </xsl:template>
> 
> but you don't have a template to match the language element. Thus, 
> the build-in template is used to process it, see 
> <http://www.w3.org/TR/xslt#built-in-rule>. The result is that a text 
> node "PHP" will be added to the result tree, without tr and td 
> element wrappers. The HTML DTD doesn't allow PCDATA inside table,
>  thus browser error recovery kicks in; Mozilla recovers by 
> outputting the PCDATA after the table, IE before.
> 
> You can fix your stylesheet by either selecting only the elements 
> you want to process in the / template, i.e. 
> 
>   <xsl:apply-templates select="address" />
> 
> or be adding a template to match the language element and output 
> nothing in it.
> 
>   <xsl:template match="language"/>
> 
> It usually/always helps in debugging if you use a command-line XSLT 
> processor, or an IDE like Xselerator to see what the output is,
>  instead of just looking at the HTML renderation on a browser.
> 
> Cheers,
> 
> Jarno - Razed In Black: Oh My Goth!... aah, the nostalgia
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread