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

Subject: RE: [xsl] how to <xsl:apply-templates /> for ELEMENT nodes only?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 30 Mar 2004 08:56:00 +0100
You can apply templates to elements only by writing <xsl:apply-templates
select="*"/>. But I don't see what's inelegant about overriding the default
template rule for text nodes.

Michael Kay 

> -----Original Message-----
> From: Terence Kearns [mailto:terencek@xxxxxxxxxxxxxxxxxxx] 
> Sent: 30 March 2004 07:04
> To: XSL-List
> Subject: [xsl] how to <xsl:apply-templates /> for ELEMENT nodes only?
> 
> 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;	
> 		 
> <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()" />
> 
> While this works, surely there is a more elegant way. The source XML 
> uses an informal schema designed by someone else which mixes 
> text with 
> elements (document centric schema). I'm halfway through overhauling 
> their XSLT templates and I just want all templates matching 
> any type of 
> element to be applied.
> 
> 
> 
> -- 
> Terence Kearns
> ph: +61 2 6201 5516
> Enterprise Applications Developer
> Enterprise Systems Support and Development
> Information and Communications Technology (ICT) Services
> University of Canberra, Australia - http://www.canberra.edu.au

Current Thread