[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: template never matches

Subject: Re: template never matches
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 22 Feb 2011 13:47:03 +0100
Re:  template never matches
Merrilees, David wrote:

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"?>
     <meta charset="utf-8"/>
   <body id="home">


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
         exclude-result-prefixes="xs xsl">

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

Here you process the child nodes of the document node with a matching template in mode "test". The only child node is the "html" element so for that element the template below is applied, it simply outputs the node with xsl:sequence but does not process any child nodes so the "head" element is never used for further processing.

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

<xsl:template match="head" mode="test">

To fix that you need apply-templates but I am not really sure what you want to achieve so for further help you might want to show the output you want to create from your input sample.


	Martin Honnen

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.