Subject: [xsl] Nodes between two nodes with the same name (again :-( From: "Smirnov, Anatoliy" <anatoliy.smirnov@xxxxxxxxxxx> Date: Tue, 6 May 2003 08:48:19 -0400 |
I need to output all nodes between two nodes with the same name, so that from the node <h> becomes the HEADER and all nodes after <h> until the next <h> become the BODY. The source file is: <html> <body> <h> Header </h> <p> A </p> <dl> <dt> B </dt> <dt> C </dt> </dl> <h>Header </h> <p> D </p> <dl> <dt> <dt> E </dt> </dt> </dl> <p> F </p> </body> </html> I need to have this output <ROWSET> <ROW> <HEADER> Header </HEADER> <BODY> ABC </BODY> </ROW> <ROW> <HEADER> Header </HEADER> <BODY> DEF </BODY> </ROW> <ROWSET> I found the similar posting on xsl list at http://www.biglist.com/lists/xsl-list/archives/20008/msg01102.html by Jeni Tennison by have hard time implementing it. My xsl is <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="html/body"> <ROWSET> <xsl:apply-templates/> </ROWSET> </xsl:template> <xsl:template match="html/body/h"> <ROW> <HEADER> <xsl:value-of select="."/> </HEADER> <BODY> <xsl:apply-templates select="following-sibling::*[generate-id(following-sibling::html/body/h[1])= generate-id(current()/following-sibling::html/body/h[1])]"/> </BODY> </ROW> </xsl:template> </xsl:stylesheet> and it gives me (numbers for reference only): 1 <ROWSET> 2 <ROW> 3 <HEADER> Header </HEADER> 4 <BODY> ABC 5 <ROW> 6 <HEADER> Header </HEADER> 7 <BODY> DEF </BODY> 8 </ROW> 9 DEF 10 </BODY> 11 </ROW> 12 ABC 13 <ROW> 14 <HEADER> Header </HEADER> 15 <BODY> DEF </BODY> 16 </ROW> 17 DEF 18 <ROWSET> with lines 5-9,12,17 that I don't want to be there. Please, can someone help. Thank you. Anatoliy Smirnov Department of Veterans Affairs XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] MSXML 4.0 SP2 crashes when co, gutman | Thread | RE: [xsl] Nodes between two nodes w, Américo Albuquerque |
[xsl] MSXML 4.0 SP2 crashes when co, gutman | Date | [xsl] Tables interactive, John Proctor |
Month |