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

Passing variable to variable

Subject: Passing variable to variable
From: Linda van den Brink <lvdbrink@xxxxxxx>
Date: Thu, 29 Jul 1999 15:39:12 +0200
javascript showitem
<item>
	<name>Amaya</name>
	<category>web_browser</category>
</item>

My XML file contains over 500 items belonging to different categories, some
to more than one category. A page is generated by category containing those
items belonging to that particular category. The page contains a banner
displaying the directory structure, like this: web_browser = Internet /
Browsers / Web Browsers

I want that banner to be populated, depending upon the category items within
a category belong to.

I've gotten as far as recognizing the category an item belongs to using the
XSL stylesheet submitted earlier today by G. Ken Holman. The categories with
their respective items are properly generated, but the banner remains the
problem.

I was thinking that it might be possible to pass on the <xsl:variable> that
selects the category element, to another variable that assigns the processor
the correct string (Internet / Browsers / Web Browsers). Is it possible
doing this without having to completely redesign my current stylesheet?

Linda

BTW, this is my current stylesheet:

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
  xmlns="http://www.w3.org/TR/REC-html40"
  result-ns="">

<xsl:template match="/">                              <!--root rule-->
	<xsl:for-each select="//item">           <!--process all people-->
		<xsl:sort select="category"/>
		<xsl:variable name="cat" select="category"/>
		<!--process only one entry per sorted year-->
		<xsl:if test="not(preceding-sibling::item[category=$cat])">
			<html><head><title><xsl:value-of
select="$cat"/></title><link rel="stylesheet" type="text/css"
href="../../../styles/intro.css"></link><script language="JavaScript"
src="../../../scripts/introlib.js"></script><script
language="JavaScript">function hideAll(itemPrefix){for ( var i = 1; i &lt;=
<xsl:number value="count(//item[category=$cat])"/>; i++){hideItem(itemPrefix
+ i);}}</script></head><body><table class="bannerList"><tr><td
class="bannerList"><xsl:value-of select="$cat"/>s</td></tr></table><table
style="margin-top: 30px;"><tr><td colspan="2"><h4 style="margin-bottom:
10px">Application</h4></td><td colspan="1">	<h4 style="margin-bottom:
10px">Description</h4>	</td>	</tr><tr><td class="left" colspan="2"><ul
class="headLines">
			<!--reselect only those in the given year-->
				<xsl:for-each
select="//item[category=$cat]">
					<xsl:element name="a">
						<xsl:attribute
name="href">javascript:showItem('item<xsl:number value="position()"
format="1"/>')</xsl:attribute>
						<li><xsl:apply-templates
select="name"/>&#160;<xsl:apply-templates select="version"/></li>
					</xsl:element>
				</xsl:for-each>
			</ul></td><td class="right">
				<xsl:for-each
select="//item[category=$cat]">
					<xsl:sort select="name"/>
					<xsl:element name="div">
						<xsl:attribute
name="id">item<xsl:number value="position()" format="1"/></xsl:attribute>
						<xsl:attribute
name="class">newsItem</xsl:attribute>
						<h4><xsl:apply-templates
select="name"/>&#160;<xsl:apply-templates select="version"/></h4>
						<p><xsl:apply-templates
select="desc"/></p>
					</xsl:element>
				</xsl:for-each>
			</td></tr></table></body></html>
		</xsl:if>
	</xsl:for-each>
</xsl:template>

</xsl:stylesheet>


 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.