xsl-list
[Top] [All Lists]

AW: [xsl] template never matches

2011-02-22 06:47:04
Hi, 

If i understand that correctly you need an apply-templates in the template that 
matches node() | @*
AFAIK xsl:sequence will only copy the childs into a sequence but it won't apply 
any templates to them.

Also if you match "/" you won't need copy because "/" isn't really an element 
thus there is nothing to copy. 

regards



. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT-Entwickler 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick(_dot_)szabo(_at_)lexisnexis(_dot_)at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 


-----Ursprüngliche Nachricht-----

Von: Merrilees, David 
[mailto:David(_dot_)Merrilees(_at_)uk(_dot_)tesco(_dot_)com] 
Gesendet: Dienstag, 22. Februar 2011 13:39
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: [xsl] template never matches

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:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        exclude-result-prefixes="xs xsl">

        <xsl:template match="/">
                <xsl:copy>
                        <xsl:apply-templates select="@* | node()" mode="test"/>
                </xsl:copy>
        </xsl:template>

        <xsl:template match="node() | @*" mode="test">
                <!-- always matched -->
                <xsl:sequence select="." />
        </xsl:template>

        <xsl:template match="head" mode="test">
                               <!-- never matched -->
                <xsl:copy>
                        <xsl:apply-templates select="@* | node()" mode="test" />
                        <link rel="shortcut icon" href="/favicon.ico" />
                </xsl:copy>
        </xsl:template>

</xsl:stylesheet>

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>
--~--




--~------------------------------------------------------------------
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>