Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 8th, 2008, 12:07 AM
Authorized User
 
Join Date: Apr 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nested Bullet List

I need to transform[list]
        <li>ddff</li>
        <li>ffffff</li>
        [list]
          <li>fffrrtytty</li>
          <li>tytyty</li>
        </ul>
      </ul>

to [list]
        <li>ddff</li>
        <li>ffffff
        [list]
          <li>fffrrtytty</li>
          <li>tytyty</li>
        </ul></li>
      </ul>

i.e if Nested ul is present it should come under upper node <li>

 
Old May 8th, 2008, 06:37 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Here is an XSLT 1.0 stylesheet that performs the transformation:
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

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

  <xsl:template match="ul">
    <xsl:copy>
      <xsl:apply-templates select="li[1]"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="li">
    <xsl:copy>
      <xsl:apply-templates/>
      <xsl:apply-templates select="following-sibling::*[1][self::ul]"/>
    </xsl:copy>
    <xsl:apply-templates select="following-sibling::li[1]"/>
  </xsl:template>

</xsl:stylesheet>
--
  Martin Honnen
  Microsoft MVP - XML





Similar Threads
Thread Thread Starter Forum Replies Last Post
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
nested for hastikeyvan Classic ASP Professional 1 July 27th, 2006 06:28 PM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
List tablesname from database & list databasename ittorget MySQL 3 September 10th, 2005 03:06 AM
Nested If pans Access 4 December 10th, 2004 12:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.