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

RE: how to pass parameters down through nested templat

Subject: RE: how to pass parameters down through nested templates using xsl:apply templates in a nested fashion?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 11 Sep 2003 09:08:03 +0100
nested templates in xsl
> Wierdly some places {} are required and some places they are 
> not. Is there some kind of ruleset or guideline on that ??

Yes. It's called the language specification.

http://www.w3.org/TR/xslt#attribute-value-templates

Michael Kay


> 
> Here is the working XSL that should show anyone how to keep 
> pushing parameters as and when required in nested template 
> calls or apply templates
> 
> Abhishek Sanwal
> HP - Houston Campus
> abhishek.sanwal@xxxxxx
> 
> WORKING CODE:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <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="Matrix">
> <xsl:param name="HeadAlign" select="'Right'"/>
> <xsl:param name="DataAlign" select="'Right'"/>
> 
> 	<xsl:if test="contains(@HeadFlow,'H')">
> 		<font class="debug">Horizontal</font>		
> 
> 		<table border="0">
> 			<xsl:apply-templates mode="H">
> 			<xsl:with-param name="HeadAlign"
> select="'Center'"/>
> 			<xsl:with-param name="DataAlign"
> select="'Center'"/>
> 			</xsl:apply-templates>
> 		</table>
> 	</xsl:if>
> 
> 	<xsl:if test="contains(@HeadFlow,'V')">
> 		<font class="debug">Vertical</font>
> 
> 		
> 		<table border="0">
> 			<xsl:apply-templates mode="V">
> 			<xsl:with-param name="HeadAlign"
> select="'Left'"/>
> 			<xsl:with-param name="DataAlign"
> select="'Left'"/>
> 			</xsl:apply-templates>
> 		</table>
> 	</xsl:if>
> 
> </xsl:template>
> 
> <xsl:template match="MatrixHeadArray" mode="H">
> <xsl:param name="HeadAlign" select="'Right'"/>
> <xsl:param name="DataAlign" select="'Right'"/>
> 	<tr align="{$HeadAlign}">
> 		<xsl:apply-templates mode="H">
> 		<xsl:with-param name="HeadAlign" select="$HeadAlign"/>
> 		<xsl:with-param name="DataAlign" select="$DataAlign"/>
> 		</xsl:apply-templates>
> 	</tr>
> </xsl:template>
> 
> <xsl:template match="MatrixHeadCell" mode="H">
> <xsl:param name="HeadAlign" select="'Right'"/>
> <xsl:param name="DataAlign" select="'Right'"/>
> 	<th align="{$HeadAlign}">
> 		<xsl:apply-templates/>
> 	</th>
> </xsl:template>
> 
> <xsl:template match="MatrixDataArray" mode="H">
> <xsl:param name="HeadAlign" select="'Right'"/>
> <xsl:param name="DataAlign" select="'Right'"/>
> 	<tr align="{$DataAlign}">
> 		<xsl:apply-templates mode="H">
> 		<xsl:with-param name="HeadAlign" select="$HeadAlign"/>
> 		<xsl:with-param name="DataAlign" select="$DataAlign"/>
> 		</xsl:apply-templates>
> 	</tr>
> </xsl:template>
> 
> <xsl:template match="MatrixDataCell" mode="H">
> <xsl:param name="HeadAlign" select="'Right'"/>
> <xsl:param name="DataAlign" select="'Right'"/>
> 	<td align="{$DataAlign}">
> 		<xsl:apply-templates/>
> 	</td>
> </xsl:template>
> 
> <xsl:template match="MatrixHeadArray" mode="V">
> <xsl:param name="HeadAlign" select="'Right'"/>
> <xsl:param name="DataAlign" select="'Right'"/>
> 	<xsl:for-each select="MatrixHeadCell">
> 		<tr>
> 			<th align="{$HeadAlign}">
> 				<xsl:apply-templates/>
> 			</th>
> 			<xsl:variable name="headloc">
> 				<xsl:value-of select="@i"/>
> 			</xsl:variable>
> 			<xsl:for-each select="../../MatrixDataArray">
> 				<td align="{$DataAlign}">
> 					<xsl:apply-templates 
> select="MatrixDataCell[@i=$headloc]"/>
> 				</td>
> 			</xsl:for-each>
> 		</tr>
> 	</xsl:for-each>
> </xsl:template>
> 
> <xsl:template match="MatrixDataCell" mode="V"/>
> <xsl:param name="HeadAlign" select="'Right'"/>
> <xsl:param name="DataAlign" select="'Right'"/>
> 
> </xsl:stylesheet>
> 
> -----Original Message-----
> From: SANWAL, ABHISHEK (HP-Houston) 
> Sent: Wednesday, September 10, 2003 5:31 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  how to pass parameters down through nested 
> templates using xsl:apply templates in a nested fashion?
> 
> Wendell,
> 
> Just made the changes you suggested. But still have an issue. 
> Please correct the following if they are wrong.
> 
> To push the initial value of the parameter - (Okay or not) 
> <xsl:with-param name="HeadAlign" select="'Center'"/> 
> <xsl:with-param name="DataAlign" select="'Left'"/>
> 
> To obtain the parameter value in the called template  (with default
> values)
> <xsl:param name="HeadAlign" select="'Right'"/>
> 
> Its just a literal string that I want to place in the <th>, 
> <td> or <tr> tags to set the text alignment of the cell. Like 
> this... (doesn't work) To push the value of the parameter 
> out. (Should I use XSL"value of and how would I actually 
> write it into the the following HTML tags ??
> 
> 	<tr align="$HeadAlign">
> 	<th align="$HeadAlign">
> 	<td align="$DataAlign">
> 
> Unfortunately it wont "spit" out those parameters into the 
> th, tr, td values. I have tried this with curly braces and 
> without and etc.
> 
> Of course I am getting nowhere with the trial and error.
> 
> Please let me know what would be the correct "syntax" for the 
> THREE XSL statements as mentioned above. (to make this possible :( ).
> 
> Thanks a lot.
> 
> Abhishek Sanwal
> 
> 
>  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.