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

RE: Template priority problem

Subject: RE: Template priority problem
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 6 Sep 2005 16:53:40 +0100
xsl template priority
When people come to this list and say that a template isn't matching when
they expect it to, the most common reason is that the elements are in a
namespace (typically a default namespace). You haven't shown us the source
document, so that's just a guess.

Michael Kay
http://www.saxonica.com/ 



> -----Original Message-----
> From: Chris Bowditch [mailto:bowditch_chris@xxxxxxxxxxx] 
> Sent: 06 September 2005 16:38
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Template priority problem
> 
> I have a requirement to copy a source XML input file but 
> adjust just a 
> couple of elements in the file. I thought this would be real 
> simple but 
> I can't get it to work. I have two templates, one specific to match 
> elements I want to change and a identity transform one. Here 
> is the XSL 
> I have:
> 
> <xsl:template match="field" priority="2">
> 	<xsl:variable name="fieldindex" select="@index"/>
> 	<xsl:variable name="fieldname" 
> select="ancestor::dataSet/fielddefinition[$fieldindex]/@label"/>
> 	<field>
> 		<xsl:value-of select="."/>
> 	</field>
> </xsl:template>
> <xsl:template match="* | comment() | text() | 
> processing-instruction() | 
> @*" priority="1">
> 	<xsl:copy>
> 		<xsl:apply-templates select="* | comment() | text() | 
> processing-instruction() | @*"/>
> 	</xsl:copy>
> </xsl:template>
> 
> The problem is the template that matches field elements is always 
> ignored, despite the higher priority! So I just get an exact 
> copy of the 
> input XML. Can someone explain why this is and offer a simple 
> solution 
> to my requirement.
> 
> Thanks,
> 
> Chris

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.