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

Re: Regrouping XML Data

Subject: Re: Regrouping XML Data
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Fri, 12 Jul 2002 02:37:13 +0200
Re:  Regrouping XML Data
Lotus Soda wrote:
Dear Friends

I have the following XML data
       <row>
            <col>
                <data>
                    Surveyor
                </data>
                <data>
                    Excavation
                </data>
                <data>
                    Plumber
                </data>
            </col>
            <col>
                <data>
                    11/02/2000
                </data>
                <data>
                    15/02/2000
                </data>
                <data>
                    11/03/2000
                </data>
            </col>
       </row>

I am having difficulty transforming this into:

       <row>
            <col>
                <data>
                    Surveyor
                </data>
                <data>
                    11/02/2000
                </data>
            </col>
            <col>
                <data>
                    Excavation
                </data>
                <data>
                    15/02/2000
                </data>
            </col>
            <col>
                <data>
                    Plumber
                </data>
                <data>
                    11/03/2000
                </data>
            </col>
       </row>

Each <row> has a fixed number of <col>
Each <col> has one set of <data> (this set is variable)
The <data> sets are equal for all <col> in each <row>

Any help is appreciated

That's table transposition, I think: <xsl:template match="row"> <row> <xsl:for-each select="col[1]/data"> <xsl:variable name="nr" select="position()"/> <col> <xsl:for-each select="../../col"> <xsl:copy-of select="data[$nr]"/> </xsl:for-each> </col> </xsl:for-each> </row> </xsl:template>

Beware, almost untested.

J.Pietschmann


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.