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 September 25th, 2007, 04:02 AM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formating the data Table values in XSLT

I have dataset which hold the table with like as below:
Column1 Column2 Column3 Column4
10016402 America 50989580 NULL
10016402 America 50989580 RITU, SHARMA
10016402 America 50989580 MEGHANA, SAM

I transform above data to excel.
Today i am getting data as displayed above in excel file. But i want to manipulate data and want to display some like as below:

Column1 Column2 Column3 Column4
10016402 America 50989580 RITU, SHARMA/MEGHANA, SAM

Means i don't need repeating rows(first three columns), instead of i want to merge last column and display in single cell of last column, is it possible using XSLT?

Here is my current xslt code:
---------------------------------------
...
..
<xsl:for-each select='DataSetName/Table'>
 <tr>
  <td><xsl:value-of select='_ID'/></td>
  <td><xsl:value-of select='_CON_NM'/></td>
  <td><xsl:value-of select='_NUM'/></td>
  <td><xsl:value-of select='REP_NAME'/></td>
 </tr>
</xsl:for-each>

..
...
------------------------------------------------

How do i merge all the three rows in single row. Pls drop your valuable inputs. Thanks

 
Old September 25th, 2007, 04:30 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You need to learn about grouping. See

http://www.jenitennison.com/xslt/grouping

It's very easy in XSLT 2.0 with the new xsl:for-each-group instruction, but involves rather clever programming tricks in 1.0.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 25th, 2007, 05:59 AM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks mhkay for such a quick reply.

 
Old October 5th, 2007, 04:30 AM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Got the Solution for the above prob. But now have something tricky here may be simple and a Great Challenge for me.

Have data like as below.

Column1 Column2 Column3 Column4 Column5
10016402 America 123 50989580 RITU, SHAMA/MEHANA, SAM
10016402 America 456 50989580 VIM, ARMA/GHANA, SAMA
10016402 America 789 50989580 XYZ, ABC/GHI, STUV

Need your help in removing the repeated values. means Column1, column2 and column4 need as single record instead of repeating the same. Need output as below.

Column1 Column2 Column3 Column4 Column5
10016402 America 123 50989580 RITU, SHAMA/MEHANA, SAM
                       456 VIM, ARMA/GHANA, SAMA
                       789 XYZ, ABC/GHI, STUV

I am in XSL 1.0 and new to this techonologies as well.
Anyone's clue or idea makes difference for me.

 
Old October 5th, 2007, 04:32 AM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

[Same as above but well arranged Table.]
 Got the Solution for the above prob. But now have something tricky here may be simple and a Great Challenge for me.

Have data like as below.

Column1 Column2 Column3 Column4 Column5
10016402 America 123 50989580 RITU, SHAMA/MEHANA, SAM
10016402 America 456 50989580 VIM, ARMA/GHANA, SAMA
10016402 America 789 50989580 XYZ, ABC/GHI, STUV

Need your help in removing the repeated values. means Column1, column2 and column4 need as single record instead of repeating the same. Need output as below.

Column1 Column2 Column3 Column4 Column5
10016402 America 123 50989580 RITU, SHAMA/MEHANA, SAM
                                456 VIM, ARMA/GHANA, SAMA
                                789 XYZ, ABC/GHI, STUV

I am in XSL 1.0 and new to this techonologies as well.
Anyone's clue or idea makes difference for me.

 
Old October 5th, 2007, 04:41 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Grouping (elimination of duplicates) is much easier in XSLT 2.0 than in 1.0. For advice on doing it in 1.0 see http://www.jenitennison.com/xslt/grouping

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Formating <li> as per xml using xslt 1.0 tims XSLT 9 May 12th, 2008 01:30 AM
Handle Null or Blank values using xslt in csv data mums XSLT 1 April 3rd, 2008 07:30 PM
Formating arbitrary data into a table. Axiverse XSLT 1 July 2nd, 2007 05:40 PM
how to populate a table with xml data in xslt miccipynewbie XSLT 6 May 28th, 2007 07:29 AM
xslt problem: values not displayed in table natjimy XSLT 2 December 1st, 2004 05:05 AM





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