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 April 26th, 2012, 03:30 PM
Registered User
 
Join Date: Apr 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Transforming data from multiple records into one record

Hi,

I have following requirement. can this be done using xslt.

Input details:
<Part>
<part Name>FirstPartName</part Name>
<part value>ABCDE</part value>
</part>
<Part>
<part Name>SecondPartName</part Name>
<part value>FGHIJ</part value>
</part>
<Part>
<part Name>ThirdPartName</part Name>
<part value>KLMNO</part value>
</part>



Output:Based on the value in the <part Name>, the following data should be the target value of this xslt.

<Output>
<Part1Value>ABCDE</Part1Value>
<Part2Value>FGHIJ</Part2Value>
<Part3Value>KLMNO</Part3Value>
<Output>
 
Old April 26th, 2012, 05:36 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your input is not well-formed XML. This makes it difficult, though not impossible, to process using XSLT. Perhaps, however, the errors in your XML were not intended. In that case, the transformation becomes trivial: but I won't give you any code, because I don't know what the real XML looks like.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old May 2nd, 2012, 01:24 AM
Registered User
 
Join Date: Apr 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Transforming data from multiple records into one record

Ahh.. my bad, here is the valid xml.

Hi,

I have following requirement. can this be done using xslt?

Input details:
<Parts>
<Part>
<partName>FirstPartName</partName>
<partvalue>ABCDE</partvalue>
</Part>
<Part>
<partName>SecondPartName</partName>
<partvalue>FGHIJ</partvalue>
</Part>
<Part>
<partName>ThirdPartName</partName>
<partvalue>KLMNO</partvalue>
</Part>
</Parts>


Output:Based on the value in the <partName>, the following data should be the target value of this xslt.

<Output>
<Part1Value>ABCDE</Part1Value>
<Part2Value>FGHIJ</Part2Value>
<Part3Value>KLMNO</Part3Value>
<Output>
 
Old May 2nd, 2012, 04:04 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Yes, it can be done, in fact it is very easy. What part of it are you finding hard? Please don't expect someone to just write the code for you: we're here to help you solve your problems, not to do your job, and we can't help you over this difficulty unless you explain where the obstacle lies.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Transforming xml data using xslt nelly78 XSLT 2 September 16th, 2010 11:27 AM
Transforming data in required XML Format pvasudevan XSLT 6 September 6th, 2006 02:34 AM
transforming data to Excel x_ray SQL Server DTS 1 December 30th, 2005 01:07 AM
selecting multiple records as one record array Greywacke Classic ASP Databases 1 February 10th, 2004 10:33 AM
one record set multiple data sources jack1234 Classic ASP Professional 1 October 17th, 2003 12:50 PM





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