This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

XML to XML transformation

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to transform one XML to another. I dont know if this question is silly.. but this is my code
<ROW num="22">
<REQUEST_NBR>001180929</REQUEST_NBR>
<SEQ_NBR>1</SEQ_NBR>
<REP_NUMBER>1</REP_NUMBER>
<REPORT_LINE_NBR>22</REPORT_LINE_NBR>
<COMP_CODE>ENCRS</COMP_CODE>
<COMP_DATA>SSP 1000 Intro Coll Learn 1.00 1.00 A <COMP_DATA>
</ROW>

Can i convert this block of XML to something like
<ROW num="22">
<REQUEST_NBR>001180929</REQUEST_NBR>
<SEQ_NBR>1</SEQ_NBR>
<REP_NUMBER>1</REP_NUMBER>
<REPORT_LINE_NBR>22</REPORT_LINE_NBR>
<COMP_CODE>ENCRS</COMP_CODE>
<COMP_DATA>
<SUB>SSP</SUB>
<MARKS> 1000 <MARKS>
Intro Coll Learn 1.00 1.00 A <COMP_DATA>
</ROW>
 
vivek ja
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry submitted the incomplete post by mistake
this is what the final XML should look like<ROW num="22">
<REQUEST_NBR>001180929</REQUEST_NBR>
<SEQ_NBR>1</SEQ_NBR>
<REP_NUMBER>1</REP_NUMBER>
<REPORT_LINE_NBR>22</REPORT_LINE_NBR>
<COMP_CODE>ENCRS</COMP_CODE>
<COMP_DATA>
<SUB>SSP</SUB>
<MARKS> 1000 <MARKS>
<SUBJECT>Intro Coll Learn </SUBJECT>
<GPA1> 1.00 <GPA1>
<GPA2> 1.00 <GPA2>
<GRADE>A </GRADE>
<COMP_DATA>
</ROW>
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do it with XSLT.
 
vivek ja
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Paul, Can you tell me how to start off.
Are there any examples available.
 
vivek ja
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I can transform from one tag to another, but as in my case
I can I create new tags as child tags?
Thank you!
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vivek ja:
but as in my case How
I can I create new tags as child tags?


Using xsl:element, chekc this tutorial => http://www.w3schools.com/xsl/el_element.asp
 
vivek ja
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I went through the tutorial and started with a small example, before diving deep:-)

I am facing this problem
When I transform the XML I am not getting the XML tags in the browser

If i want the output as HTML then i can include the HTML tags.
But since I want it as an XML, even if i give the XML tags ( tried without giving the XML tags too), its not displaying that and displaying only the data between the tags.

What should I do to get the tags in the XML document
 
vivek ja
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pls Help!!! Very urgent

How can i split this using XSLT

<NAME>Vivek R Ja</NAME>

to
<NAME>
<FIRSTNAME>Vivek</FIRSTNAME>
<MIDDLENAME>R</MIDDLENAME>
<LASTNAME>Ja</MIDDLENAME>
</NAME>
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do it with XSLT's string manipulation functions. Have a look at things like contains, substring, substring-before, string-length etc. (docs are here).
 
vivek ja
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The docs are very useful.
Thank you so much!
 
reply
    Bookmark Topic Watch Topic
  • New Topic