xsl-list
[Top] [All Lists]

RE: [xsl] template never matches

2011-02-22 07:21:00
Oh yeah, heh, silly me.

Hi Andrew, hope all is well.

Thanks all

-----Original Message-----
From: Andrew Welch [mailto:andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com]
Sent: 22 February 2011 13:07
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Cc: Merrilees, David
Subject: Re: [xsl] template never matches

On 22 February 2011 12:39, Merrilees, David 
<David(_dot_)Merrilees(_at_)uk(_dot_)tesco(_dot_)com> 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>Vítejte</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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


This is a confidential email. Tesco may monitor and record all emails. The 
views expressed in this email are those of the sender and not Tesco.

Tesco Stores Limited
Company Number: 519500
Registered in England
Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire EN8 9SL
VAT Registration Number: GB 220 4302 31

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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