RE: [xsl] xslt a mixed html and xml file

Subject: RE: [xsl] xslt a mixed html and xml file
From: "Stephen Tredrea" <stephen.tredrea@xxxxxxxxxxxxx>
Date: Mon, 14 Jun 2004 15:42:49 +0200
Stunning... thank you!

-----Original Message-----
From: Michael Kay [mailto:mhk@xxxxxxxxx]
Sent: 14 June 2004 01:50 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] xslt a mixed html and xml file


> 
> ... I want to apply a style sheet that outputs the HTML as it 
> is but also
> applies templates to the custom bits.
> 
> ...but I need to add in this WITHOUT changing the XML:
> 
> <xsl:template match="link">
> 	<a href="<xsl:value-of select="href" />">
> 		<xsl:value-of select="innerHTML" />
> 	</a>
> </xsl:template>
> 
> Hoping there's a simple and elegant solution, Stephen
> 

There is indeed. Use the identity template as your default template rule:

<xsl:template match="*">
  <xsl:copy>
  <xsl:copy-of select="@*"/>
  <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

and then supplement it with template rules like yours above that treat
particular elements differently.

Michael Kay

Current Thread