This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Grouping and Sorting on value inside group


FWIW - I guess you need to use keys because your actual problem is more
complicated than the examples, but here is the approach I would take, which
I think is just a restatement of Tom's first suggestion.  I post it only
because you say you might restructure your templates...and perhaps there's
something here you can use.

David.
 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>

<xsl:template match="dataset">
	<xsl:call-template name="outputElement"/>
</xsl:template>

<xsl:template match="*[starts-with(name(),'group')]">
	<xsl:element name="{name(.)}">
		<xsl:copy-of select="@*"/>
		<xsl:call-template name="outputData">
			<xsl:with-param name="sortby" select="'data_z'"/>
		</xsl:call-template>
	</xsl:element>
</xsl:template>

<xsl:template match="value">
	<xsl:call-template name="outputElement"/>
</xsl:template>

<xsl:template name="outputData">
	<xsl:param name="sortby" select="'data_x'"/>
	<xsl:for-each select="*[name()=$sortby]">
		<xsl:sort select="value"></xsl:sort>			
		<xsl:variable name="thisid" select="@dataid"/>
		<xsl:for-each select="../*[@dataid = $thisid]">
			<xsl:sort select="name()"/>
			<xsl:call-template name="outputElement"/>
		</xsl:for-each>
	</xsl:for-each>
</xsl:template>

<xsl:template name="outputElement">
	<xsl:element name="{name(.)}">
		<xsl:copy-of select="@*"/>
		<xsl:apply-templates/>
	</xsl:element>
</xsl:template>

</xsl:stylesheet>



> -----Original Message-----
> From: Hunsberger, Peter [mailto:Peter.Hunsberger@stjude.org]
> Sent: Wednesday, June 12, 2002 12:17 PM
> To: 'xsl-list@lists.mulberrytech.com'
> Subject: RE: [xsl] Grouping and Sorting on value inside group
> 
> 
> > It's not the key() function that's reducing it to a single 
> node, it's the 
> > generate-id() function you are running on the nodes 
> returned by key(). .4]
>   
> [snip]
> 
> > Beyond this I think Tom S. explained it.
> 
> Yes, what I meant was that perhaps I should be a little more 
> explicit in
> what I'm passing into the key function when I generate the  
> keys.  However,
> I find that I actually do understand what's going on now, although my
> understanding on how to get keys to always return the results I expect
> remains a little foggy (more experimentation needed).
> 
> >But I'm confused not having the examples in front of me. 
> Would you be able 
> >to snip them out (again) and recapitulate the question if 
> I'm not getting 
> >what you're asking?
> 
> At this point I don't think its worth you spending more time 
> on it.  I just
> made one other reply a bit ago that may help explain the bit you where
> "missing".  It does have some open questions that I could use 
> some opinions
> on, but I'm pretty much ok with the way the grouping is 
> currently working. 
> 
> The exception is the open question on  why I can't get the 
> key to replace
> the //dataset reference to work.  That's what I'll play with 
> over the next
> couple of days.  I may end up posting back to the list again, but I'm
> starting to suspect there's a way to restructure the whole 
> set of templates
> to deal with the data with a different line of attack that 
> may make the
> whole issue go away...
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


---------------------------------------

The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission.  If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited.  If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments.  Thank you.

Every effort is made to keep our network free from viruses.  You should, however, review this e-mail message, as well as any attachment thereto, for viruses.  We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]