• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

output xml structure problem  RSS feed

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
Posts: 23968
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.
How do they get the deer to cross at the signs? Or to read this tiny ad?
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!