Page 1 of 1

How to select all tags until a certain tag

Posted: Wed Apr 13, 2011 11:20 am
by soccrtux
Hi,
I have the following XML:

Code: Select all

<root>
<H>1-A</H>
<H>1-B</H>
<P></P>
<P></P>
<P></P>
<H>2-A</H>
<P></P>
<P></P>
<H>3-A</H>
<H>3-B</H>
<H>3-C</H>
<P></P>
</root>
I need to have the following output:

Code: Select all

<R>
<RECORD>
<SOMETAG>
<H>1-A</H>
<H>1-B</H>
</SOMETAG>
<ANOTHER>
<P></P>
<P></P>
</ANOTHER>
</RECORD>
<RECORD>
<SOMETAG>
<H>2-A</H>
</SOMETAG>
<ANOTHER>
<P></P>
<P></P>
<P></P>
</ANOTHER>
</RECORD>
<RECORD>
<SOMETAG>
<H>3-A</H>
<H>3-B</H>
<H>3-C</H>
</SOMETAG>
<SOMETAG1>
<P></P>
</SOMETAG1>
</RECORD>
</R>
So all H and P tag belong together until another H tag is received.
Consequentiality all H tag belong together and all P tag should be grouped together.

Until now I didn't find a correct way to handle it yet.
Anybody having an idea on how to handle this in xslt?

regards,

Re: How to select all tags until a certain tag

Posted: Thu Apr 21, 2011 5:41 pm
by sorin_ristache
Hello,

Maybe the experts from the xsl-list mailing list can provide an XSLT solution for your processing.


Regards,
Sorin