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

Grouping of a plain html files

Subject: Grouping of a plain html files
From: "J. S. Rawat" <jrawat@xxxxxxxxxxxxxx>
Date: Thu, 30 Oct 2008 12:31:26 +0530
 Grouping of a plain html files
Hi all,
Can anybody help me out to get the required output.

Input
      <div class="TOC">
        <p class="TOC_entry_level1">Ent<i>r</i>y 1-1</p>
        <p class="TOC_entry_level1">Ent<b>r</b>y 1-2</p>
        <p class="TOC_entry_level1">Ent<b>r</b>y 1-3</p>
        <p class="TOC_entry_level2">Ent<b>r</b>y 2-1</p>
        <p class="TOC_entry_level2">Ent<b>r</b>y 2-2</p>
        <p class="TOC_entry_level1">Ent<i>r</i>y 1-4</p>
        <p class="TOC_entry_level2">Ent<b>r</b>y 2-3</p>
      </div

XSL
<xsl:template match="div[@class='TOC']">
 <toc>
  <xsl:apply-templates select="p[1][@class='TOC_entry_level1']"/>
 </toc>
</xsl:template>

<xsl:template match="p[@class='TOC_entry_level1']">
 <entry1>
  <xsl:apply-templates select="." mode="label1"/>
   <xsl:if test="following::p[1][@class='TOC_entry_level2']">
    <xsl:apply-templates select="following::p[1][@class='TOC_entry_level2']"/>
   </xsl:if>
 </entry1>
    <xsl:apply-templates select="following::p[1][@class='TOC_entry_level1']"/>
</xsl:template>

<xsl:template match="p[@class='TOC_entry_level2']">
 <entry2>
  <xsl:apply-templates select="." mode="label1"/>
 </entry2>
 <xsl:if test="following::p[1][@class='TOC_entry_level2']">
   <xsl:apply-templates select="following::p[1][@class='TOC_entry_level2']"/>
 </xsl:if>
 <xsl:if test="following::p[1][@class='TOC_entry_level1']">
   <xsl:apply-templates select="following::p[1][@class='TOC_entry_level1']"/>
 </xsl:if>
</xsl:template>

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

OUTPUT of Above XSL
<toc>
 <entry1>Ent<i>r</i>y 1-1</entry1>
 <entry1>Ent<b>r</b>y 1-2</entry1>
 <entry1>Ent<b>r</b>y 1-3
  <entry2>Ent<b>r</b>y 2-1</entry2>
  <entry2>Ent<b>r</b>y 2-2</entry2>
  <entry1>Ent<i>r</i>y 1-4
   <entry2>Ent<b>r</b>y 2-3</entry2>
  </entry1>
</entry1>
</toc>

REQUIRED OUTPUT
<toc>
 <entry1>Ent<i>r</i>y 1-1</entry1>
 <entry1>Ent<b>r</b>y 1-2</entry1>
 <entry1>Ent<b>r</b>y 1-3
  <entry2>Ent<b>r</b>y 2-1</entry2>
  <entry2>Ent<b>r</b>y 2-2</entry2>
  </entry1>
  <entry1>Ent<i>r</i>y 1-4
   <entry2>Ent<b>r</b>y 2-3</entry2>
  </entry1>
</toc>
Thanks
...JSR

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.