|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Call context within a named xsl:template
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








