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

RE: Call context within a named xsl:template

Subject: RE: Call context within a named xsl:template
From: Jeff Beadle <Jbeadle@xxxxxxxx>
Date: Thu, 15 Nov 2001 09:04:53 -0500
xsl call template context
thanks for your help Robert.

-----Original Message-----
From: Robert Stuart [mailto:Robert.Stuart@xxxxxxxxxxxxxxxxx]
Sent: Thursday, November 15, 2001 4:07 AM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: RE:  Call context within a named xsl:template


No, but you can validate parameters - which, in turn, can be used to force
calling templates to give some kind of context.

(Standard caveats regarding debugging apply.)

Something like this:

###############

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>

	<!-- a template with a required parameter -->
	<xsl:template name="called">
		<xsl:param name="caller"/>

		<!-- the interesting bit -->
		<xsl:if test="not( $caller )
			and not( caller = '0' )
			and not( caller = 'false' ) ">

			<xsl:message terminate="yes">
				<xsl:text>No caller given</xsl:text>
			</xsl:message>
		</xsl:if>
		<!-- end the interesting bit -->

		<!-- the rest of the template -->
		<b>Called by: <xsl:value-of select="$caller"/></b><br />
	</xsl:template>

	<xsl:template match="/">
		<xsl:call-template name="called">
			<xsl:with-param name="caller" select="'one'"/>
		</xsl:call-template>

		<xsl:call-template name="called">
			<xsl:with-param name="caller" select="'1'"/>
		</xsl:call-template>

		<xsl:call-template name="called">
			<xsl:with-param name="caller" select="'0'"/>
		</xsl:call-template>

		<xsl:call-template name="called">
			<xsl:with-param name="caller" select="'false'"/>
		</xsl:call-template>

<!--
	the following fails
	in my test environment, nothing but the "No caller given" message
appeared
 -->
		<!--
		<xsl:call-template name="called">
		</xsl:call-template>
		 -->
	</xsl:template>

</xsl:stylesheet>

###############

Cheers

Robert Stuart

======================================

Date: Wed, 14 Nov 2001 08:45:18 +0100
From: Ruben.Provoost@xxxxxxxxxxxxx
Subject: RE:  Call context within a named xsl:template

On 13 Nov 2001, at 18:06, Michael Kay wrote:

> > Is
> > there anyway I can determine who called me?
> >

> No.
> 
> (It's surprising how often people ask for features in XSLT that I've never
> come across in any other programming language...)

I've seen (NOT written...) Java code like this :

public void someMethod()
{
[snip]

Ruben Provoost

[snip]

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

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


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.