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

Grouping: unordered lists from xml to html

Subject: Grouping: unordered lists from xml to html
From: "J. S. Rawat" <jrawat@xxxxxxxxxxxxxx>
Date: Thu, 16 Oct 2008 14:42:06 +0530
 Grouping: unordered lists from xml to html
Hi List,
I am doing html to xml conversion and we need grouping in this regard. I found one solution within the list which is not working as per requirement. I sharing input, output and required output.


XML
<summary>
<para bullet="1">This is paragraph 1</para>
<para bullet="0">This is paragraph 2</para>
<para bullet="1">This is paragraph 3</para>
<para bullet="1">This is paragraph 4</para>
</summary>

XSL
<xsl:template match="para[@bullet=0]">
  <p><xsl:apply-templates/></p>
  <xsl:apply-templates select="following-sibling::para[1]"/>
</xsl:template>

<xsl:template match="para[@bullet=1][preceding-sibling::para[1][@bullet=1]]">
    <li><xsl:apply-templates/></li>
    <xsl:apply-templates select="following-sibling::para[1]"/>
</xsl:template>

<xsl:template
match="para[@bullet=1][not(preceding-sibling::para[1][@bullet=1])]">
  <ul>
    <li><xsl:apply-templates/></li>
    <xsl:apply-templates select="following-sibling::para[1]"/>
</ul>
</xsl:template>

<xsl:template match="summary">
   <xsl:apply-templates select="para[1]"/>
</xsl:template>

OUTPUT
  <ul>
      <li>This is paragraph 1</li>
      <p>This is paragraph 2</p>
      <ul>
         <li>This is paragraph 3</li>
         <li>This is paragraph 4</li>
      </ul>
   </ul>

REQUIRED OUTPUT
<ul>
      <li>This is paragraph 1</li>
 </ul>
      <p>This is paragraph 2</p>
      <ul>
         <li>This is paragraph 3</li>
         <li>This is paragraph 4</li>
      </ul>

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.