Subject: Re: [xsl] template never matches From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Tue, 22 Feb 2011 13:06:49 +0000 |
On 22 February 2011 12:39, Merrilees, David <David.Merrilees@xxxxxxxxxxxx> wrote: > Hi > > I'm having trouble matching a named element vs using node(). Code below. Any bright ideas? > > Example input: > > <?xml version="1.0" encoding="utf-8"?> > <html> > <head> > <title>Vmtejte</title> > <meta charset="utf-8"/> > </head> > <body id="home"> > </body> > </html> > <xsl:template match="node() | @*" mode="test"> > <!-- always matched --> > <xsl:sequence select="." /> > </xsl:template> That will match <html> and then effectively copy the whole input tree to the output... you need to call apply-templates: <xsl:template match="/"> <xsl:apply-templates mode="test"/> </xsl:template> <xsl:template match="node() | @*" mode="test"> <xsl:copy> <xsl:apply-templates select="@* | node()" mode="#current"/> </xsl:copy> </xsl:template> <xsl:template match="head" mode="test"> <xsl:copy> <xsl:apply-templates select="@* | node()" mode="test" /> <link rel="shortcut icon" href="/favicon.ico" /> </xsl:copy> </xsl:template> -- Andrew Welch http://andrewjwelch.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] template never matches, Martin Honnen | Thread | RE: [xsl] template never matches, Merrilees, David |
Re: [xsl] template never matches, Martin Honnen | Date | RE: [xsl] template never matches, Merrilees, David |
Month |