Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2007, 09:35 PM
Authorized User
 
Join Date: Dec 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Question

I have a source and a resultant xml.Can someone provide me with an xslt for this scenario.

Source
-------
<table>
    <tableData>
        <row>
            <a>cat A</a>
            <a>Asomestring1</a>
            <a>Asomeotherstring1</a>
            <b>Asomedata1</b>
            <b>Asomeotherdata1</b>
        </row>

        <row>
            <a>cat B</a>
            <a>Bsomestring1</a>
            <a>Bsomeotherstring1</a>
            <b>Bsomedata1</b>
            <b>Bsomeotherdata1</b>
        </row>

        <row>
            <a>cat A</a>
            <a>Asomestring2</a>
            <a>Asomeotherstring2</a>
            <b>Asomedata2</b>
            <b>Asomeotherdata2</b>
        </row>

        <row>
            <a>cat A</a>
            <a>Asomestring3</a>
            <a>Asomeotherstring3</a>
            <b>Asomedata3</b>
            <b>Asomeotherdata3</b>
        </row>

        <row>
            <a>cat B</a>
            <a>Bsomestring2</a>
            <a>Bsomeotherstring2</a>
            <b>Bsomedata2</b>
            <b>Bsomeotherdata2</b>
        </row>

    </tableData>
</table>


Resultant
------------
<rows>
<row>
<cell>cat A</cell>
<row><cell>Asomestring1</cell><cell>Asomeotherstring1</cell><cell>Asomedata1</cell><cell>Asomeotherdata1</cell></row>
<row><cell>Asomestring2</cell><cell>Asomeotherstring2</cell><cell>Asomedata2</cell><cell>Asomeotherdata2</cell></row>
<row><cell>Asomestring3</cell><cell>Asomeotherstring3</cell><cell>Asomedata3</cell><cell>Asomeotherdata3</cell></row>
<row></row>

</row>

<row>
<cell>cat B</cell>
<row><cell>Bsomestring1</cell><cell>Bsomeotherstring1</cell><cell>Bsomedata1</cell><cell>Bsomeotherdata1</cell></row>
<row><cell>Bsomestring2</cell><cell>Bsomeotherstring2</cell><cell>Bsomedata2</cell><cell>Bsomeotherdata2</cell></row>
</row>

</rows>




 
Old December 6th, 2007, 05:06 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

As is so often the case with XSLT this is a grouping question.

If you are using XSLT 2.0 then use <xsl:for-each-group>, and if you are using XSLT 1.0 then you need to use the slightly more complicated Muenchian Grouping method: http://www.jenitennison.com/xslt/gro...muenchian.html

Give it a try yourself and then if you are still stuck show us what your XSLT looks like and we'll try to help.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT conversion question jastao XSLT 3 April 29th, 2008 09:09 PM
Newbie XSLT question fedehf XSLT 4 January 29th, 2008 03:09 PM
XSLT n00b question rockypg XSLT 4 October 3rd, 2006 10:23 AM
xslt basic question kgoldvas XSLT 2 January 25th, 2006 02:48 PM
easy XSLT question sgruhier XSLT 3 February 18th, 2005 11:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.