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

RE: Elminitate redundancy by using variables

Subject: RE: Elminitate redundancy by using variables
From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx>
Date: Wed, 24 Mar 2004 11:47:11 -0500
using variables in xslt
I see what you are saying.  The only param I am using is "count" because I
have to pass in the value of position() to the template. So I guess the
essential idea is that I don't have to store my listing of td elements in a
variable.

-----Original Message-----
From: Pieter Reint Siegers Kort [mailto:pieter.siegers@xxxxxxxxxxx] 
Sent: Wednesday, March 24, 2004 11:40 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Elminitate redundancy by using variables

Yes, but as Michael mentioned you do not have to use variables nor params,
and that's what your question was about... So you got me a bit confused.
Anyway, my reply was floating around as I was not getting the usual list
server output, this seems to have been corrected now.

<prs/> 

-----Original Message-----
From: Kenny Akridge [mailto:kenny@xxxxxxxxxxxxxxxxx] 
Sent: Wednesday, March 24, 2004 8:40 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Elminitate redundancy by using variables

Funny you mention that because I actually am already doing that :)


-----Original Message-----
From: Pieter Reint Siegers Kort [mailto:pieter.siegers@xxxxxxxxxxx]
Sent: Wednesday, March 24, 2004 9:33 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Elminitate redundancy by using variables

Hi Kenny,

>Is there a way to save the value from the beginning of the <td> to the 
>end,

>including the generate value of LineItemName?

You may be able to just use xsl:param or xsl:variable within your template,
and to avoid the repeating you mention you should iterate through the td
elements by simply defining a template at that node level, and the XSL
processor will automatically loop through them. One way to do this is to use
xsl:apply-templates which selects the node-set to process, in this case the
nodes you want to process in your TD elements. 

An example that does this and uses an alternating row color value is as
follows (note that it does not use params nor variables):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="msxsl local xql"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:local="#local-functions"
xmlns:xql="#xql-functions">

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

<xsl:template match="/">
	<html>
	<head>
	<title>ASP 3.0 (classic) to ASP.NET C# Performance Tests</title>
	</head>
	<body bgcolor="#efc6ff">
		<h3 align="center" style="width:600">ASP 3.0 (classic) to
ASP.NET C# Performance Tests</h3>
		<table border="1">
		<tr><td>
		<table cellpadding="3" cellspacing="0" border="0"
width="600">
			<tr>
				<th align="left" bgcolor="Lightblue"><font
color="white">Customer ID</font></th>
				<th align="left" bgcolor="Lightblue"><font
color="white">Company Name</font></th>
				<th align="left" bgcolor="Lightblue"><font
color="white">Contact Name</font></th>
			</tr>
			<xsl:apply-templates select="root/Customers"/>
		</table>
		</td></tr>
		</table>
	</body>
	</html>
</xsl:template>

<xsl:template match="Customers">
   <tr>
	<xsl:attribute name="bgcolor">
        <xsl:choose>
          <xsl:when test="position() mod 2 = 0">#ccfec7</xsl:when>
          <xsl:otherwise>#feffc6</xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
	<td>
		<xsl:value-of select="CustomerID"/>
	</td>
	<td>
		<xsl:value-of select="CompanyName"/>
	</td>
	<td>
		<xsl:value-of select="Country"/>
	</td>
   </tr>
</xsl:template>

</xsl:stylesheet>

HTH, Pieter 

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.