This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Apply-template printing text from parent before applying template to child


Hi Michel,

The <xsl:apply-templates/> immediately after "Dear Member:" works on
all the children of the current context (i.e. "letter"). This means
it works through "surname", "givenName", etc. until it reaches "nsf".
Since you haven't defined explicit templates for those elements, the
default fires, which prints out the text. Then, when "nsf" is reached,
the template you supplied fires.

You can fix this by changing the <xsl:apply-templates/> to
<xsl:apply-templates select="nsf">

Rgds,

Dan.

-- 
Danny Yates
XML Technical Architect
Abbey National Treasury Services
E-mail: Danny.Yates@ants.co.uk
Phone: +44 20 7612 4017
Fax: +44 20 7612 4342


-----Original Message-----
From: Michel Gallant [mailto:michel@cifta.com]
Sent: 13 August 2002 15:19
To: 'XSL List (XSL-List@lists.mulberrytech.com)'
Subject: [xsl] Apply-template printing text from parent before applying
template to child


Hello,
I`m new to XSL and I`m having a bit of problems.
I have the following files:

XML:
<letterGen date="2002-01-01">
	<letter langPref="e">
		<surname>Lastname</surname>
		<givenName>Firstname</givenName>
		<address1>101 MyRoad</address1>
		<address2>Apt 8</address2>
		<city>MyCity</city>
		<province>MyProv</province>
		<postalCode>A1A 1A1</postalCode>
		<accountNum>023498287</accountNum>
		<nsf letterAmount="5">
			<currentBalance>-23.11</currentBalance>
			<chequeTo>My company</chequeTo>
			<chequeAmount>60.00</chequeAmount>
		</nsf>
	</letter>
</letterGen>

XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
	<xsl:template match="letterGen">
		<html>
			<head>
				<title>Test</title>
			</head>
			<body>
				<p>
					<xsl:value-of select="@date"/>
				</p>
				<xsl:apply-templates/>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="letter">
		<p>
			<xsl:value-of
select="givenName"/>&#160;<xsl:value-of select="surname"/>
			<br/>
			<xsl:value-of select="address1"/>
			<br/>
			<xsl:value-of select="address2"/>
			<br/>
			<xsl:value-of select="city"/>,&#160;<xsl:value-of
select="province"/>
			<br/>
			<xsl:value-of select="postalCode"/>
			<br/>
		</p>
		<p>Dear Member:</p>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="nsf">
		<p>
			We wish to advice you that your chequing account
currently has insufficient funds to cover the cheque / MasterCard debit of
<xsl:value-of select="chequeAmount"/> received today.
		</p>
	</xsl:template>
</xsl:stylesheet>

The problem that I'm having is that in my template for LETTER, when I do the
apply-templates, hoping to get the template for NSF, it prints out the text
contents of LETTER before the template for NSF, giving me the following :

<html xmlns:fo="http://www.w3.org/1999/XSL/Format";>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
<title>Test</title>
</head>
<body>
<p>2002-01-01</p>
<p>Firstname Lastname<br>101 MyRoad<br>Apt 8<br>MyCity, MyProv<br>A1A
1A1<br></p>
<p>Dear Member:</p>LastnameFirstname101 MyRoadApt 8MyCityMyProvA1A
1A1023498287<p>
			We wish to advice you that your chequing account
currently has insufficient funds to cover the cheque / MasterCard debit of
60.00 received today.
		</p>
</body>
</html>

I'm sorry for not being able to explain very well, but I'd appreciate any
help.  Thank you

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


***************************************************************************
This communication (including any attachments) contains confidential information.  If you are not the intended recipient and you have received this communication in error, you should destroy it without copying, disclosing or otherwise using its contents.  Please notify the sender immediately of the error.

Internet communications are not necessarily secure and may be intercepted or changed after they are sent.  Abbey National Treasury Services plc does not accept liability for any loss you may suffer as a result of interception or any liability for such changes.  If you wish to confirm the origin or content of this communication, please contact the sender by using an alternative means of communication.

This communication does not create or modify any contract and, unless otherwise stated, is not intended to be contractually binding.

Abbey National Treasury Services plc. Registered Office:  Abbey National House, 2 Triton Square, Regents Place, London NW1 3AN.  Registered in England under Company Registration Number: 2338548.  Regulated by the Financial Services Authority (FSA).
***************************************************************************


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]