RE: [xsl] Removing unwanted tag content from xsl output to html response.

Subject: RE: [xsl] Removing unwanted tag content from xsl output to html response.
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 11 Mar 2003 11:22:26 +0200
Hi,

> I have the following xsl sheet (Very simple) and when I do 
> not include the
> <xsl:template match="*" /> I get my output the way I want it, 
> but with all
> the remainder of the xml as text at the bottom of the screen. 
>  If I include
> the match="*" template I get nothing at all.
> 
> Any pointers would be handy. (NOTE: All paths in templates 
> are absolute)
> 
> Cheers
> 
> Simon
> 
> [CODE]
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="1.0">
>     <xsl:output method="html"/>
> 
>     <!-- template rule matching source /root/tables element -->
>     <xsl:template match="/root/tables">
>         <h1>Avaliable subsystems and signals</h1>
>         <table border="1" cellpadding="3">
>             <tbody>
>                 <tr>
>                     <th>Subsystem</th>
>                     <th>Time Select (Not implemented)</th>
>                     <th>Signal Select</th>
>                 </tr>
>                 <xsl:apply-templates select="/root/tables/table"/>
>             </tbody>
>         </table>
>     </xsl:template>
> 
>     <xsl:template match="/root/tables/table">
>         <tr>
>             <td>
>                 <b><xsl:value-of select="@name"/></b>
>             </td>
>             <td width="50" bgcolor="red">
>                 <b><u>Time stamp not implemented yet!</u></b>
>             </td>
>             <td>
>                 <xsl:for-each select="column">
>                     <xsl:apply-templates
> select="/root/tables/table/column"/>
>                 </xsl:for-each>
>             </td>
>         </tr>
>     </xsl:template>
> 
>     <xsl:template match="/root/tables/table/column">
>         <b>Click to select :</b><xsl:value-of select="."/><br/>
>     </xsl:template>
> 
> <!-- This is the line causing the problem -->
>     <xsl:template match="*" />

When the processing starts, the build-in template for "/" will kick in, and process all child nodes. The template above will be used to process the "root" element, thus the other templates above will never be used as it does not select any nodes for processing. If you want to process just "/root/tables", then e.g. replace the template causing problems with

<xsl:template match="/">
  <xsl:apply-templates select="root/tables" />
</xsl:template>

Cheers,

Jarno - SITD: Snuff Machinery (Club Version)

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


Current Thread