|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Passing variable to variable
<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 <=
<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"/> <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"/> <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
|
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








