xsl-list
[Top] [All Lists]

RE: how to <xsl:apply-templates /> for ELEMENT nodes only?

2004-03-30 00:51:41
Hi,

At the moment, I have

  <!-- lots of imported templates in this XSL file -->
  <xsl:template match="/">
   <html>
    <head>
     <title>UC Policy Database</title>
     <link rel="StyleSheet" type="text/css" 
href="policydb_content.css"/>
    </head>
    <body leftmargin="0" topmargin="0" marginwidth="0" 
marginheight="0">
     <xsl:call-template name="header"/>
     <xsl:apply-templates select="//menu" mode="menu"/>&#xa0; 

The same advice as always, using // is expensive and you should avoid it if you 
can.

<xsl:apply-templates />
     <xsl:call-template name="footer"/>
    </body>
   </html>
  </xsl:template>

But in order to stop the text node from being spewed out by 
default, I 
have to explicityly surpress it with
<xsl:template match="//text()" />

Simple "text" will suffice.

While this works, surely there is a more elegant way. The source XML 

There's nothing inelegant about your solution. The other approach, possibly 
preferable, is that you don't select the nodes you don't want to be processed. 
That is, instead of

  <xsl:apply-templates />

use

  <xsl:apply-templates select="*" />

or what ever the content model contains.

Cheers,

Jarno - Epsilon Minus: Freedom


<Prev in Thread] Current Thread [Next in Thread>