 |
| 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
|
|
|
|

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

September 25th, 2007, 04:30 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

September 25th, 2007, 05:59 AM
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks mhkay for such a quick reply.
|
|

October 5th, 2007, 04:30 AM
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

October 5th, 2007, 04:32 AM
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
[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.
|
|

October 5th, 2007, 04:41 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|
 |