• 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

XSL conversion

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

I need to convert the below input.xml to the output.xml format.
Please advice

Input.xml:


Output.xml:

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

I suggest using an XSLT stylesheet. There's an excellent XML/XSL tutorial on the sun Java tutorial pages. I would offer some sample code but I am currently burnt out on my own XSL-FO project. Start at the tutorial learn the Java TrAX API and if you have more questions, come back and ask.Good luck!
 
Vineet Solabannavar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Craig,

Actually I have gone through tutors. I tried to do the conversion but am unable to find a solution. Have done the other parts, just need to add the <section_header> tag followed by <section_text>. Each time a <section_header> tag appears, the following tag should be a <section_text> tag.

Vineet
 
Clifton Craig
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vineet Solabannavar:
Hi,

I need to convert the below input.xml to the output.xml format.
Please advice

Input.xml:


Output.xml:


Cliff's the name XSL is the game. (My drill sergeants called me Craig!)
Anyway, to your point. My apologies as I didn't know how far along the XSL trail you had come. Off the top of my head (and un-tested) I'd say you want something like this in your stylesheet:

That should copy and collate the section_header and section_text elements for you. If that doesn't work quite right I would look into the key() function and maybe build a key on the position of these elements. From there you should be able to somehow match them based on position. Sorry I'm not being more specific.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vineet Solabannavar:
...just need to add the <section_header> tag followed by <section_text>. Each time a <section_header> tag appears, the following tag should be a <section_text> tag.

If I am reading the input XML correctly (the randomized indentation makes it a little difficult to follow), you already have every section_header element followed by a section_text element. So I am assuming you want to preserve those in the order they are already in, you just want to wrap them all in a sections element. Is this correct?
 
Clifton Craig
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,

he wants to interweave or collate the section_header and section_text elements. I also meant to add to my above post that you'll want to apply the section_header template from inside a sections element in your stylesheet like so:
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Clifton Craig:
[QB]Paul,

he wants to interweave or collate the section_header and section_text elements.

Oh yeah, your eyes are better than mine today.
 
Vineet Solabannavar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I actually want the <section_header> to appear after <section_text>.
Now the output I generate is all <section_header>'s tags followed by all <section_text> tags.

Please advise
 
reply
    Bookmark Topic Watch Topic
  • New Topic