[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Nodes between two nodes with the same name (again :-(

Subject: Nodes between two nodes with the same name (again :-(
From: "Smirnov, Anatoliy" <anatoliy.smirnov@xxxxxxxxxxx>
Date: Tue, 6 May 2003 08:48:19 -0400
row header html
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.