How to select all tags until a certain tag

Here should go questions about transforming XML with XSLT and FOP.
soccrtux
Posts: 1
Joined: Wed Apr 13, 2011 11:10 am

How to select all tags until a certain tag

Post 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,
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: How to select all tags until a certain tag

Post by sorin_ristache »

Hello,

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


Regards,
Sorin
Post Reply