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

Re: grouping questions

Subject: Re: grouping questions
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Wed, 4 Aug 2004 09:33:24 -0700 (PDT)
csv.xsl
Hi Xiang,
Please try this XSL -
(this is a Muenchian Grouping solution)

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

<xsl:output method="text"/>
	
<xsl:key name="by-row" match="row"
use="concat(length,' ',Axis)" />
	
<xsl:template match="/root">
   <xsl:for-each select="Record/row[generate-id(.) =
generate-id(key('by-row', concat(length,'
',Axis))[1])]">
     Experiment (length=<xsl:value-of select="length"
/>,Axis=<xsl:value-of select="Axis"
/>)<xsl:text>&#xA;</xsl:text>
     <xsl:for-each select="key('by-row',
concat(length,' ',Axis))">
        <xsl:for-each select="*[(name() != 'length')
and (name() != 'Axis')]">
           <xsl:value-of select="name()"
/>=<xsl:value-of select="." />
             <xsl:if test="position() !=
last()">,</xsl:if>
	</xsl:for-each>
	<xsl:text>&#xA;</xsl:text>	        
     </xsl:for-each>
   </xsl:for-each>
</xsl:template>
	
</xsl:stylesheet>

I added a <root> tag at the begining to make the XML
well formed.

Hope I understood the problem correctly..

Regards,
Mukul

--- Xiang Li <lix@xxxxxxx> wrote:

> Hi, 
> 
> I have some problems in restructuring some data
> files. what i have to do is
> to group the measurements(<length>) of "a" and "c"
> (<Axis>) together, so i
> need to find what are the other tags in each row,
> and read their values to
> decide which ones belong to the same experiment. 
> 
> my xml file looks like this:
> 
> <Record sample="1">
>    <row row_id='0'>
>       <length>5.4</length>
>       <Axis>a</Axis>
>       <Environment>air</Environment>
>       <Temperature>200K</Temperature>
>    </row>
>    <row row_id='1'>
>       <length>5.3</length>
>       <Axis>c</Axis>
>       <Environment>air</Environment>
>       <Temperature>200K</Temperature>
>    </row>
>    <row row_id='2'>
>       <length>5.0</length>
>       <Axis>a</Axis>
>       <Environment>air</Environment>
>       <Temperature>400K</Temperature>
>    </row>
>    <row row_id='3'>
>       <length>5.4</length>
>       <Axis>c</Axis>
>       <Environment>air</Environment>
>       <Temperature>400K</Temperature>
>    </row>
>    <row row_id='4'>
>       <length>5.4</length>
>       <Axis>a</Axis>
>       <Environment>Ar</Environment>
>       <Temperature>200K</Temperature>
>    </row>
>    <row row_id='5'>
>       <length>5.4</length>
>       <Axis>c</Axis>
>       <Environment>Ar</Environment>
>       <Temperature>200K</Temperature>
>    </row>
> </Record>
> <Record sample="2">
> 	...
> </Record>
> 
> Problem is, tags other than <length> and <Axis> vary
> from sample to sample.
> this seems like impossible for me to do the grouping
> using xslt. Maybe some
> gurus here can give me your brilliant ideas?...
> thanks!!
> 
> Xiang



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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.