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

Grouping Problem in Hedear Tag

Subject: Grouping Problem in Hedear Tag
From: "Byomkesh" <bkesh@xxxxxxxxxxxxxxx>
Date: Thu, 29 Jun 2006 12:36:53 +0530
hedear
Dear Mukul,

I am so confused in Grouping style. I am new about apply Group. Some text
(next <h1> text) is missing in my output files. So Please Check my files....
My following Xml file is

XML File
------------

<html>
<body>
<div>
 <h1>Heading 1.</h1>
 <p>Some text here..</p>
 <p>Sahoo</p>
</div>
<div>
 <h2>Heading 2...</h2>
 <p>text here....</p>
<!-- If i am creat another <h2> text here, its not converting properly. -->

</div>
<div>
<h3>Heading 3.....</h3>
 <p>Some text here......</p>
</div>
<div>
 <h1>Again Heading 1.</h1>
 <p>Some text here..</p>
 <p>Introduction to Wi-Fi</p>
</div>
<div>
 <h2>Again Heading 2...</h2>
 <p>text here....</p>
 <p>History and Basics</p>
</div>
<div>
<h3>Again Heading 3.....</h3>
 <p>Some text here......</p>
</div>
</body>
</html>

and My XSL file
--------------------

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">

<xsl:output method="xml"  indent="yes" />

<xsl:template match="body">
   <document>
       <xsl:for-each-group select="*" group-starting-with="h1">
          <section1>
    <title><xsl:value-of select="current-group()[1]/h1" /></title>
  <xsl:choose>
   <xsl:when test="p">
   <xsl:apply-templates select="p"/>
   </xsl:when>

  </xsl:choose>
    <xsl:for-each-group select="current-group()[position() &gt; 1]"
group-starting-with="h2">
                  <section2>
    <title><xsl:value-of select="current-group()[1]/h2"/></title>
  <xsl:choose>
   <xsl:when test="p">
   <xsl:apply-templates select="p"/>
   </xsl:when>

  </xsl:choose>
    <xsl:for-each-group select="current-group()[position() &gt; 1]"
group-starting-with="h3">
          <section3>
          <title><xsl:value-of select="current-group()[1]/h3" /></title>
  <xsl:choose>
   <xsl:when test="p">
   <xsl:apply-templates select="p"/>
   </xsl:when>

  </xsl:choose>

          </section3>
                      </xsl:for-each-group>
  </section2>
              </xsl:for-each-group>
          </section1>
       </xsl:for-each-group>
   </document>
</xsl:template>

<xsl:template match="p">
<para>
<xsl:apply-templates/>
</para>
</xsl:template>

</xsl:stylesheet>

Now my out put ---------

<?xml version="1.0" encoding="UTF-8"?>
<document>
   <section1>
      <title>Heading 1.</title>
      <para>Some text here..</para>
      <para>Sahoo</para>
      <section2>
         <title>Heading 2...</title>
         <para>text here....</para>
         <section3>
            <title>Heading 3.....</title>
            <para>Some text here......</para>
         </section3>
      </section2>
   </section1>
<!-- Missing in Next <h1> text.. -->

</document>

Please suggest me, what is wrong.

Thanks and Regards

Byomkesh

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.