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

Re: Merging nodes to process with FO

Subject: Re: Merging nodes to process with FO
From: Russell Levy <russlevy@xxxxxxxxxx>
Date: Thu, 01 Sep 2005 21:23:31 -0400
russell levy
xsl-list-digest-help@xxxxxxxxxxxxxxxxxxxxxx wrote:
Why don't you just nest the loops instead of putting them adjacent to each other?

Consider this little stysheet (change 'root' to a proper name) :

<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:key name="occupant" match="occupant" use="unitid"/>

<xsl:template match="root">
<xsl:for-each select="unit">
	<xsl:variable name="unit" select="."/>
	<xsl:variable name="occupants" select="key('occupant',id)"/>
	<xsl:choose>
		<xsl:when test="$occupants">
			<xsl:for-each select="$occupants">
				<xsl:value-of select="$unit/name"/> | <xsl:value-of select="name"/>
				<xsl:text>&#10;</xsl:text>
			</xsl:for-each>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$unit/name"/> | Vacant
		</xsl:otherwise>
	</xsl:choose>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
I had something like this (without using keys, as I just don't understand keys well enough other than to copy other people's examples :) ); the problem is that I was giving a simplified version of my problem. There are actually 7 or 8 columns per row, and it just seems that there must be a way that I don't have to have each column defined in both the when and the otherwise.

--Russell

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.