• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Transformation

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have an XML issue but I really don't know how to explain want I would like as a result. I have a XML with client information and services offered. I'd like to group all same clients in one node, so I will have all services inside it.
Take a look at this example it's more understandable:

This is the input XML:
<?xml version="1.0" encoding="UTF-8"?>
<REPORT>
<ROW>
<CLT_ID>1</CLT_ID>
<CLT_NAME>PETER</CLT_NAME>
<CLT_PHONE>XXX-XXX-XXXX</CLT_PHONE>
<SER_ID>1</SER_ID>
<SER_NAME>ANY SERVICE NAME</SER_NAME>
<JOB_DATE>2004/09/25</JOB_DATE>
</ROW>
<ROW>
<CLT_ID>1</CLT_ID>
<CLT_NAME>PETER</CLT_NAME>
<CLT_PHONE>XXX-XXX-XXXX</CLT_PHONE>
<SER_ID>2</SER_ID>
<SER_NAME>ANY OTHER SERVICE NAME</SER_NAME>
<JOB_DATE>2004/09/26</JOB_DATE>
</ROW>
<ROW>
<CLT_ID>2</CLT_ID>
<CLT_NAME>GREG</CLT_NAME>
<CLT_PHONE>XXX-XXX-XXXX</CLT_PHONE>
<SER_ID>1</SER_ID>
<SER_NAME>ANY SERVICE NAME</SER_NAME>
<JOB_DATE>2004/09/25</JOB_DATE>
</ROW>
</REPORT>

And this is the output XML:
<?xml version="1.0" encoding="UTF-8"?>
<REPORT>
<ROW>
<CLT_ID>1</CLT_ID>
<CLT_NAME>PETER</CLT_NAME>
<CLT_PHONE>XXX-XXX-XXXX</CLT_PHONE>
<JOBS>
<JOB>
<SER_ID>1</SER_ID>
<SER_NAME>ANY SERVICE NAME</SER_NAME>
<JOB_DATE>2004/09/25</JOB_DATE>
</JOB>
<JOB>
<SER_ID>2</SER_ID>
<SER_NAME>ANY OTHER SERVICE NAME</SER_NAME>
<JOB_DATE>2004/09/26</JOB_DATE>
</JOB>
</JOBS>
</ROW>
<ROW>
<CLT_ID>2</CLT_ID>
<CLT_NAME>GREG</CLT_NAME>
<CLT_PHONE>XXX-XXX-XXXX</CLT_PHONE>
<JOBS>
<JOB>
<SER_ID>1</SER_ID>
<SER_NAME>ANY SERVICE NAME</SER_NAME>
<JOB_DATE>2004/09/25</JOB_DATE>
</JOB>
</JOBS>
</ROW>
</REPORT>

How can I do the transformation using only XSLT? Thanks a lot. I'm new in XML/XSLT.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I do the transformation using only XSLT? Thanks a lot. I'm new in XML/XSLT.

Its very do-able using XSLT, no doubt.
However, personally, I don't want to give out a solution without any effort.
Write a simple style sheet - start from a simple example and modify it to
suit your application. Feel free to post here as you run into trouble.

Here's an example to get started.
These are very good and walk you through different scenarios and teach you
how to write an XSL style sheet.

Again, post here for any clarifications or if you get struck.
Happy learning.....

- m
 
Brian Grey
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for this wonderful advice.
But sorry I didn't have so much time last week. I just wanted some tips.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brian Grey:
Thanks a lot for this wonderful advice.
But sorry I didn't have so much time last week. I just wanted some tips.





Brian,

Don't get me wrong. You probably may not be one, but there are a lot of
people out there who don't put any effort and are in for a quick return.
Maybe its a homework assignment or something like that where someone is
trying to get an unfair advantage - I don't know.

All I was trying to do was help you learn. Sure we may not find the time
needed due to various reasons, but if you could atleast explain to us
what you did / did not do then we will be in a better situation to extend
our help.
Thanks.

- m
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic