[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"?>
<html>
   <head>
     <title>Vmtejte</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"/>

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>

<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
	http://msmvps.com/blogs/martin_honnen/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.