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.
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.