This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

output xml structure problem  RSS feed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am a newbie in XSL. I have transformed an xml to another xml using XSL Transformation. But instead of creating parent node and filling child node one by one in it. It is creating parent node every time it finds a child node.

Following is my xml file

And following is my xsl file



and following is the output xml



Now I am not able to create one parent node <Content> and add all the <ContentNo> node in it.
Kindly help
 
Marshal
Posts: 24184
54
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, first of all your XSLT is more complicated than it needs to be (even though it appears very simple). It is equivalent to this:


But anyway, your complaint is that for each IndexEntry element you create a new Content element? Well, yeah. That's exactly what the posted code does. (Maybe the simple version displays that more clearly than the complicated version?)

So to solve this problem, you need to come up with a specification which describes when you want to generate a Content element and when you want to generate a ContentNo element. Something like "For each X in the source I want to generate Y". You are going to have more than one template because you will have different rules for when you generate the two elements. Give it a try and see what you come up with.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!